Sunday, November 23, 2008

High Level Overview: Duplicating Linux Multi-Boot Systems

Assumptions:
-- 2 drives, /dev/sda and /dev/sdb, roughly 160GB each.
-- Each node has identical h/w, including drives.
-- Partitions:
sda1(/boot), sda2(swap), sda3(OS #1), sda4(extended, containing 5-9), sda5(OS #2), sda6(OS #3), sda7(OS #4), sda8(OS #5), sda9(OS #6), sdb1(OS #7), sdb2(OS #8), sdb3(OS #9), sdb4(extended, containing 5-9), sdb5(OS #10), sdb6(OS #11), sdb7(OS #12), sdb8(OS #13), sdb9(OS #14)
-- All partitions are compatible with the partimage utility. EXT3 is the choice here.
-- GRUB installed into MBR and pulling its OS boot options (grub.conf/menu.lst) from sda1

Backup:
-- Boot Knoppix 5.1.1
-- Mount desired NFS share
-- Use sfdisk to capture the partitioning information for sda and sdb
sfdisk -d /dev/sda > /NFS/dev-sda-sfdisk-info.txt
sfdisk -d /dev/sdb > /NFS/dev-sdb-sfdisk-info.txt
-- Change into the desired NFS sub-directory
-- Use partimage to image all of the partitions. Here is the idea for sda1.
/usr/sbin/partimage --batch -z1 -o -d save /dev/sda1 ./dev-sda1-image

Restore/Duplication:
-- Boot Knoppix 5.1.1
-- If Knoppix is using a pre-existing swap partition, disable with "swapoff -v "
-- Mount desired NFS share
-- Use sfdisk to write out the partitioning information for sda and sdb
sfdisk /dev/sda < /NFS/dev-sda-sfdisk-info.txt
sfdisk /dev/sdb < /NFS/dev-sdb-sfdisk-info.txt
-- Use sfdisk to verify the partitioning information for sda and sdb
sfdisk -l -V /dev/sda
sfdisk -l -V /dev/sdb
-- Change into the desired NFS sub-directory
-- Use partimage to write out all of the partitions. Here is the idea for sda1.
/usr/sbin/partimage --batch restore /dev/sda1 ./dev-sda1-image.000
-- Use the GRUB shell to write out the MBR and insist, for our example, that GRUB pulls its OS boot options (grub.conf/menu.lst) from sda1.
grub
root (hd0,0)
setup (hd0)
quit
-- Reboot and enjoy your multi-boot Linux system.

NOTE: See this LINK for more GRUB info. It's pretty darn good.