Wednesday, 8 September 2010

Creating Debian USB Installer

Prerequisites:

An already insalled and working linux distribution. My laptop already had Fedora Core 10.

Target OS

Debian Lenny 5.0.1 was used for this purpose. It can be downloaded fromhttp://cdimage.debian.org/debian-cd/5.0.1/i386/bt-dvd/

We also need a different installer kernel and initrd image as we will be installing from USB. In this case hd-image installers will be used. vmlinuz and initrd for hd-image installes can be downloaded from http://http.us.debian.org/debian/dists/lenny/main/installer-i386/current/images/hd-media/. It is very important to have correct installer image for a distribution.

Preparing USB disk:

We will create an ext2 partition with fdisk command. USB disk device name can be found from dmesg command output. Create a single partition on USB disk and make it bootable. All these activities are performed using fdisk commands. So if USB disk is called as /dev/sdb , it will have one partition as /dev/sdb1

Copy the required grub files to USB stick:
mount /dev/sdb1 /mnt
mkdir -p /mnt/boot/grub
cp /boot/grub/* /mnt/boot/grub
Copy the downloaded hd-media installer image and iso files to USB stick:
cp /home/test/Download/{vmlinuz,initrd.gz} /mnt
cp /home/test/debian-501-i386-DVD-1.iso /mnt
Configure and Install Grub:
Edit /mnt/boot/grub/menu.lst to have following contents only.
title USB Installer
root (hd0,0)
kernel /vmlinuz rootdelay=10
initrd /initrd.gz

It is important to have rootdelay option other wise installer will not kick off. This is required because USB flash drives take a bit longer to be prepared.

Now Install the grub bootloader to USB disk.
# grub
grub> device (hd0) /dev/sdb
grub> root (hd0,0)
grub> setup (hd0)
Thats it. Boot the system from USB disk.

Monday, 30 August 2010

Creating Fedora11 USB Installer With Grub

Introduction:

As the new OSes are coming in the market, to test and install these OSes requires DVDs to be created. An efficient method was required, so that DVD burning can be stopped. Since my Laptop can be booted from USB device , so It makes much sense to use USB devices (i.e. USB stick or USB drive) to do the installation. For this purpose and 8GB USB disk was used.

Prerequisites:

An already insalled and working linux distribution. My laptop already had Fedora Core 10.

Target OS.

Fedora-11 was used for this purpose. It can be downloaded from http://download.fedoraproject.org/pub/fedora/linux/releases/11/Fedora/i386/iso/Fedora-11-i386-DVD.iso

In case of Debian we had used different installer kernel and initrd image which had to be downloaded. But in case of Fedora-11 we will use the same Installer and initrd image which is available in its ISO file. For more information on Debian USB installer kernel see Preparing USB disk:

We wil create an ext2 partition with fdisk command. USB disk device name can be found from dmesg command output. Create a single partition on USB disk and make it bootable. All these activities are performed using fdisk commands. So if USB disk is called as /dev/sdb , it will have one partition as /dev/sdb1

Copy the required grub files to USB stick:
mount /dev/sdb1 /mnt
mkdir -p /mnt/boot/grub
cp /boot/grub/* /mnt/boot/grub
Copy the installer image and iso files to USB stick:
mount -o loop Fedora-11-i386-DVD.iso /tmp/image
cp /tmp/image/isolinux/vmlinuz /mnt/vmlinuz-fedora-11
cp /tmp/image/isolinux/initrd.img /mnt/initrd.img-fedora-11
cp -pr /tmp/image/images /mnt
cp Fedora-11-i386-DVD.iso /mnt

Note: vmlinuz and initrd.img files are available at two locations in ISO image. First location is isolinux/ and second is images/pxeboot/ . But kernel and initrd.img are exactly same. So it doesn't matter what files are copied. Also there is additional step of copy in Fedora-11 than in Debian.

Configure and Install Grub:
Edit /mnt/boot/grub/menu.lst to have following contents (or grub.conf).
title USB Fedora-11 Installer
root (hd0,0)
kernel /vmlinuz-fedora-11 rootdelay=10
initrd /initrd.img-fedora-11
It is important to have rootdelay option other wise installer will not kick off. This is required because USB flash drives take a bit longer to be prepared.
Now Install the grub bootloader to USB disk.
# grub
grub> device (hd0) /dev/sdb
grub> root (hd0,0)
grub> setup (hd0)
Thats it. Boot the system from USB disk.

Friday, 6 August 2010

OS Remastering CentOS 5.5 using Kickstart

Introduction

This document will describe How to Create a Linux LiveCD using kickstart method. This is the very fast and convenient method of producing LiveCDs. This method can be used only on RedHat based distribution only e.g. Fedora, CentOS. The Method of producing LiveCDs based on Debian distribution is different and is not described here. A manual procedure of modifying a LiveCD is described in the following link.
OS Remastering CentOS 5.5 using Manual Method

Objective

We will be creating a highly customized CentOS 5.5 Based LiveCD which will have some external third party rpm packages as well.

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) Third Party RPM package which is to be installed in Live CD. In this case we are using NTFSProgs package which is not available in CentOS repositories.
http://packages.sw.be/ntfsprogs/ntfsprogs-1.13.1-1.el5.rf.i386.rpm

Procedure Overview

First we will install a regular CentOS 5.5 on a system. This can be done on a VM as well. In this installed machine we will build our 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. and then run VM and finish OS installation
qemu-img create -f qcow2 /VIRTUAL/QEmu/CentOS/CentOS-5.5-i386.img 10G

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.
Add a repository for LiveCD tools.
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.
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 creating the LiveCD in this system. All the following commands henceforth will be carried out in this machine only. Mount cdrom
Run the following command to mount the cdrom.
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
Prepare the directory containing third party tools.
mkdir /root/livecdkickstart_files
Place the files in this above directory which you want to include in your customized LiveCD. In this case we had included following files.
BackupRestore.sh 
command.txt 
isolinux.cfg 
kick.ks 
ntfsprogs-1.13.1-1.el5.rf.i386.rpm 
pcbackup_keys 
README 
root_ssh_config 
ssh 
WindowsPCBackup.sh
In the above listed files kick.ks is the kickstart file which will contain all the instructions for the customization of LIveCD. kick.ks is given at the end of this article.

Following are the contents of isolinux.cfg file
default menu.c32
timeout 100
menu title Welcome to BackupRestore CD ver 1.0 !
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 This System
kernel vmlinuz0
append initrd=initrd0.img root=CDLABEL=LiveBackupRestoreCD rootfstype=iso9660 ro liveimg mode=Backup vga=0x314
label linux1
menu label Restore This System
kernel vmlinuz0
append initrd=initrd0.img root=CDLABEL=LiveBackupRestoreCD rootfstype=iso9660 ro liveimg mode=Restore vga=0x314
Create the LiveCD
Once you have required files and kickstart file run the following command to create the LiveCD.
cd /root/livecdkickstart_files
livecd-creator --config=kick.ks --fslabel=LiveBackupRestoreCD
kick.ks file
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use hard drive installation media
#harddrive --dir=/tmp/fedora --partition=sda8
repo --name=cdrom --baseurl=file:///tmp/fedora
# To compose against the current release tree, use the following "repo" (enabled by default)
repo --name=released --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-13&arch=$basearch
# To include updates, use the following "repo" (enabled by default)
repo --name=updates --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f13&arch=$basearch

# Root password
rootpw --iscrypted $1$x9PSyNru$RR5iKsKjlRpaMBgGrg3a81
# System authorization information
auth  --useshadow  --passalgo=md5
# Use text mode install
text
# System keyboard
keyboard uk
# System language
lang en_GB
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Installation logging level
#logging --level=info
# Reboot after installation
reboot
# System timezone
timezone  Europe/London
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all  

%post
%end

%packages --nobase
@admin-tools
openssh-server
-PackageKit-yum-plugin
-coolkey
-fedora-release-notes
-finger
-fprintd-pam
-ftp
-gnupg2
-hunspell
-iptstate
-irda-utils
-jwhois
-krb5-workstation
-lftp
-mlocate
-mtr
-nc
-nss_db
-nss_ldap
-pam_krb5
-pam_pkcs11
-pam_smb
-perf
-rdate
-rdist
-rsh
-sos
-sssd
-talk
-tcp_wrappers
-telnet
-time
-tree
-vconfig
-words
-ypbind

%end

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.