The following article describes 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 in CDP. The article is meant to be a proof of concept. The methods outlined can be used to create LiveCDs with other Linux distros.
Creating a LiveCD is not as daunting a task as many people think. The customized LiveCD is based on a standard CentOS 5.6 LiveCD.
To create the customized LiveCD, follow the instructions below.
1. Obtain the standard LiveCD and boot from it.
2. After booting, you have to provide some writable disk space (at least 10 gigabytes). In this document it is assumed that the writable space is a hard disk partition and this partition is mounted in /usr/src directory. If you do not have a hard disk, you can use USB flash drive or network share.
3. After you have configured writable space, install development tools (GNU C compiler, make, etc.) and kernel sources. The kernel sources should be exactly the same version as the kernel on LiveCD (for CentOS 5.6 it is version 2.6.18-238.el5) . So do not use yum for installing kernel sources and other tools, because yum will try to upgrade your kernel to a newer version. You should download all rpms directly from one of CentOS mirrors:
4. Next, you have to download Linux Integration Components for Windows Server 2008 Hyper-V R2 from Microsoft's website to a Windows 2008 R2 machine. At the time of writing this the URL was as follows:
5. Launch the executable file on Windows 2008 machine. This executable is a self-extracting archive. You will have to upload extracted LinuxIC v2.iso file to Linux. Rename it so that there are no spaces in the name - for example, to LinuxICv2.iso - and place in /usr/src directory. Mount this iso file using loopback device:
6. The iso file is mounted read-only. But to be able to compile drivers for Hyper-V virtual hardware, the directory with the drivers' source code should be writable. Copy the content of the iso file to the writable space using tar instead of cp, so all file permissions are preserved:
7. Enter /usr/src/ICv2work directory and run the "setup.pl drivers" command to build drivers:
8. Errors in creating initrd image are safe to ignore. Make sure that the drivers have been built successfully. If they have, the directory /lib/modules/2.6.18-238.el5/kernel/drivers/vmbus should exist and contain five files:
9. The next step is to embed the drivers into LiveCD image. It is a good idea to embed R1Soft repository configuration too, so after booting from this customized LiveCD you can always install the latest version of CDP Server or Agent using yum.
Copy the content of the CentOS LiveCD to the writable space. The content of LiveCD is in /mnt/live directory:
10. Inside the LiveCDwork you should see LiveOS directory, and inside LiveOS there is the squashfs image file - squashfs.img:
11. You should unpack this squashfs image using unsquashfs command (it will create squashfs-root directory):
12. Inside the squashfs-root directory there is another LiveOS directory, and inside this LiveOS directory there is the ext3fs.img file, that has to be modified. This file can be mounted read-write using the loopback device. Mount it and examine its content:
13. Now you should copy /lib/modules/2.6.18-238.el5/kernel/drivers/vmbus directory to /mnt/ext3/lib/modules/2.6.18-238.el5/kernel/drivers and then run depmod to rebuild module dependencies:
14. Next, create the R1Soft repository configuration for yum. Open the file /mnt/ext3/etc/yum.repos.d/r1soft.repo in the text editor and enter the following text:
15. Save the file, exit from the text editor, exit /mnt/ext3 directory, and unmount the ext3 image:
16. Delete the squashfs.img file and recreate it:
17. Change directory to /usr/src/LiveCDwork, remove squashfs-root directory, and create the ISO file using mkisofs command:
18. Transfer the ISO file you have just created (/usr/src/CentOS-5.6-i386-LiveCD-plus.iso) to your Hyper-V server and boot the VM you want to restore from this ISO. After logging in as root, load the netvsc module and check if seth0 intrface has appeared:
19. If you see the interface, you can assign IP address to it manually, or run dhclient to obtain IP address from DHCP server. When the network is configured, you can install CDP Agent or CDP Server Standard or Advanced Edition using yum. If you are using Agent, do not forget to turn off the firewall which blocks the Agent port and to restart Agent in recovery mode:
20. Now you can go to the Web Interface of CDP Server and start the Bare-Metal Restore process. See Launching Bare-Metal Restore.