38

Is it possible to convert a Physical Ubuntu Install (Intel based PC with Ubuntu 10.10) to a virtual box disk, so that I can use that same environment on a separate pc or can keep it virtual for testing?

Something similar to "Disk2VHD" which converts a physical Windows 2K3 and above box into a VHD or VMware image.

Will be grateful for your assistance ! Kind Regards

fossfreedom
  • 172,746
Mutahir
  • 811

2 Answers2

34

Yes, however it will most likely take a very long time. I haven't actually tried the steps below, but they should work.

First, you need to make an image of your entire partition. You need to know the partition path of the Ubuntu partition, for example /dev/sda1 would be the first partition on the first attached hard drive.

sudo dd if=PART_PATH of=OUTPUT_PATH/ubuntu.bin

note that you should do the above command from a liveCD with the partition you are trying to copy unmounted -- i.e. you need to have another hard drive or something to copy all the data to.

You can shut the liveCD down and boot back into Ubuntu to perform the last step:

Convert the binary into a vbox drive:

VBoxManage convertdd PATH_TO_ubuntu.bin ubuntu.vdi --format VDI

you can then use the resulting ubuntu.vdi as a Virtualbox drive. Just make sure you have plenty of time and hard drive space for this operation. A little tip: commandline tasks can be suspended by hitting Ctrl+Z. The operation will go to sleep, and you can use you computer again. When you are interested in resuming the process, type fg in the terminal, and the operation will resume. Quite handy for long operations like this.

Jakob
  • 10,579
nerdy_kid
  • 1,005
  • 8
    I would use gparted before running dd. With dd if you have a 200GB Linux OS partition your going to get a 200GB file. Even if you are only using 8GB of it. Then when you convert your going to need 400GB total. So use gparted, shrink to 9GB (give it a little space) then run DD. To note it does take a long time to run gparted, but in the long run its a lot faster then doing a VBoxManage on a 200GB bin DD backup. :) – Psytek7 Dec 01 '12 at 02:26
  • 2
    This should work as well and be faster: sudo dd if=PART_PATH | VBoxManage convertdd stdin ubuntu.vdi SIZE_BYTES --format VDI where SIZE_BYTES is the size of the device in bytes – Jacob Oct 15 '14 at 22:42
  • 2
    I've used these steps. When starting the VDI in virtualbox I get an error: FATAL: No Bootable medium found! System halted. – Riccardo Dec 15 '14 at 06:42
  • @butcher same here :( – 00fruX Jan 05 '15 at 01:31
  • 1
    @00fruX For the initial dd command, you need to image the raw device (e.g. /dev/sda) instead of only the primary partition (e.g. /dev/sda1), that way you get the boot partition. – chess007 Apr 20 '16 at 13:41
  • @chess007 but I dual boot my system and my Ubuntu is in /dev/sda7. Any idea how to make it boot? – RecursiveCursive Apr 17 '18 at 17:19
0

an alternative route, check out: 'VMware vCenter Converter'

it's freely available, and claims do to this in one go: http://linhost.info/2009/04/vmware-converter-installation-on-ubuntu-linux

from there, it links to the vmware page, but only under 'version 4.01' is a linux flavor avail. after the registration hoopla, expand and look for: "Version History - VMware vCenter Converter 4.0.1"

Matt S.
  • 773
  • 4
    I just tried this. You still need an ESX server somewhere on the network to store the VM. VMware VCenter Converter is only the "middle man" that converts the physical computer to the VM and stores it on the ESX server. (http://www.vmware.com/pdf/converter_standalone_guide401.pdf) - "In Linux conversions, no agent is deployed on the source machine. A helper virtual machine is created instead and deployed to the destination ESX/ESXi host." – 00fruX Jan 05 '15 at 01:39