Convert Ubuntu system from physical to virtual (kvm/qemu)

So I’ve had some troubles converting a Ubuntu Server from a physical system to a kvm compatible system. After trying and failing a few methods I found one that worked well.

1. Shut down your system to be cloned.

2. Install a hard drive (SATA/USB etc) to store your disk image of your boot drive.

3. Boot system up with a Ubuntu Desktop Live CD

a. Mount the disk drive to copy your image to.

b. Determine your disks, open Terminal type in…

    sudo su –

    fdisk -l

Note the location of the drive you wish to clone.  Which should be something like /dev/sda

4. Copy your drive using dd.  Change the drive location, and filename to your appropriate information.

    dd if=/dev/sda of=/media/usbdisk/sda.img

5. Reboot your machine, remove the Live CD.

6. In your QEMU or KVM virtual host.  Copy over the image file from your drive to your storage pool.

7. Create a new virtual machine using existing disk.  Select the copied image file, use the ‘raw’ format.

Tags: , , , , ,

This entry was posted on Tuesday, December 13th, 2011 at 11:35 pm and is filed under OSS. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

2 Responses to “Convert Ubuntu system from physical to virtual (kvm/qemu)”

Stowe Davison April 20th, 2012 at 8:15 am

Can you give a little more detail on Step 7? Are you using virt-install? Or virt-manager? If virt-install, then an example command line with all options would be very helpful.

Thanks.
Stowe Davison

Sean April 20th, 2012 at 11:52 pm

Stowe,

I’m using Virt Manager with a KVM backend. I used the Virt Manager GUI to add the system using existing disk. I don’t exactly mean for this to be a how-to on building a virtual environment. You can google it, there is plenty of resources on that topic.

Sean Furukawa

Leave a Reply