Preserving a Sparse File during copying

Post Type: 
Tutorial

Level: Advanced


Okay, say if you have a large virutal machine image, that you have
copied from your external usb drive to your harddrive.

Myimage.img 4G

If the file contains a lot of zero blocks , you can convert the file to
a sparse file with.

cp --sparse=Myimage.img mysparseimage.img

ls will report it's the size of the file.

du mysparseimage.img will report the actual size on disk.

http://freshmeat.net/projects/phantom/

this tools with convert all files to sparse files, beware I've not tried
this tool, so if it trashes your harddisk , don't blame me.