Convert VirtualBox guest into main OS

Solution 1:

I found these instructions on techokarma.blogspot.com:

VirtualBox comes with one hidden command under its hood, converttoraw! This can be used in following manner,

VBoxManage internalcommands converttoraw your.vdi your.raw

So now you have a raw image of your VM (please note that if you have a VM of say, 16GB dynamically expandable virtual hard disk, when you create a raw image it will actually create a file which will occupy 16GB on your disk! so make sure you have that much of space on your disk before procedeeing). Now this raw image can be deployed to another disk very easily.

Connect the disk on which you want to deploy the raw image that you just created to your existing system. Now depending upon on the Operating system that you are running the actual command may very. I will pick Linux as my host operating system on which I will assume the VirtaulBox is running. So this second physical disk appears as /dev/sdb on my Linux box, so I execute,

dd if=/location-of-your-raw of=/dev/sdb

Once its done, connect this disk as primary master to the system that you are planning run. At first boot, make sure the system is started with -r option to re-configure the devices.

Solution 2:

Yes. However, there are a few steep hurdles you'll have to clear. You may want to consider using the backup and restore utilities instead since that would be easier. But if not then read on.

If using Windows as host you might want to first move (or copy) your virtual OS from the .vdi format that Virtual Box uses to a .vhd format that Windows can mount. (I seriously doubt you already did this or created your guest OS on a .vhd rather than VBox's default .vdi format). The goal here is to get your virtual OS on to a virtual hard drive that Windows can then natively mount without the use of Virtual Box. And for that, I personally like using Clonzilla mounted as a .iso in VBox as my CD/DVD-ROM drive so that I can transfer one image from one virtual drive to another virtual drive.

Once your guest OS (in this case, Ubuntu) is in a .vhd "file" and mounted as a hard drive within Windows, you can then use any number of Windows-based imaging utilities to directly copy the entire virtual hard drive (and OS) to a real hard drive. Afterwards, just move the real hard drive to your new machine and voila! However, I'm almost certain you will have problems with hardware and drivers but at least the core OS will be there. (You may also want to uninstall the guest additions before transferring the image to the new real hard drive too.)

FYI: Virtual Box is able to fully use and mount .vhd files which Windows (XP to 7) can natively create. However, with VBox you must unmount a .vhd as a hard drive before the guest can boot from it - or even use it. Don't worry, you can still share files between a guest OS and a host. You just have to use file sharing instead of full-on direct mounting cause only one OS can really only mount any one hard drive at any one time.

Now you may be able to do this under Linux. I'm just not the guy to ask since I don't know of any virtual hard drives that Linux can natively support other than maybe a the .iso format.

Hope it helps.

Solution 3:

In situations like this, the best solution, to me is to keep it as simple as possible - which to me is to use the same methods i'd use in replicating a physical box

You could make an image of the VM with something like clonezilla and restore it

You could alternately use something like remastersys to make an installer with your software preferences already in it

Finally you could just do a fresh install and move /home/ and other customisations over