Just needed to have a place to document the process to migrate a server to a VM.
Problem: migrate (or consolidate) a phisical Linux machine to a VMware virtual machine without passing through a CD/DVD.
1. Install VMWare Server on the desired machine.
2. Create an empty virtual machine with enough disk space, selecting the OS you’re going to migrate.
3. Download a Linux live-CD ISO (for example Grml or Knoppix).
4. Burn one copy on a CD and then copy the ISO to the VMWare server (the host).
5. Reboot the original Linux box with the CD you’ve just burnt, and connect the ISO to the newly created Virtual Machine.
6. Check both live CDs have net connection correctly configured and that they can see each other.
7. In the virtual machine, type this:nc -l -p 10000|dd of=/dev/hda
8. On the machine you’re migrating, type:
dd conv=noerror if=/dev/hda|nc $IP_OF_THE_VM 10000
9. Wait until dd finishes its job, do a clean reboot of the virtual machine and enjoy the consolidation! You may want to install VMWare tools to get everything 100% working in the new system.
A couple of notes:
dd is used to do a physical copy of the disk conv=noerror is used to bypass error on the original disk. Use this option at your own risk. nc is used to copy the stream other the net. man lc for further info kill -USR1 $PID_OF_DD could be used to see dd stats
Take a Linux install iso, my favourite is CentOS 4.6 disk 1, set it as boot device and fire up your VM.
Be sure to boot from the rescue CD. Otherwise you'll surely get a Kernel Panic messages at the boot prompt type Linux Rescue.
do NOT connect the network (sometimes it bring to an hanged system)
Linux rescue will try to mount the virtual machine file system in /mnt/sysimage: mount it in read-write mode.
Issue the chroot /mnt/sysimage command
edit /etc/modules.conf with your favourite editor, changing every scsi alias with BusLogic and each eth nic with pcnet32. Save and exit.
Change directory to /boot and make a backup copy of your initrd-2.x.y-zz.img .
Then issue the mkinitrd command (mkinitrd -v -f /boot/initrd-2.x.y-zz.img 2.x.y-zz, all on one line). Wait for the command to end.