Backups and the System Rescue CD

Use the bootable System Rescue CD two or four times per month to save your data and protect your sanity.

Unless you’re very disciplined, you probably backup your system on a best effort basis. You may regularly archive critical files, such as Quickbook files, MP3 collections, email, and private correspondence, but how often do you perform a full system backup — a complete copy of all hard disks, including your operating system, applications, and all data? Chances are not often or never, because, admittedly, only enterprise shops have the expensive proprietary software and dedicated, high-speed backup hardware to make light of such labor- and time-intensive work.

For most of us then, a catastrophic failure translates to a weekend (or a week) re-building a system with the right operating system, applications, personalized settings, patches and updates, and important data. (If you’re not copying critical data to CDs and DVDs, woe on you when the hard disk Mean Time Between Failure fairy finally decides to pay you a visit.)

There is a better way to enshrine your bytes, and it doesn’t require expensive hardware and proprietary/expensive system imaging software, such as Symantec’s GHOST. All you need is a small amount of self-discipline, a bunch of cheap hard drives, and a nifty, CD-bootable Linux that has all the open source software tools required to save your valuable weekend and your behind.

The Hardware

First, let’s embark on a shopping trip to buy a whole bunch of cheap, high-capacity IDE/ATA or Serial ATA (SATA) hard disks. Depending on how comfortable and dedicated you want to be with periodic backups, I’d go out and buy a matching pair or four identical 250 GB to 400 GB hard drives. At the bare minimum, purchase at least one drive that is larger than the hard disk currently installed in your PC.

Depending on the time of year and when new drive models and sizes are introduced by the various manufacturers, you can find some great deals on big hard disks. At the time of this writing, the street price (via Pricewatch.com) on a bare, 250 GB SATA hard disk was about $60. The next size up, 300 GB, was about $100, which is considerably more money for only a slightly bigger storage jump. The next level up from that was more than twice the price. This last Christmas season, various retailers were selling the USB Iomega 250 GB drive at $80 closeouts with a $20 rebate. I bought a number of them as holiday gifts to myself and for family friends who I know needed cheap backup.

Once you’ve got your hard disks, you must decide how to hook the devices to your PC. Obviously, if you’ve gotten a bunch of USB external disks cheap, there’s nothing else you need to do. If you’ve bought a bunch of barebone drives, you can either mount one or two inside your PC, and be careful to never format or touch the drives unless you need to back the system up. Or, you can keep these spares on the shelf (or in your fire safe) in anti-static bags until needed.

There is a third and much more preferred option, and that’s using a USB to SATA/IDE drive adapter kit to connect the barebone drives to your PCs when actually needed. Recently, I was sent a USB 2.0 Drive Adapter Kit by NewerTech (http://www.newertech.com/products/usb2_adapt.php, shown in Figure One), which retails on their web site for $24.95. The NewerTech USB 2.0 Universal Drive Adapter implements a bridge between one USB port and one ATA, Serial ATA, or ATAPI mass storage device port, and turns any ATA or SATA drive into a convenient external drive. The adapter is completely plug-and-play, is Linux, Windows and Mac compatible, and can accommodate any SATA 2.5-, 3.5-, and 5.25-inch IDE/ATAPI device, including notebook drives and internal CD-R and DVD devices.

The adapter comes with all the connector cables you could possibly need, as well as an external power supply for powering any type of SATA or ATAPI drive. There are slightly cheaper ones on the market, but I like the fact that the Newertech has been tested to work with Linux and that it comes with the power adapter for Molex connector and SATA. (If you work in a support role and you come away with any tip from this article, go pick up one of these to have in your bag of tricks at work.) I connected my adapter to a commodity Maxtor 200 GB SATA2 drive.

And I’m glad I did. During a recent stay in Alpharetta, Georgia, I had to do an unexpected restore due to a botched Red Hat Enterprise Linux 5.0 upgrade. The Newertech drive adapter allowed me to restore the operating system and partitions, including my Linux and Windows drives, back to their original configuration in a matter of minutes, due to its very fast native USB 2.0 480-megabit per second transfer rate.

The Software

With backup hardware in place, let’s talk about software. Everything that you are going to need is contained on the System Rescue CD, a bootable Linux distro based on Gentoo, designed with system backup and system recovery in mind. You can download the ISO from http://www.sysresccd.org, and burn it with your favorite CD burning program, such as K3B (http://www.k3b.org) or DeepBurner Free (http://www.deepburner.com) The latter runs on Windows XP and Vista, and is ideal for burning ISO files.

Here is a list of just some of the software included on the System Rescue CD: GParted, a Partition Magic clone for Linux; 0GNU Parted, a text tool for editing your disk partitions under Linux; Partimage, a Ghost/Drive-image clone for Linux; text-based filesystem tools (e2fsprogs, reiserfsprogs, reiser4progs, xfsprogs, jfsutils, ntfsprogs, dosfstools) to format, resize, and debug an existing partition of your hard disk; Ntfs3g, which allows you to mount your Windows partition and get a full read/write unlimited access to the NTFS partition; and many others.

A complete list of the software on the System Restore CD can be found at http://www.sysresccd.org/System-tools. You can also install Linux on a Windows system with no free space with the System Rescue CD.

Using the System Rescue CD

Now that you have the System Rescue CD and the backup drive (s), go ahead and boot your system with the System Rescue CD. (Be sure that your BIOS is configured so that the CD drive is the first bootable device.) The boot screen resembles Figure One. The image shown in Figure Two

FIGURE ONE: The boot screen of the System Rescue CD

By default, if you hit Enter, the System Rescue CD boots the Linux kernel and attempts to auto-detect all your hardware and attached storage devices. If by chance you have some esoteric hardware attached to your machine, such as a latest and greatest video card or some integrated video chip which may not be auto-detectable, you can send a whole host of boot time parameters to the kernel as it boots up. For example, boot: fb640 forcevesa forces the frame buffer to 640×480 and forces the X Window System configuration to a VESA-compatible mode (a basic fail-safe VGA mode that is common to virtually all modern graphics cards). A full list of boot image and kernel parameters can be found by pressing the F2, F3 and F4 keys just before kernel bootup.

Once the System Rescue CD boots Linux, type startx to fire up the X environment. Figure Two shows you the desktop.

FIGURE TWO: The X Window System environment of the System Rescue CD, which runs on the minimal WindowMaker window manager. Anyone remember the NeXT computer?

Shades of 1987

The System Rescue CD’s GUI is a lightweight environment that provides a basic GUI with all the tools you need for partition and file system recovery. It runs in a modicum of memory, and uses the minimal WindowMaker window manager. Unlike other GUIs like KDE, GNOME, or Microsoft Windows, WindowMaker makes extensive use of the mouse’s right button, which can be somewhat counter-intuitive. To launch a program from one of the icons stacked on the “dock” at the right, right-click on the icon and choose “Launch”. To pull up the main GUI menu, right-click on an empty area of the desktop and choose whatever option you want (such as launching a new xterm).

Your first step is format the backup drive so it can be used to store partition image files. If you’ve purchased USB hard disks, chances are they are already formatted as FAT32 drives (vfat) and you can skip this step (unless you want to regain some space, because FAT32 is extremely inefficient.) If you choose a format other than FAT32, be advised that any other kind of file system, such as ext3, won’t be readable in Windows. But since you are using them specifically for use with the System Rescue CD, that shouldn’t be an issue.

Go ahead and launch the gparted program, which is the third icon down from the top of the dock. You can also launch it by typing gparted in the default xterm window. gparted is also shown in Figure Two.

On the upper right of gparted’s main window is a drop down selector box that lists all the hard disk detected on your system. Click on it and select the external USB drive (or internal device) you intend to use as the backup drive. When you select a disk target, gparted’s lower pane displays any partitions that already exist. (Of course, do not format your data/OS drive or perform any change actions on it. I don’t think you’re that stupid, but I had to mention it because my editor told me to.[ Let's be careful out there. —Ed.])

Once you select a backup drive, right click on the free space and choose the New button. When the Create New Partition dialog box appears, take the default settings and click Add. By default, the system will mark it as an ext3 partition and prep it for formatting. Next, click on the Apply button (the big green check mark). gparted formats the drive for use. Exit the program when the formatting is complete, and mount your backup drive on the system.

By default, the System Restore CD has a /mnt directory where filesystems can be mounted, and a /mnt/custom directory that is left as a empty mountpoint for you to use. Issue the following command from a terminal window:

% mount –t ext3 /dev/sdc /mnt/custom

In this case, /dev/sdc is my 200 GB USB backup device. The command should execute successfully without any errors or messages.

Next, make a backup of the partition table of your operating system and data drive. Assuming the boot drive is /dev/sda, and your external backup drive is /dev/sdc, issue the following command:

% sfdisk –d /dev/sda > /mnt/custom/ptable-sda-backup

This creates a text file on /mnt/custom named ptable-sda-backup, which can be used at a later date to restore the partition table on /dev/sda in the event the hard drive has to be replaced, if all the partitions accidentally get blown away, or if a rogue micrometeoroid from outer space goes straight thru your drive casing. You should keep a copy of this file on the backup hard disk or any other backup hard disks that you might be using, or perhaps email a copy of it to your Gmail or other free webmail account for future retrieval.

To restore a partition table, you would issue the following:

% sfdisk /dev/sda < /mnt/custom/ptable-sda-backup

The latter command lacks the –d (dump) parameter, and the redirector is pointing in the opposite direction (<). Do not issue this command now; it’s just an example if you ever must restore your partition table.

Once you’ve backed up your partition table from your operating system and drive, you’re ready to create partition images on your backup drive. From an X terminal window, run partimage. The partimage main menu is shown in Figure Three.

FIGURE THREE: The main menu of the Partition Image utility

Partitions

Partition Image, or partimage, is a character-mode program to back up raw partitions to files that you can store on mounted file systems. Not only can you back up to locally mounted filesystems, but you can also backup and restore via IP multicast from a remote system running the Partimage server. For the purposes of this article, all steps are local, but you can read all about its advanced options at http://www.partimage.org.

Partimage fully supports the backup and restore of ext2/ext3, Reiser, FAT16, FAT332, HPFS, and JFS fileystem in stable mode. NTFS (Windows XP/2000/2003), Solaris UFS, and MacOS HFS are currently considered beta, but I’ve tested NTFS and I can certify that it works. For those of you with Windows boxes or have dual-boot systems, you can feel confident that System Rescue CD is a good solution for those systems as well.

On the main menu screen, as shown in Figure Three, select the partition to be backed up, the name of the image file that is to be created (or used for restoration) and then an action to be performed, which is either to save a partition, restore a partition, or restore a Master Boot Record (MBR) from an image file. You can also elect to connect to a remote Partition Image server.

To navigate thru the menu sections, hit the Tab key. You can also use the up and down arrows to make a selection, such as on the Partiton save/restore dropdown list. In the Image file to create text entry area, specify a fully-qualified pathname to your mounted backup drive and create a new file (or overwrite an existing file. To proceed to the next screen, press the F5 key.

FIGURE FOUR: The” Save Partiton to Image file” screen

On the partition file options screen, as shown in Figure Four, you can customize the compression level and file splitting options. The default settings are just fine, so hit F5 to continue. You’ll then be asked to enter a description for the partition you are backing up. After entering a description, hit Enter.

The system now creates partition backup files on your backup drive. By default, if your backup file is greater than 2048 MB, the software creates a new file with an iterated numerical filename, such as backup.000, backup.001, and so on. Empty space in the original partition is not saved, so the files are very efficient in size. If you’ve only got 3GB of data on a 70GB partition, you’ll only have about 3 GB or less of partition backup files.

If you ever need to do the restore, specify a fully-qualified pathname to the first partition backup file (for instance, backup.000). You can only restore a partition that is the exact same size of the partition that was backed up, so its critically important you have a backup of your partition table, and restore it with sfdisk as documented earlier, if the OS/data drive has been wiped. If it already has partitions of the correct size, you don’t need to (and shouldn’t!) restore the partition table first. You’ll want to repeat this step for all of your partitions.

Other Tips

I recommend that you create a directory on your backup drive for each partition you want to save. If you’ve purchased more than one backup drive, go ahead and format them with gparted, and rotate which drives you use as a backup on weekly or bi-weekly basis. This way, you’ll always have a second somewhat-recent copy in the event one of the backup drives fail.

This is where the discipline comes in: designate two (or four, depending on how disciplined you want to be) days per month where you boot up the System Rescue CD and go thru a partimage backup process of your primary operating system and data partitions.

Fatal error: Call to undefined function aa_author_bios() in /opt/apache/dms/b2b/linux-mag.com/site/www/htdocs/wp-content/themes/linuxmag/single.php on line 62