[nSLUG] dd: disks of different sizes

Dop Ganger nslug at fop.ns.ca
Thu Jan 26 21:04:41 AST 2006

On Thu, 26 Jan 2006, Rick Wightman wrote:

> I've spent my Christmas and Birthday money on a 160Gb ATA drive so I can 
> upgrade my basement server from 8Gb and, among other things, hold my music 
> collection.

Nice! That should last you for... days! ;->

> Awhile back (but I can't find it in the archives) there was a discussion 
> about using dd to copy disks. Given the power that dd has for good, and for 
> evil, I'm looking for advice on what parameters and watchouts there might be.

I wouldn't recommend using dd to copy it over. The approach I prefer to 
use is to boot a rescue disk such as superrescue 
(http://www.kernel.org/pub/dist/superrescue/v2/) or RIP 
(http://www.tux.org/pub/people/kent-robotti/looplinux/rip/), create a 
/source and /target, mount the partitions appropriately, then do something 

( cd /source && tar -cf - ./ ) | ( cd /target && tar -xvf - )

This has the added benefit of defragmenting the files, as well as not 
wasting your time copying empty sectors. The trick is then to boot the 
disk; the easiest way is probably to boot the rescue disk again after 
configuring your hard drive as appropriate, but at the lilo/grub prompt, 
boot your target type in something like:

linux root=/dev/hda2

replacing /dev/hda2 with the appropriate device.

Added bonus tip: you can do a cheesy backup of a system this way by doing 
something like:

( cd /source && tar -cf - ./ ) | ( ssh targethost 'cd /target && tar -xvf -' )

And the equivalent restore would, of course, be:

( ssh targethost 'cd /target && tar -cf - ./ ) | ( cd /newtarget && tar -xvf - )

If you're running over a low bandwidth link, use ssh -C, but it's not 
worth it over a LAN.

Cheers... Dop.


More information about the nSLUG mailing list