Showing posts with label LiveCD. Show all posts
Showing posts with label LiveCD. Show all posts

Monday, 2 August 2010

OS Remastering CentOS 5.5

Introduction

As part of Backup and Restore , We will be customizing an OS CD for our use. We will be using LiveCD for this purpose. We will be customizing it according to our requirement.

Objective

We will customize the LiveCD so that it will represent two customize menu when this system is booted using this CD. We will be inserting our own script which will execute automatically when system is booted without any login. It will execute the script and reboots the system

Software Requirement

1) CentOS 5.5 DVD
This can be downloaded from below link
http://mirror.as29550.net/mirror.centos.org/5.5/isos/i386/CentOS-5.5-i386-bin-DVD.iso
2) LiveCD
This can downloaded from below link
http://mirror.as29550.net/mirror.centos.org/5.5/isos/i386/CentOS-5.5-i386-LiveCD-Release2.iso

Procedure Overview

First we will install a regular CentOS 5.5 on a system. This can be done on a VM as well. We have used. In this installed machine we will modify our LiveCD. This is necessary to have base system same as that of LiveCD. This is due to the squashfs version incompatibility.

We have to use squashfs-tools in order to modify the LIveCD. But If the version of squashFS used to modify the LiveCD is different from the version inside the LiveCD, then resulting LiveCD will not work. Moreover Some OSes used their own patch to patch the utilities. So it is better to use the same Base OS and Same OS based LiveCD.

Install the Base System
We installed the CentOS 5.5 using CentOS 5.5 DVD in a VM. We used KVM for this purpose.
First create the Virtual Harddisk using following command.
qemu-img create -f qcow2 /VIRTUAL/QEmu/CentOS/CentOS-5.5-i386.img 10G
Run VM and start Install Process.
kvm -smp 4 -m 2048 -hda /VIRTUAL/QEmu/CentOS/CentOS-5.5-i386.img -cdrom /DATA/Install/ISO/CentOS/CentOS-5.5-i386-bin-DVD.iso -usb -usbdevice tablet -vnc :40 -net nic,macaddr=00:00:00:00:00:01 -net tap,script=
I installed the system with minimum utilities. Only Base and Administration Utilities.
Configure the Base system(Newly created VM).
Add a repository for LiveCD tools(inside newly created VM).
Create a file /etc/yum.repos.d/CentOS-LiveCD.repo with following contents.
# Name: CentOS LiveCD repository
[livecd]
name = CentOS $releasever - LiveCD
baseurl = http://www.nanotechnologies.qc.ca/propos/linux/centos-live/$basearch/live
enabled=1
protect=0
gpgkey = http://www.nanotechnologies.qc.ca/propos/linux/RPM-GPG-KEY-PGuay
Install LiveCD tools (inside newly created VM).
Run the following command to install the LiveCD tools.
yum install livecd-tools syslinux
This is our full blown running OS on a harddisk. We will be making the changes to LIveCD in this system. All the following commands henceforth will be carried out in this machine only.
CentOS-5.5-i386.img was a 10GB Image. It is necessary to have sufficient space in order to modify the LiveCD. Installation of Base OS on 10GB disk space is enough. All the following commands are now run on this Base OS i.e. CentOS 5.5 (On this VM machine)

Modify LiveCD
Copy the LiveCD ISO to /root directory(inside newly created VM).
# cd /root
#
# ls
anaconda-ks.cfg  centos5.5-livecd.iso  install.log  install.log.syslog
# mkdir -p live/{isofiles,isomount,osmount}
# mount -o loop centos5.5-livecd.iso live/isomount
# cp -R live/isomount/* live/isofiles
# unsquashfs -dest live/squashfiles live/isofiles/LiveOS/squashfs.img
created 1 files
created 2 directories
created 0 symlinks
created 0 devices
created 0 fifos
#
# mount -o loop,rw live/squashfiles/LiveOS/ext3fs.img live/osmount
# cd live/osmount/
# cd etc/rc3.d
#
# mv S08ip6tables K08ip6tables
# mv S08iptables K08iptables
# mv S11auditd K11auditd
# mv S12syslog K12syslog
# mv S23setroubleshoot K23setroubleshoot
# mv S25bluetooth K25bluetooth
# mv S26acpid K26acpid
# mv S26apmd K26apmd
# mv S56cups K56cups
# mv S80sendmail K80sendmail
# mv S85gpm K85gpm
# mv S90crond K90crond
# mv S90xfs K90xfs
# mv S95anacron K95anacron
# mv S95atd K95atd
# mv S97yum-updatesd K97yum-updatesd
# mv S98avahi-daemon K98avahi-daemon
# mv S99firstboot K99firstboot
# mv S99smartd K99smartd
# mv S26hidd K26hidd
# mv S25pcscd K25pcscd
# mv S08mcstrans K08mcstrans
Once changes have been done. Pack the contents back to the CD.
# cd /root
# umount /root/live/osmount
# rm live/isofiles/LiveOS/squashfs.img
# mksquashfs live/squashfiles/* live/isofiles/LiveOS/squashfs.img -keep-as-directory
Modify isolinux.cfg file. (I used following contents.)
# cd live/isofiles/isolinux/
# cat isolinux.cfg
default menu.c32
timeout 100
menu title Welcome to livecd-kick-201008021533!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color timeout_msg 0 #ffffffff #00000000
menu color timeout 0 #ffffffff #00000000
menu color cmdline 0 #ffffffff #00000000
menu hidden
menu hiddenrow 5
label linux0
  menu label Backup
  kernel vmlinuz0
  append initrd=initrd0.img root=CDLABEL=BackupRestore rootfstype=iso9660 ro quiet liveimg 3
label linux1
  menu label Restore
  kernel vmlinuz0
  append initrd=initrd0.img root=CDLABEL=BackupRestore rootfstype=iso9660 ro quiet liveimg 4
Make ISO
# cd /root/live/isofiles/
# mkisofs -o /root/BackupRestore.iso -b isolinux/isolinux.bin -c isolinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table -J -r -hide-rr-moved -V BackupRestore /root/live/isofiles
/root/BackupRestore.iso is the resulting customized LiveCD
Note: Please note -V option in above mkisofs command. The option to -V must be same as that of CDLABEL in isolinux.cfg file.