Skip to content

grubernaut/Golang-Tar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Golang Sparse files and Tar

Proving that Golang, as of Go1.5.1 does not maintain sparse files during file compression with compress/tar.

Steps to reproduce:

vagrant up

During Vagrant Provision, Vagrant will perform the following steps:

  • Install Go1.5.1

  • Create a Sparse file on the Linux Filesystem by:

# truncate -s 512M sparse.img
  • Verify that the created file has an apparent size of 512M, but an actual size of 0M
# ls -lash sparse.img
0 -rw-r--r-- 1 root root 512M Nov 30 21:29 sparse.img
  • Run compress.go, which uses archive/tar to compress the sparse file both with and without the sparse type set in the archive header. This creates directories of non_sparse/ and sparse/ for non-sparse and sparse compression, named respectively.

  • Extract both of the archives created from compress.go.

# tar -C non_sparse/ -xf non_sparse/non_sparse.tar
# tar -C sparse/ -xf sparse/sparse.tar
  • Verifies that Go did NOT keep file sparseness regardless of whether the GNUSparse type was set in the archive header or not.
# ls -lash non_sparse/sparse.img
512M -rw-r--r-- 1 root root 512M Nov 30 21:29 non_sparse/sparse.img
# ls -lash sparse/sparse.img
513M -rw-r--r-- 1 root root 512M Nov 30 21:29 sparse/sparse.img
  • Compresses the sparse file using GNU Tar, maintaining the sparseness of the file
tar -Scf tar/sparse.tar sparse.img
  • Extract the archive created from GNU Tar.
tar -C tar/ -xf tar/sparse.tar
  • Verify that compression via Tar, maintains the sparse file.
ls -lash tar/sparse.img
0 -rw-r--r-- 1 root root 512M Nov 30 21:29 tar/sparse.img

About

Proving Golang 1.5.1 does not maintain sparse files on compression

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages