Translations of this page:

Tiny Backups

Shrinking dd gz

This is a trick to getting much smaller data dump images. It's actually very easy to do! Just create a big file full of zeros out of the free space inside the partition you are about to backup, and then delete the file.

dd if=/dev/zero of=delete bs=1M

Wait for it to fill the drive to its capacity then just.

rm delete

Now just proceed with your backup.

[NB. This command write zeros to the partition of your current path, so you should first change directory into the folder where the partition you want to backup is mounted before running these commands. e.g. if you have booted up your EeePC with Pupeee and are going to backup the 1st SSD (/dev/hdc1 as seen by Pupeee) which is mounted in /mnt/hdc1, then first run the command:]

cd /mnt/hdc1

Shrinking an Existing Image

If your image is already compressed then decompress it to a raw image.

gzip -d image.gz

Now mount it via loop back.

mount -o loop image /mnt/image

Create a large zero'ed file in the image.

dd if=/dev/zero of=/mnt/image/delete bs=1M

When the image is full it stop, now delete the file.

rm /mnt/image/delete

And recompress it.

gzip -9 image

The image should now be much smaller.

How it works

Compression relies on recognizing repeated patterns to reduce the size of a file. With a data dump style backup you aren't just compressing the existing files, but rather the filesystem itself. Now when you delete, edit, or move a file the filesystem doesn't actually get rid of the data. Instead it just removes the “reference” to that file, and allows new files to overwrite that spot. Now this makes thinsg harder for your compression protocol because it has to compress this data even if its been deleted. So what we are doing here is safely overwriting all this deleted data with zeros. Which is very easy to compress.(with gzip 1gig of zeros = 1 meg) An example of how well this works is this, I did a test install of windows on my Eeepc. I made only 4 gig partition on the system to do this. So to avoid having to deal with the cd drive method again I backed up the drive. It compressed down to 1.58 gigs. A few days later I was done playing and wanted to switch back to linux so backed up the partition again, though this time I used the method above. The image compressed down to 613megs… nearly a gig less, you should also note that I had in stalled about another 500 megs of programs during those few days.

 
howto/get_smaller_backups.txt · Last modified: 2008/09/26 10:00 by albkwan
 
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
This website is no longer under a Creative Commons license.
All rights are reserved by Eeeuser.com and each individual author
If you want to reproduce content, all individual contributers must be identified and you must seek permission from Eeeuser.com