Playing with sparse files
peter at mcnabbs.org
Fri Mar 11 12:41:06 MST 2011
On Thu, Mar 10, 2011 at 12:09:08PM -0700, Joseph Hall wrote:
>Question 1: Why is my non-sparse file full of zeros, sitting inside
>the filesystem inside the new sparse file, not taking up a lot of
cp creates holes for sparse files from long sequences of 0's.
This leads to a handy trick when you are copying a VM disk image. If the
VM has been running for a while and writing/unlinking files, you can do:
dd if=/dev/zero of=/tmp/foo; rm -f /tmp/foo
Then shutdown the VM, copy the disk image with "cp --sparse=always", and
your new disk image file should be much smaller.
More information about the PLUG