Migrating a Linux machine to a VMWare host

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

7 thoughts on “Migrating a Linux machine to a VMWare host

  1. […] du machst es so wie hier beschrieben… ein direktes kopieren des Platteninhalts über das netz: Migrating a Linux machine to a VMWare host « The eternal fight between admins and computers __________________ We think we’re in control then we become the things we hate. In Zukunft werden […]

  2. When using Ubuntu Live CD you need to change step 7 to:

    sudo nc -l -p 10000 | sudo dd of=/dev/hda


  3. Great tutorial indeed, thanks for sharing !!

    I’d like to use this method to consolidate an old qmail server that has fstab like this:
    # This file is edited by fstab-sync – see ‘man fstab-sync’ for details
    /dev/VolGroup00/LogVol00 / ext3 defaults 1 1
    LABEL=/boot /boot ext3 defaults 1 2
    none /dev/pts devpts gid=5,mode=620 0 0
    none /dev/shm tmpfs defaults 0 0
    none /proc proc defaults 0 0
    none /sys sysfs defaults 0 0
    /dev/VolGroup00/LogVol01 swap swap defaults 0 0
    /dev/fd0 /media/floppy auto pamconsole,exec,noauto,managed 0 0

    It is configured to use VolGroup .. can i use the same method like:
    nc -l -p 10000|dd of=dev/VolGroup00/LogVol00


    Thanks again for the great note

  4. Hi … nice tip, however … what will happen if size of disk on target machine (virtual machine) is not the exact size as the one at the source machine? Will dd still copy disks without problems?

    Kind regards, Marko.

  5. It’s a bit frightening dd’ing from one machine’s raw disk directly to another.

    Instead of that, we used ‘SystemRescueCD’ to boot the original machine, then sshfs to connect a file system (of any other PC) over the network, and finally qemu-img to convert to VMWARE format.

    mkdir /mnt/remote
    sshfs myself@ /mnt/remote
    dd if=/dev/sda of=/mnt/remote/image

    Now you have an image file called ‘image’ on the remote machine. You can run this as-is with QEMU:

    qemu image

    — or use qemu-img to convert it to VMWARE format:

    qemu-img convert -f raw image -O vmdk image.vmdk

    Now create a virtual machine with VMWARE, and give it the file ‘image.vmdk’ as it’s first disk. Make sure this disk is defined as IDE.

    Now you can run it!

    Seeya – Shalom Crown

  6. A safer and easier method would be to:

    1. boot to an external os like knoppix on the original machine and re-size the partitions to the smallest available size.
    2. dd the smaller re-sized partitions to network storage.
    3. boot the vm image from the same boot disk and copy in the partitions / disks from network storage to the vm hd.
    4. re-size the partitions to whatever size you wish.
    5. depending on the vm hardware, you may have to alter the bootloader and/or inittab. For example, changing /dev/hda to /dev/sda if using scsi instead of ide. Using IDE may be best because sometimes you need to add scsi drivers before it can read the drive.

  7. Thanks for this tip…
    Did similar things already with tar and curl on file level….
    I’m now in the process of migrating a 80 GB and a 60 GB but it’s taking some time on my 100 Mbit/s LAN…..

    Next time I will compress things…..

    I guess this will work:

    dd conv=noerror if=/dev/hda | gzip –fast | nc $IP_OF_THE_VM 10000

    nc -l -p 10000 | gunzip | dd of=/dev/hda

    Mine has sda drives, so I used /dev/sda

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s