compared with
Current by Nata Ramanenka
on Mar 05, 2012 02:03.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (68)

View Page History

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.
{code}
{code}[root@livecd ~]# cat /etc/redhat-release
CentOS release 5.6 (Final){code}
{code}
To create the customized LiveCD, follow the instructions below.


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 {color:blue}yum{color} for installing kernel sources and other tools, because {color:blue}yum{color} will try to upgrade your kernel to a newer version. You should download all rpms directly from one of CentOS mirrors:
{code}
{code}[root@livecd ~]# rpm -i http://mirror.rackspace.com/CentOS/5.6/os/i386/CentOS/kernel-headers-2.6.18-238.el5.i386.rpm
[root@livecd ~]# rpm -i http://mirror.rackspace.com/CentOS/5.6/os/i386/CentOS/kernel-devel-2.6.18-238.el5.i686.rpm
[root@livecd ~]# rpm -i http://mirror.rackspace.com/CentOS/5.6/os/i386/CentOS/glibc-headers-2.5-58.i386.rpm
[root@livecd ~]# rpm -i http://mirror.rackspace.com/CentOS/5.6/os/i386/CentOS/libgomp-4.4.4-13.el5.i386.rpm
[root@livecd ~]# rpm -i http://mirror.rackspace.com/CentOS/5.6/os/i386/CentOS/gcc-4.1.2-50.el5.i386.rpm
[root@livecd ~]# rpm -i http://mirror.rackspace.com/CentOS/5.6/os/i386/CentOS/make-3.81-3.el5.i386.rpm{code}
{code}
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 {color:blue}LinuxIC v2.iso{color} file to Linux. Rename it so that there are no spaces in the name - for example, to {color:blue}LinuxICv2.iso{color} \- and place in {color:blue}/usr/src{color} directory. Mount this {color:blue}iso{color} file using loopback device:
{code}
{code}[root@livecd ~]# mkdir /mnt/ICv2
[root@livecd ~]# mount -o loop /usr/src/LinuxICv2.iso  /mnt/ICv2{code}
{code}
6. The {color:blue}iso{color} 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 {color:blue}iso{color} file to the writable space using {color:blue}tar{color} instead of {color:blue}cp{color}, so all file permissions are preserved:
{code}
{code}[root@livecd ~]# cd /mnt/ICv2
[root@livecd ICv2]# mkdir /usr/src/ICv2work
[root@livecd ICv2]# tar -c -f - * | tar -C /usr/src/ICv2work -x -f - -{code}
{code}
7. Enter {color:blue}/usr/src/ICv2work{color} directory and run the "{color:blue}setup.pl drivers{color}" command to build drivers:
{code}
{code}[root@livecd ICv2]# cd /usr/src/ICv2work/
[root@livecd ICv2work]# ./setup.pl drivers
Updating Linux integration components (vmbus, enlightened ide, enlightened scsi and network drivers) for Hyper-V...
Building storvsc driver...done.
Building netvsc driver...
........{code}
{code}
8. Errors in creating {color:blue}initrd{color} image are safe to ignore. Make sure that the drivers have been built successfully. If they have, the directory {color:blue}/lib/modules/2.6.18-238.el5/kernel/drivers/vmbus{color} should exist and contain five files:
{code}
{code}[root@livecd ICv2work]# ls -al /lib/modules/2.6.18-238.el5/kernel/drivers/vmbus
total 1216
-rwxr-xr-x 1 root root 297963 May 24 14:34 blkvsc.ko
-rwxr-xr-x 1 root root 320448 May 24 14:34 netvsc.ko
-rwxr-xr-x 1 root root 296318 May 24 14:34 storvsc.ko
-rwxr-xr-x 1 root root 279208 May 24 14:34 vmbus.ko{code}
{code}
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 {color:blue}yum{color}.

Copy the content of the CentOS LiveCD to the writable space. The content of LiveCD is in {color:blue}/mnt/live{color} directory:
{code}
{code}[root@livecd ~]# mkdir /usr/src/LiveCDwork
[root@livecd ~]# cd /mnt/live
[root@livecd live]# cp -R * /usr/src/LiveCDwork
[root@livecd live]# cd /usr/src/LiveCDwork{code}
{code}
10. Inside the {color:blue}LiveCDwork{color} you should see {color:blue}LiveOS{color} directory, and inside {color:blue}LiveOS{color} there is the {color:blue}squashfs{color} image file - {color:blue}squashfs.img{color}:
{code}
{code}[root@livecd LiveCDwork]# cd LiveOS
[root@livecd LiveOS]# ls -al squashfs.img
-r-xr-xr-x 1 root root 719618048 May 24 14:13 squashfs.img{code}
{code}
11. You should unpack this {color:blue}squashfs{color} image using {color:blue}unsquashfs{color} command (it will create {color:blue}squashfs-root{color} directory):
{code}
{code}[root@livecd LiveOS]# unsquashfs squashfs.img
created 1 files
created 2 directories
[root@livecd squashfs-root]# cd LiveOS
[root@livecd LiveOS]# ls
ext3fs.img{code}
{code}
12. Inside the {color:blue}squashfs-root{color} directory there is another {color:blue}LiveOS{color} directory, and inside this {color:blue}LiveOS{color} directory there is the {color:blue}ext3fs.img{color} file, that has to be modified. This file can be mounted read-write using the loopback device. Mount it and examine its content:
{code}
{code}[root@livecd LiveOS]# mkdir /mnt/ext3
[root@livecd LiveOS]# mount -o loop ext3fs.img /mnt/ext3
[root@livecd LiveOS]# ls /mnt/ext3
bin boot dev etc home lib lost+found media misc mnt opt proc root sbin selinux srv sys tmp usr var{code}
{code}
13. Now you should copy {color:blue}/lib/modules/2.6.18-238.el5/kernel/drivers/vmbus{color} directory to {color:blue}/mnt/ext3/lib/modules/2.6.18-238.el5/kernel/drivers{color} and then run {color:blue}depmod{color} to rebuild module dependencies:
{code}
{code}[root@livecd LiveOS]# cp -R /lib/modules/2.6.18-238.el5/kernel/drivers/vmbus /mnt/ext3/lib/modules/2.6.18-238.el5/kernel/drivers
[root@livecd LiveOS]# depmod -b /mnt/ext3{code}
{code}
14. Next, create the R1Soft repository configuration for {color:blue}yum{color}. Open the file {color:blue}/mnt/ext3/etc/yum.repos.d/r1soft.repo{color} in the text editor and enter the following text:
{code}
{code}[r1soft]
name=R1Soft Repository Server
baseurl=http://repo.r1soft.com/yum/stable/$basearch/
enabled=1
gpgcheck=0{code}
{code}
15. Save the file, exit from the text editor, exit {color:blue}/mnt/ext3{color} directory, and unmount the {color:blue}ext3{color} image:
{code}
{code}[root@livecd LiveOS]# cd
[root@livecd ~]# umount /mnt/ext3{code}
{code}
16. Delete the {color:blue}squashfs.img{color} file and recreate it:
{code}
{code}[root@livecd ~]# cd /usr/src/LiveCDwork/LiveOS
[root@livecd LiveOS]# rm -f squashfs.img
[root@livecd LiveOS]# mksquashfs squashfs-root squashfs.img
Number of uids 1
        root (0)
Number of gids 0 0{code}
{code}
17. Change directory to {color:blue}/usr/src/LiveCDwork{color}, remove {color:blue}squashfs-root{color} directory, and create the ISO file using {color:blue}mkisofs{color} command:
{code}
{code}[root@livecd ~]# cd /usr/src/LiveCDwork
[root@livecd LiveCDwork]# rm -rf LiveOS/squashfs-root
[root@livecd LiveCDwork]# mkisofs -o /usr/src/CentOS-5.6-i386-LiveCD-plus.iso -b isolinux/isolinux.bin
Path table size(bytes): 40
Max brk space used 1a000
355092 extents written (693 MB){code}
{code}
18. Transfer the ISO file you have just created ({color:blue}/usr/src/CentOS-5.6-i386-LiveCD-plus.iso{color}) to your Hyper-V server and boot the VM you want to restore from this ISO. After logging in as root, load the {color:blue}netvsc{color} module and check if {color:blue}seth0 intrface{color} has appeared:
{code}
{code}[root@livecd ~]#  modprobe netvsc
[root@livecd ~]#  ifconfig seth0{code}
{code}
19. If you see the interface, you can assign IP address to it manually, or run {color:blue}dhclient{color} 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 {color:blue}yum{color}. 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:
{code}
{code}[root@livecd ~]# /etc/init.d/iptables stop
[root@livecd ~]# touch /usr/sbin/r1soft/.recovery-mode
[root@livecd ~]# /etc/init.d/cdp-agent restart{code}
{code}
20. Now you can go to the Web Interface of CDP Server and start the Bare-Metal Restore process. See [CDP3:Launching Bare-Metal Restore].{excerpt:hidden=true}Instructions on how to create a customized CentOS LiveCD, with support for Microsoft Hyper-V
virtual machines, for the purpose of performing Bare-Metal Restores in