Cloning a physical RHEL 5 server to vmware virtual server

Jephe Wu -

Objective: Cloning a physical RHEL 5 server to vmware virtual server from scratch
Environment: RHEL 5.1 (physical server HP Proliant DL360), CentOS 5.5 (vmware host server)


1. Setup the vmware server 2.0 under CentOS 5.5
Please refer to another article at

2. Clone physical RHEL 5.1 to vmware virtual server

a. create a vmware virtual environment, use sda as hard disk and boot it up from system rescue CD iso image
You can download iso file from

b. make a tar ball from the original RHEL 5.1 physical server
login as root
cd /
tar --exclude root --exclude sys --exclude proc -cvpzf - . | ssh intermediate_server 'cat > rhel.tar.gz'

c. configure IP address, make partitions and change root password
ifconfig eth0 netmask up
passwd root
fdisk /dev/sda (make sda1 as /boot(100M), sda2 as swap(2xRAM size), sda3 as /)
mkfs -t ext3 /dev/sda1
mkfs -t ext3 /dev/sda3
mkswap /dev/sda2

d. start to clone the whole OS

cd /mnt
mkdir sda
mount /dev/sda3 sda
cd sda
mount /dev/sda1 boot

scp  root@original_server:/etc/passwd /etc/

scp root@original_server:/etc/group /etc/

note: above scp commands to copy original server /etc/passwd and /etc/group file to the rescue CD environment so that untaring the rhel.tar.gz will keep the correct owner and permission for all files systems later on. Otherwise, you will notice /var/spool/clientmqueue directory will not be owned by smmsp, as well as the group permission for /usr/sbin/sendmail.sendmail, and so on.

logout then login again

 cd /mnt/sda
ssh root@intermediate_server 'cat rhel.tar.gz' | tar xvpzf - 

if on the same LAN,use
tar --exclude root --exclude sys --exclude proc -cvpf - . | ssh intermedia_server 'cd /mnt/sda; tar xpf -'

 Note: if you use RIP 12.3 non-X version, vi /etc/hosts.deny to comment out the last line which only permit localhost to ssh into RIP server, also you might need to vi /etc/ssh/sshd_config to enable root login by using password.

e. modify configurations after cloning OS

cd /mnt/sda
chroot .
modify /etc/sysconfig/network-scritps/ifcfg-eth0 and ifcfg-eth1 if necessary
modify /etc/sysconfig/network
modify /etc/fstab
modify /etc/grub.conf
cp /etc/blkid /etc/blkid.bak
rm -f /etc/blkid/*
cp /etc/mtab /etc/mtab.bak
vi /etc/mtab (to correct the / and /boot line to have the correct partition name)
vi /boot/grub/ to something like '(hd0)  /dev/sda'
cd /dev

After that, create root, sys and proc directory for cloned virtual server.
cd /mnt/sda
mkdir proc sys root

f. generating new initrd image and install grub

modify /etc/modprobe.conf to have the correct scsi driver, for vmware using sda hard disk, change that file to the follows:

root@jephe # more /etc/modprobe.conf
alias eth0 pcnet32
#alias scsi_hostadapter mptspi
#alias scsi_hostadapter1 mptfc
#alias scsi_hostadapter2 mptsas
alias scsi_hostadapter3 mptbase
alias scsi_hostadapter4 mptscsih
alias scsi_hostadapter5 ata_piix
alias scsi_hostadapter6 usb-storage

then generate new initrd image based on the above scsi drivers (no need to use --preload options to load scsi modules)
root@jephe # mkinitrd -f /boot/initvm.img kernelnumber
error opening /sys/block: No such file or directory
error opening /sys/block: No such file or directory
Note: ignore above errors.

note: you can use commands below to check new initrd content:
mkdir /tmp/initrd
cd /tmp/initrd;gzip -dc /boot/initrd- | cpio -id

Lastly, install grub: (install it again everytime you modify file /etc/grub.conf)
# grub-install hd0

Or after reboot, at grub prompt:

root (hd0,0)
setup (hd0)

g. reboot
# rm -f /etc/mtab  (already backed up as /etc/mtab.bak at section e)
# reboot

Note: if you encountered issue such as getting grub> prompt only , you need to boot into Windows partition, use command 'chainloader  (hd0,0)+1' to boot into Windows

# more /etc/grub.conf

title windows
   chainloader (hd0,0)+1