11.2. The Steps in TheoryLater in this chapter, you'll find specific procedures for each of the four methods we've described. This next section takes a closer look at the six general steps involved in our bare-metal backup and recovery process. 11.2.1. Step 1: Back Up Important MetadataThe first data that you need to save is the metadata. Metadata is the data about that data, that is, the information about how the system is physically configured. In this case, it's how the operating system disk is partitioned. This information is not typically included in a normal backup. Making a copy of the MBR and partition table is a way to maintain this information in a format that can be used to recreate the root disk partition. The MBR and partition table are contained in the first 512 bytes of your hard drive. An MBR has three parts: the boot block is stored in the first 446 bytes, the paritition table is stored in the next 64 bytes, and the boot code signature takes up the remaining 2 bytes. 11.2.1.1. Linux, FreeBSD, and Solaris x86If you're running Linux, FreeBSD, Solaris x86, or any other Unix-like operating system, you can easily back up your important metadata live.
To save the disk partition information, run these commands: # fdisk -l >/backups/fdisk.txt # cp /etc/fstab /backups/fstab.txt To back up the MBR and partition table, run the following command. It creates a backup to a file called /backups/mbr. # dd if=/dev/hda of=/backups/mbr bs=512 count=1 This can be used later to restore the MBR and the partition table. 11.2.1.2. WindowsUnfortunately, there are no Windows equivalents to the commands just shown. You have two choices. If you use the alt-boot full image method, you can skip this step. If you want to use the alt-boot partition image method, save this information before backing up your partitions. After booting into Knoppix, you are automatically logged in as user knoppix. This example assumes you are booting into a DHCP environment and have an NFS server called nfsserver with a share called /data08/curtis. Obviously, you need to substitute the appropriate values for your environment. In addition, if you're using a USB drive for this procedure, you need to mount it instead of the NFS drive. Run these commands to proceed: $ su - # mkdir /backups
Now run one of the following two commands depending on whether you are running NFS or SAMBA: # mount nfsserver:/data08/curtis /backups # mount -t smbfs -o username=administrator,password=PASSWORD //servername/share /backups Finally, save the partition information: # fdisk -l >/backups/fdisk.txt # dd if=/dev/hda of=/backups/mbr bs=512 count=1
11.2.2. Step 2: Back Up the OS with a Native UtilityIf you are going to restore the operating system without reinstalling it, you need to use a utility that is always available. 11.2.2.1. Linux, FreeBSD, Solaris X86If you're using the live method, you'll want to use tar or cpio. tar is easily the most popular choice here because it's more portable than cpio. If you're going to use the alt-boot filesystem method, you need to understand the filesystem types, mount the filesystems, then use tar or cpio to back them up. If you're going to use the alt-boot full image or alt-boot partition image methods, you need to use dd. 11.2.2.2. WindowsIf you're going to back up a Windows system using the alt-boot full image or alt-boot partition image methods, you'll need to use dd. We'll cover the syntax that you'll need to know. If you're going to use the alt-boot filesystem method, you'll need to use the ntfsclone utility that's available on the Knoppix CD. ntfsclone efficiently clones (or copies) an NTFS filesystem to a file, copying only the used data. (Unused blocks are represented by zeros in a sparse file, so they don't take up space.) You can't back up a Windows system using the live method. While you can easily download a Windows version of tar, and tar is available on the Knoppix CD, tar does not preserve Windows ACLs. 11.2.3. Step 3: Boot the System from Alternate MediaIn order to easily recover your operating system, you need a limited root shell, which you get when you boot into Knoppix. Once you boot into Knoppix, you can perform the rest of this procedure from a fully functional root shell. 11.2.4. Step 4: Restore the Boot Block InformationThe boot block is a special part of the disk that loads the operating system by its "bootstraps," hence the name. It contains just enough executable code to locate and load the kernel. On the Intel platform, this boot block is referred to as the master boot record, and you can restore it with dd, using the backup we created in the previous step.
If you previously backed up the MBR and partition table using dd, as explained earlier, you can now use dd to restore the MBR and partition table by running the following command. Since the file /backups/mbr contains the MBR, partition table, and MBR signature, restoring this file to the hard drive partitions it just like the one you backed up and makes it bootable. Once this is done, you're ready to restore the operating system. # dd if=/backups/mbr of=/dev/hda bs=512 count=1 In order to get Knoppix to recognize without a reboot that we had recovered the MBR, we found it necessary to actually run fdisk /dev/hda and then choose w to write the partition to disk. A reboot works as well but takes longer.
11.2.5. Step 5: Partition and Format the New Root DriveThe steps in the previous section restore both the MBR and the partition table, so there's no need to repartition the drive. All the partitions will already be created for you.
11.2.5.1. Linux, FreeBSD, and Solaris X86If you're using either the live or alt-boot filesystem methods, you now need to create filesystems on the drive using the mkfs command. You need the backed up fstab file to know which filesystem types each partition is supposed to have. If you're using the alt-boot full image or alt-boot partition image methods, you don't need to worry about formatting the drive; it happens automatically when you restore from the image. 11.2.5.2. WindowsIf you're using the alt-boot full image or alt-boot partition image methods, you don't need to worry about formatting the drive; it happens automatically when you restore from the image. If you're using the alt-boot filesystem method, the drive is automatically formatted when you restore using ntfsclone. 11.2.6. Step 6: Restore the OS to the New Root DriveFirst, you must have access to the backed-up data. Our examples use an NFS directory. You may have to do one of the following:
Our example backups were sent to an NFS filesystem. The drivers and tools that were needed to do this are all available on Knoppix. |