Cloning a Linux server - from IDE to SCSI

Jephe Wu

If your source and destination are the same kind of hard disk, you can refer to the previous articles at cloning a linux server - scenery 2.

In case you need to clone Linux server from ide hard disk to scsi hard disk, after you did the steps that mentioned in the above link, you have to modify initrd.img to include scsi driver.

1. modify initrd.img
I assume you are using 2.6 kernel, the initrd.img format are different if you are using kernel 2.4. Kernel 2.6 for initrd.img is cpio archive after unzip while kernel 2.4 for initrd.img is loopback file system after unzip.

The following are the steps to add scsi driver to initrd.img

1. preparation
cp /boot/initrd.img /tmp/a
cd /tmp
zcat a > a1
mkdir a1.dir
cd a1.dir
cpio -iv < ../a1

or one command like this:
cd /tmp; mkdir initrd; cd initrd
gzip -dc /boot/initrd.img | cpio -id

2. modification
vi init ( add scsi driver modules in init as well as put them in lib/ folder)
after modification, it should be like this:

[root@linuxtechres jephe]# more init
mount -t proc /proc /proc
echo Mounted /proc filesystem
echo Mounting sysfs
mount -t sysfs none /sys
echo Creating /dev
mount -o mode=0755 -t tmpfs none /dev
mknod /dev/console c 5 1
mknod /dev/null c 1 3
mknod /dev/zero c 1 5
mknod /dev/sda3 b 8 3 ---> added(assuming /dev/sda3 is your root partition)
mkdir /dev/pts
mkdir /dev/shm
echo Starting udev
echo -n "/sbin/hotplug" > /proc/sys/kernel/hotplug
echo "Loading jbd.ko module"
insmod /lib/jbd.ko
echo "Loading ext3.ko module"
insmod /lib/ext3.ko

insmod /lib/scsi_mod.ko
insmod /lib/sd_mod.ko
insmod /lib/sr_mod.ko
insmmod /lib/scsi_transport_spi.ko
insmod /lib/sym53c8xx.ko
# note: added above lines for sym53c8xx scsi drivers, please remember to put all necessary files from /lib/modules/KERNEL_VERSION/kernel/drivers/scsi to the above lib folder.

echo Creating root device
mkrootdev /dev/root
umount /sys
echo Mounting root filesystem
mount -o defaults --ro -t ext3 /dev/root /sysroot
mount -t tmpfs --bind /dev /sysroot/dev
echo Switching to new root
switchroot /sysroot
umount /initrd/dev

3. make changes finally
find . | cpio -co > ../c
cd ..
gzip c
cp c.gz /boot/initrd.img


find ./ | cpio -H newc -o > initrd.cpio
gzip initrd.cpio
mv initrd.cpio.gz initrd.img

1. make cpio -co not 'cpio -o', 'c' is very important parameter
2. make backup for /boot/initrd.img first.

4. modify /etc/modprobe.conf
add the following for scsi driver
alias scsi_hostadapter sym53c8xx

Note: If you are making changes for initrd.img for kernel 2.4, the following are the steps:
cd /boot
cp initrd.img /tmp/a.img -va
cd /tmp
zcat a.img > a
mkdir a.dir
mount -o loop a a.dir
cd a.dir
modify something for file init
cd ..
umount a.dir
cat a | gzip >

5. References