The following article discusses the steps needed to create a customized CentOS LiveCD, with support for Microsoft Hyper-V Virtual Machines, for the purpose of performing Bare Metal Restores via the R1Soft CDP Server. It is meant to be a Proof-of-Concept. The methods outlined can likely be used to create Live ISOs using a variety of distros.
Creating a LiveCD isn't as daunting a task as many people think. My working environment was a standard CentOS 5.2 installation.
If you don't already have "squashfs-tools" install, use yum to install it.
Start off by downloading the latest CentOS LiveCD from your favorite mirror: CentOS-5.3-i386-LiveCD.iso
Once downloaded, create a mount point, mount the ISO, and look at the contents (these are the component you will be working with):
Inside the 'LiveOS' directory is the squashfs image:
We cannot work within this directory tree since the ISO mount point is read-only. Create a new working directory and copy the contents of /mnt/centlive to it:
Before proceeding any further, you will need to download Linux Integration Components for Windows Server 2008 Hyper-V from Microsoft's website TO A WINDOWS MACHINE:
Run the executable and it will extract another ISO image containing the necessary drivers. You can either extract the ISO to a folder in Windows or mount the ISO in Linux. Either way, the contents of the ISO need to get into our working environment:
Return back to the /mnt/hyper-v/LiveOS and unsquash the image file (it will create a "squashfs-root" directory):
Inside the LiveOS directory is the ext3fs.img that we will need to modify. Begin by mounting it and checking it's contents:
Building Micorsoft's drivers is no different than building other kernel modules for Linux. You need to have GCC, kenrel-headers, make, etc... installed on the machine to do so. By default, the CentOS LiveCD doesn't have these and you will not be able to use Yum to install them once the CD is booted up since there will be no NIC detected. For the sake of simplicity, I created 1 directory (called rpms) within the 'ext3' image and place all neccessary compenents in it:
We have a full linux directory tree structure in /tmp/ext3. You can chroot into it and install the RPMs now, or do it once you boot into the CD:
Install the RPMs in this directory (you can delete them one done). Once done, we need to repackage the ISO. Begin by exiting the 'chroot' and unmount the ext3 image:
And re-squash the image:
Next, replace the existing squashfs.img file in our working directory (/mnt/hyper-v/LiveOS) with the one we just created. Last we will make a little edit to the isolinux.cfg file. I changed:
append initrd=initrd0.img root=CDLABEL=CentOS-5.3-i386-LiveCD rootfstype=iso9660 ro quiet liveimg 3
To -> append initrd=initrd0.img root=CDLABEL=Hyper-V-BMR-i386 rootfstype=iso9660 ro quiet liveimg 3
*** The root=CDLABEL value MUST be used in the mkisofs command or the new LiveCD will not boot properly!!
Transfer your newly created ISO to your Hyper-V machine and boot the VM you wish to BMR with the ISO.
Once at a command prompt, build the drivers (the drivers will build, but the script will throw an error because it is a LiveCD):
Load the newly built drivers manually.
Verify the the appropriarte drivers are loaded (looking for 'netvsc'):
Restart networking on the machine (/etc/init.d/network restart) and your NIC should now be detected:
Install the R1Soft agent in 'recovery mode' : http://wiki.r1soft.com/display/kb/Starting+Buagent+for+BMR and you can start BMR'ing