In this TechBuilder Recipe, I’ll show you how to set up a hard drive mirror clone--as opposed to a new drive mirror (or what’s known as a “bare metal restore”)--for Linux-based systems.
You don't have to be a Linux expert to get these procedures to work. I've tried to keep them simple and specific. Follow them exactly, and you should be able to save yourself days, even weeks, of work. Fixing it yourself can also spare you from the expense of hiring a specialized hard-drive recovery shop, some of which charge thousands of dollars for their services.
In an earlier TechBuilder Recipe, Backing Up Linux Workstations Without Tears, I detailed the process of creating a new drive mirror and set up a backup system drive mirror and DVD-R archives. But that procedure took nearly a week of experimenting to get exactly right. The procedures in this Recipe will enable you to skip that painful experimentation period and get right to drive cloning.
With a hard-drive mirror in place, recovery from a drive crash is as simple as unbolting a hard drive from a mobile rack and replacing the failed hard drive along with it. The whole process should take only 15 minutes. Remember, the completeness of a disk recovery always depends on how recent your last backup is.
For this Recipe, most of the processes will be executed within a terminal at the command line. What you see in monospace type will refer to either the processes or programs, or the files or prompts you will actually see (or enter) within a terminal in monospace font itself. Specific command-line instructions can be cut and pasted directly from the article into a terminal window. This reduces the odds of a system builder making a mess by incorrectly entering a command-line switch.
Ingredients
For the process of setting up any hard drive mirror, you'll need a mobile rack. I've been using Newegg’s SANMAX PMD-96I, and it’s worked very well. This particular mobile hard-drive rack uses a standard PCB pin-socket connector.
By contrast, most lower-cost mobile racks use the Centronics parallel connector. I have recommended the Centronics connector in the past, mainly because it’s inexpensive. Unfortunately, the Centronics parallel connector is intended for relatively low-speed data transfer (megabyte/second range), such as those seen from a computer to a parallel printer. While that’s fine for a parallel printer, it's definitely not fine for the data-transfer requirements of modern, high-speed IDE drives. This problem is exacerbated if there’s any significant wear generated on the Centronics connector. On the Newegg rack, the DIN PCB pin-socket connector accurately transfers data at full IDE bus speed, drastically reducing error rates.
Also, if you have the usual flat-ribbon IDE cables installed, consider replacing them with round cables with shielding. The price is of round cables is now comparable to that for flat ones, and the round cables do a better job of handling high-speed drive data transfers. They’re also easier to work with inside the computer case.
You'll also need either a working drive to copy or a full archival image backup set on DVD-R.
My earlier Linux backup Recipe included three scripts: a dd drive-cloning script; rsync backup script (intended to provide a simple differential backup taking a few minutes to run); and dar script, which creates “compressed-like” files suitable for archiving to a DVD-R backup set. Unfortunately, while the dd script worked well at first, it has since started giving me increasing problems. Finally, it became unusable. As there is no replacement dd script in my earlier Recipe, instead, use the rsync_backup.sh script below for direct drive-to-drive copies.
Setting Up a Drive Mirror in 12 Steps
To set up a mirror which should clone any drive in workable condition:
rsync_backup.shscript in the last section of the article to /usr/local/bin. Again, see my earlier TechBuilder Recipe, Backing Up Linux Workstations Without Tears, for details.
sh rsync_backup.shscript accordingly. The instructions are within the internal script comments.) If you’ve unplugged other drives in the system, plug them back in now as well.
sh rsync_backup.sh.
/mnt/temp /mnt/temp1
While these aren’t actually necessary from the standpoint of cloning a drive with an unmodified boot sector, the script won’t run correctly without them. Instead, it will crash when it tries to use the directories.
If you have not changed the boot setup, skip ahead to Step 9 and unplug the main HD.
Below, you’ll find the modified rsync and dar scripts for you to cut and paste, which will automatically mount and back up the boot partition. Be aware that the very first boot-up on a new drive will be slower than you’re probably used to, and it might even hang for a minute or two. This does not indicate a problem unless the boot sequence completely shuts down instead of resuming.
Also, if you do have a boot sector modified from the default, run the modified rsync backup script specified in the first item in the list as instructed below as soon as possible. That way, the boot sector information will exist in the backup for you to copy.