[CentOS] ssh and dd

Mon Jul 26 19:54:27 UTC 2010
Gordon Messmer <yinyang at eburg.com>

On 07/25/2010 03:26 PM, Ross Walker wrote:
>
> Better then dd over ssh,

Well, no...  If you're trying to do an *image*, you'll find that cpio 
can't write an image out to a block device.

It's fairly easy to make dd as bandwidth efficient as clonezilla.

1: Clear all of the unused blocks on the local filesystem which you want 
to image:
# dd if=/dev/zero of=/mnt/zero
# rm /mnt/zero

2: Copy your filesystem to a file:
# umount /mnt
# dd if=/dev/sdb1 of=/var/tmp/fs.img

3: Compress your filesystem image:
# bzip2 /var/tmp/fs.img

4: Copy the image to the remote system:
# ssh root at remote 'bzip2 -dc | dd of=/dev/sda1' < /var/tmp/fs.img.bz2

Can't get much better than that for low-volume copies.  If you need to 
repeat the process on a lot of machines, clonezilla gives you some nice 
options.  If you're copying files instead of images, cpio might be useful.