3

we have NFS storage, where we store our backups.. we manipulate with them from linux machine where the nfs is also mounted.. So, for example thin provisioned thin.vmdk disk is on linux seen as thin.vmdk and thin-flat.vmdk. We want to archive and compress them with tar and gzip, however when issuing simple tar command on those two.. the thin just dissappears and everythnig is suddenly 10G.

Even when I try to tar the thin-flat.vmdk, which has 1.6G, separately (with "tar cf thin.tar thin-flat.vmdk") it makes 10G tar file. This also happened when the I tried to run tar cf /extfs/thin.tar to create the tar on ext fs.

What kind of sorcery is this? Does anybody have a clue?

Thanks a lot.

Jakub Žitný
  • 165
  • 1
  • 4

4 Answers4

5

GNU tar, which you should have if you're using Linux, supports handling sparse files with the -S (or --sparse) option. Try

tar cSf thin.tar thin-flat.vmdk
Flup
  • 7,688
  • 1
  • 31
  • 43
  • Wow, thanks. How is does it work? How come I did not specify the -S option, tar created 10G tar archive and after I restored it, it was still 10G non-thin vmdk? Y'know what I mean? Isn't tar supposed to create identical unarchived file with the same checksum as the one before archiving? – Jakub Žitný Aug 06 '13 at 15:19
  • If you search for 'sparse files' you'll see how it works. – Flup Aug 06 '13 at 15:20
4

From the GNU tar(1) man page:

       -S, --sparse
              handle sparse files efficiently
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
4

You should tell tar to treat sparse files efficiently with the -S --sparse command line switch.

-S, --sparse handle sparse files efficiently

user9517
  • 114,104
  • 20
  • 206
  • 289
3

You're not supposed to do this. At least, if you're trying to develop a process around this, the more scalable approach is to archive using a different method.

If you want to export a VM and preserve its attributes, you can export as an OVF file. Or if you have VM-aware backup methods available, that may make more sense.

Also see: Move VMware ESXi VM to new datastore - preserve thin-provisioning

ewwhite
  • 194,921
  • 91
  • 434
  • 799