11.5. Alt-Boot Partition Image MethodThis example uses dd to back up and recover a complete system at the partition level. It requires the system to be offline (booted into Knoppix), and it works regardless of your operating system. It's slightly more complex than the alt-boot full image method and still requires the system to be down during a backup, but it can be faster if your disk is partitioned correctly. You can save a lot of space and time if you partition your hard disk so that one partition contains the operating system and applications, and then apply this procedure only to that partition. (You would back up the other partitions with regular filesystem backup tools.) 11.5.1. Create the Bare-Metal BackupUse the following steps to create a bare-metal backup of your system. 11.5.1.1. Back up the important metadataBack up the MBR by running the following command: # dd if=/dev/hda of=/backups/mbr bs=512 count =1 11.5.1.2. Boot the system from alternate mediaPlace the Knoppix CD into the drive and reboot into Knoppix. By default, Knoppix starts KDE (a windowing environment) as user knoppix. After switching to the root user (which has no password initially), create a mount point and mount an NFS directory as /backups: knoppix@0[knoppix]$ su - # mkdir /backups # mount nfsserver:/data08/curtis /backups
11.5.1.3. Back up the operating system with a native utilityYou then back up the operating system to the NFS directory using dd. You can find which partitions you need and back up just those partitions using these commands: # fdisk -l Disk /dev/hda: 41.1 GB, 41174138880 bytes 255 heads, 63 sectors/track, 5005 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 13 104391 83 Linux /dev/hda2 14 4874 39045982+ 83 Linux /dev/hda3 4875 5005 1052257+ 82 Linux swap / Solaris # dd if=/dev/hda1 of=/backups/hda1.dd # dd if=/dev/hda2 of=/backups/hda2.dd
Alternatively, you can also use compression. Depending on where your bottlenecks are, this may speed things up or slow them down. # dd if=/dev/hda1| gzip c > of=/backups/hda1.dd.gz # dd if=/dev/hda2| gzip c > of=/backups/hda2.dd.gz You can place an & (ampersand) at the end to allow the backups to occur simultaneously by placing them in the background. However, this requires you to monitor those processes to ensure that they complete before you reboot. 11.5.2. Perform a Bare-Metal RecoveryUse the following steps to recover your system from bare metal. 11.5.2.1. Boot the system from alternate mediaThe first step in recovering this system is to place the Knoppix CD into the CD drive and boot up the system. A check of the partition table at this point shows the following: # fdisk -l Disk /dev/hda: 41.1 GB, 41174138880 bytes 16 heads, 63 sectors/track, 79780 cylinders Units = cylinders of 1008 * 512 = 516096 bytes Disk /dev/hda doesn't contain a valid partition table As before, open a terminal window and switch to the root user, then mount your NFS directory: knoppix@0[knoppix]$ su - # mkdir /backups # mount nfsserver:/data08/curtis /backups
11.5.2.2. Restore the boot block and prepare the new root driveFor restoring by partition, you need to restore the MBR and partition table and then restore each partition. You can restore the MBR and partition table by running the following command: # 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 was 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.5.2.3. Restore the operating systemYou are now ready to actually restore the operating system. Use dd in the reverse order that you used to back up the operating system: # dd if=/backups/hda1.dd of=/dev/hda1 # dd if=/backups/hda2.dd of=/dev/hda2 If you used the compression option in the backup, you should use these commands: # gzip dc /backups/hda1.dd.gz |dd of=/dev/hda1 # gzip dc /backups/hda2.dd.gz |dd of=/dev/hda2 Again, we knew that there was nothing of value in /dev/hda3. You can place an & at the end to allow the restores to occur simultaneously by placing them in the background. However, this requires you to monitor those processes to ensure that they complete before you reboot. All you have to do now is remove the Knoppix CD and reboot. |