NOTE This is provisional (and unformatted) information Use at your own risk.
1) Make sure that the source machine has SSH installed, and that it's reachable via network.
2) Create an empty VM, allocating enough disk space. Sice this is a virtual
environment, the key is to *KEEP IT SIMPLE*. In the majority of the cases the
VMware infrastructure will take charge of the disk redundancy, and - anyway,
the "disks" will simply be files in some fscking large SAN array.
One single disk image, large enough to contain the data, could be enough. An
exception could be the made for web/mail/file/DB servers, where the possibility to
move and remount the extra disk image file in another VM can be a plus.
For the sake of example let's suppose that we will migrate everything on a single virtual HD.
* Select a Linux-Ubuntu template
* Size the RAM to a sensible size (based on the usage pattern collected in the phisical
machine). An unusual RAM size (as 234M) is perfectly OK.
* Create one or more virtual disks. Using the Ubuntu template the VM will emulate a
LSIlogic SCSI controller.
3) BOOT with a Knoppix ISO CD image, taking care to disable the graphical interface.
The boot parameters to use are:
knoppix 2 keyboard=it vga=normal
4) Check for the reachability of the source host. Try to ssh to it as root.
Fix things as needed
5) Create in the virtual disks the partitions you'll use, and mount them in a
mountpoint as appropriate.
Let's say that we chose to have / in /dev/sda1, /home on /dev/sda2, /var on
/dev/sda3 and swap on /dev/sda4. The steps are:
a) Create the partitions with cfdisk
cfdisk /dev/sda
b) format them
mke2fs -j /dev/sda1
mke2fs -j /dev/sda2
mke2fs -j /dev/sda3
mkswap /dev/sda4
c) mount them under /clone
mkdir /clone
mount /dev/sda1 /clone
mkdir /clone/home
mount /dev/sda2 /clone/home
mkdir /clone/var
mount /dev/sda3 /clone/var
Remember to make note of the new machine partition layout, you'll need these info later.
6) Start ssh on the target host and set a password for root
/etc/init.d/ssh start
passwd
7) Login on the source host and COPY (via tar+ssh) all the filesystem contents to the
virtual host (under the /clone tree)
Depending on the structure of your environment, you can adapt something similar to:
cat /etc/mtab | awk '/ ext[23] / {print $2}' |\
xargs tar --one-file-system -cf - |\
ssh root@tar.get.host '(cd /clone && tar xpvf -)'
7) In the now cloned FS, remove and change the old hardware identity hints. Specifically:
a) Remove ad-hoc statically loaded modules from /clone/etc/modules
b) Remove static HW names from udev (if the source was using it). You should remove:
/clone/etc/udev/rules.d/z25_persistent-net.rules
/clone/etc/udev/rules.d/z25_persistent-cd.rules
...
c) Edit /clone/etc/hosts (if needed)
d) *IMPORTANT*: Craft a new fstab (/clone/etc/fstab) with the new device names in the
cloned VM.
8) If needed, change the IP address so that when you boot the new VM you don't have a IP
conflict). See /clone/etc/network/interfaces
Depending on the services you run on the machine you should also replace/check the IP
in other deamons. Running
grep -r 11.22.33.44 /clone/etc
(with 11.22.33.44 replaced with your old address) should give you and idea on what
you need to touch.
9) Restore the boot loader. This could be one of the most tricky parts...
9.1) If the source has a 2.4 kernel:
Remount the root partition using "dev":
mount -o dev,remount /dev/sda1 /clone
Chroot to the VM disk
chroot /clone
Add the list of the kernel modules to be added in the initrd to suport the
LSI controller. You should add to /etc/mkinitrd/modules :
mptbase
mptscsih
Remake an initrd using the kernel version you'll use. Example:
mount /proc
mkinirtd -o /boot/initrd.img-2.4.5-foo 2.4.5-foo
9.2) If the source has a 2.6 kernel:
Get access to the /dev fs:
mount --bind /dev /clone/dev
Chroot to the VM disk
chroot /clone
9.3) Reinstall grub.
/usr/sbin/update-grub
/usr/sbin/grub-install /dev/sda
10) Ready to test?
Shutdown the VM and check the BIOS configuration to be sure that you are going to
boot from disk (and not from CD).
For added peace of mind, you can umount the CD and disconnect the NIC in the VM.
11) Test
12) Install the VMware tools
13) Re-boot, re-test
14) Rejoice. Pat yourself in the back. Party.
Another walktrough is there