How to clone a linux disk with dd
Back to the list of ebpg administration tips
- Do not do this if you have an older system with a RAID mirror drive, since the RAID drive is already a clone.
RAID is an overly complicated way of making a clone, and it does not protect you from disasters of the stupid sort. On the newer ebpg systems you can make a proper clone and save the original disk somewhere safely offline. - Purchase a blank solid-state disk of the exact same size as the system disk. If you have a two-disk system then you should buy two more of the same size. (There is no reason to use two disks for an ebpg, but sometimes Raith does that.)
- Change the boot order of the console computer. Every computer has a different way of choosing the boot order. Here is the one for our HP Z8
console computer:After power-on, press F10 to get to the setup menu. Advanced -> Boot options USB storage boot (make sure this is checked) Advanced -> Boot options -> UEFI Boot order put USB as the first choice save - Plug in a USB boot drive, such as the one from Raith, or make your own. (see below for making your own.) Unplug the backup drive and the archive drive, if you have those. (You should have a backup drive. Don't get lazy about that.)
- Boot from the USB drive. This is a Linux installation drive, but you DO NOT want to install Linux. Instead choose troubleshooting then rescue a Red Hat Enterprise Linux system or whatever it wants to "rescue" - it doesn't really matter. Then choose 3 to skip to a shell. Do not "install". Do not "continue".
-
List the devices with
parted -l
(That's a lower-case "L", for "list".) You should see at least two drives. Chances are that /dev/sda has a boot partition. That's the 'source'. And chances are that /dev/sdb is the blank disk. That's the 'destination'. The USB drive is probably /dev/sdc, and 'parted' may be confused about the partitions. You can choose "i" to ignore it.
What if you did not purchase a new disk? What happens if you want to overwrite a previous clone, or you fished the disk out of an old computer? Then "parted" will display the partitions on the old disk, and it can be confusing to pick the right 'source' and 'destination'. Picking the wrong one would be bad. Here's a great trick for avoiding this worry: Remove all the disks except for the 'destination' drive, then boot the Linux box with your USB stick. Choose "rescue a linux system" and "skip to a shell" as before. Now use "parted -l" to list the drives. There should be only two- the USB stick and the 'destination'. Let's suppose the destination drive was assigned to /dev/sda. Next, use "parted /dev/sda" to edit the partition table of the drive. In 'parted' use the commands "rm 1", "rm 2", etc to remove the partitions. Power down, plug in the "source" drive, and reboot with the USB stick. Now the 'source' drive has partitions and the 'destination' does not. No worries! - Use 'dd' to clone the drive:
dd if=/dev/sda of=/dev/sdb bs=10MB
"if=" specifies the original disk, and "of=" specifies the blank disk. The output of "parted" should have told you which one has the boot track, and which one is unformatted. dd will copy the disk bit-by-bit with no thought at all about partitioning or formatting. The destination will simply have the same structure as the source.
It will take about 4 hours to clone a 1 TB drive, and you will not see any status updates. It's really primitive. Congratulations: you have now used one of the oldest unix commands ever. It's older than you.
- Remove the system drive and replace it with the clone. Put the original drive somewhere safe. Boot with the clone. If it does not work, then this process has obviously failed.
Making your own boot USB stick
Buy a blank USB storage stick. 32 GB is large enough.
Download a Linux "ISO" file. It does not have to be Red Hat Enterprise Linux. Any distribution will have "dd", since it is an ancient, primitive command. Ubuntu has very nice step-by-step instructions for making a usb boot stick, at Ubuntu.com
Alternatively, you can create the boot stick with an ISO file and the Windows program "rufus", which can be found at rufus.ie
When you boot from this, remember that you want to use it in "troubleshooting" or "rescue" mode, by running a simple Linux shell.