[CentOS] creating disk images

Fri Jul 14 22:12:56 UTC 2006
Yiorgos Stamoulis <yiorgos-lists at 272deg.homelinux.net>

compressing the resulting image is unlikely to give good results.  This 
is because the dd image is done bit-bu-bit and the free space is usually 
full of random rubbish and NOT very compressible.  I remember reading 
somewhere that the best way is to fill the empty space with zeroes, 
which can be compressed nicely!!

something like

*dd if=/dev/zero of=zero.pad count=1 bs=100M*

where bs is _larger_ than the free space of your disk and the zero.pad 
file is on the disk in question.  The commad will fail when the disk 
gets full.  Delete the zero.pad file and voila! all your free space will 
be much more _compressible_ !


Eduardo Grosclaude wrote:

>     >Replacing /dev/hda1 in your dd line by /dev/hda used to work.
>     Thanks, I'll try that...
>     Any way to drop the size of the created image?
>     Ex: disk is 100G and I no longer need all the extra space. perhaps
>     only 20Gig image instead of the full 100Gig.
> Extracting and compressing images depends on what you're up to. You 
> can compress the created image, even on the fly, but then perhaps 
> dd'ing a whole disk is not such a good idea if all you're interested 
> in is backing up files, as you're saving lots of unused blocks in your 
> filesystems, and also taking a completely useless snapshot of your 
> whole swap partition. If backing up files is your business, you 
> shouldn't be bypassing the filesystem as with dd, so you will want to 
> read about tar or cpio for instance. On the other hand, you may wish 
> to keep a pristine image of a disk for forensics purposes, so dd is 
> the way to go. Feel free to elaborate about your needs and we may be 
> able to help better.
> -- 
> Eduardo Grosclaude
> Universidad Nacional del Comahue
> Neuquen, Argentina
>CentOS mailing list
>CentOS at centos.org