About that "copying disks" thread and dd

Lamar Owen lowen at pari.edu
Thu Sep 6 20:30:44 UTC 2007


On Thursday 06 September 2007, Paul Johnson wrote:
> This has been a humbling experience.  If anybody does come with with a
> step by step fool proof way to make this work, I would be really glad
> to hear it.

I have done it the hard way before, and then I found the easy way.  Paragon 
Partition Manager's Rescue CD.

Note that if two disks are identical then you can just dd the whole disk at 
one fell swoop:  that is, dd if=/dev/sda of=/dev/sdb

Set the blocksize to some multiple of the cylinder size; run fdisk -l, find 
the cylinder size, and find the largest factor of the number of cylinders to 
multiply by.  It doesn't really matter exactly what the blocksize is with 
modern zoned disks, but any blocksize is better than the default, as long as 
the total size of the disk is an integer multiple of the blocksize.

I have cloned numerous systems that have had identical drives, and haven't had 
these sorts of problems.  But the key is the disks have to have identical 
parameters for this to work.

Paragon Partition Manager's Rescue CD Just Works, 99% of the time, and can 
resize, slice, and dice your partitions while it's doing it.  Think 
Gparted++++.

Now, if the disks are not identical, you have more work to do.  Note that 
copying a smaller disk to a larger disk will work just fine; I did a 40GB to 
an 80GB raw disk dd (using the /dev/sdX and not doing each partition 
individually) and it just worked.

Copying a larger disk to a smaller disk is more of an adventure, but it can be 
done.  The key is to resize the source disk's partitions before doing the dd, 
then doing the raw dd.  You can use parted or similar tool (the bootable 
Gparted CD with Clonezilla works pretty good for this, even with NTFS 
partitions), shrink the last partition down, then dd it across.

I actually keep a set of sysprepped Windows 2000 and XP images that have been 
shrunk down to minimum size; I can dd that image from the file server (using 
something like: "ssh fileserver.pari.edu cat /backup_set/win2k.img | dd 
of=/dev/sdX") then run either the Windows native diskpart tool or 
parted/Gparted to grow the partition to the full disk.  So I have a 4.5GB 
WinXP sysprepped image that I can easily deploy as needed; I keep the image 
current and updated, and already have the settings, users, etc all set up; 
the sysprep tool sets things up to ask for the CD key and do activation upon 
firstboot.  Grow it to the destination disk's size, and deploy the 
workstation.  This assumes very close hardware; odd hardware still requires 
separate installs.

I have gone through the pain of rebuilding initrds before; I had to change the 
SCSI card in a server quickly (the old card failed, it was a production 
server, and it needed to be back up RIGHT NOW), and I didn't have the correct 
card on hand.  I changed out the controller, booted the rescue CD, had it 
mount my drives, and I was able to rebuild the initrd fairly quickly with 
mkinitrd.  There was editing involved of a few files, but the key is to 
remember the --preload and --with options.
-- 
Lamar Owen
Chief Information Officer
Pisgah Astronomical Research Institute
1 PARI Drive
Rosman, NC  28772
(828)862-5554
www.pari.edu




More information about the users mailing list