Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there any way to create a virtual machine that you can use in VirtualBox from a physical installation that you have? For instance, if I have Windows XP installed on a physical computer and want to have a virtual version of that machine on a different computer. This would save a ton of time by not having to reinstall and reconfigure the whole OS.

I would think there would be issues with Microsoft's licensing. But even if it's not possible with Windows would it be possible to take a physical Linux machine and create a VirtualBox version of that? Does any other desktop virtualization software provide this feature?

share|improve this question

9 Answers 9

up vote 33 down vote accepted

Windows is a bit different, see How to migrate existing Windows installations to VirtualBox for a guide.

From memory you can use VMware's converter and VirtualBox will read VMDK files.

For Linux, if you want the easy solution, boot a live CD,

dd if=/dev/sda1 of=/path/to/images/sda1.img bs=1024

Do that for every partition mounted in /etc/fstab of your machine, and then setup those images in VirtualBox.

share|improve this answer
2  
It appears from the docs at the link you list Sun recommends imaging the entire drive not just the partition so your dd command would change to: dd if=/dev/sda of=/path/to/images/sda.img bs=1024 –  Andrew S Jul 26 '10 at 20:49

Windows is pretty easy to clone to virtual machine with Microsoft tool called Disk2vhd. You can do it on a running Windows system as I did with my Windows 2008 server.

  1. download Disk2vhd and extract it to some folder.
  2. Start the software and choose which partition you want to clone.
  3. Wait for the cloning to finish, in my case this took about 50 minutes
  4. Copy the resulting .vhd file to your virtual machine host.
  5. Start your virtual machine software and make a new VM.
  6. Mount the disk on the VM you just made and boot.
  7. If everything went right you should now have a clone of your Windows system running in a VM

If you are migrating a Windows installation to VirtualBox you might want to check out the how-to on on the VirtualBox website

share|improve this answer

I prefer the network cloning methods using a live CD or ISO images (Clonezilla, Ghost, etc. there are many to choose from). See my previous post regarding increasing disk size in virtual machines.

The network cloning methods work physical to physical, physical to virtual, virtual to virtual and between any virtualization platforms supporting booting to ISO/CD.

You shouldn't use APIC anyway unless using a laptop or you need extra interrupts (lots of addin cards, old ports still being used, etc.). PIC is much better for physical machines if you're doing anything realtime based like audio/video, CNC, etc.. These days with USB and eSATA interrupt stacking isn't as often needed as before.

share|improve this answer

To do this...Shutdown Windows or whatever you are using

Force Boot a live linux CD.

Open a terminal window and type:

sudo dd if=/dev/YOUR DEVICE (hdd,cdrom) of=A UNIQUENAME.iso (WINBoot,cd5,Hacktoolz).iso.

In the command... 'if' is Input File (or source) and 'of' is Output File (or destination).

This takes your OS HDD or OS install CDROM and creates an ISO from it in FILE format and stores it in your Homedir.

Open VitrualBox and Create your new VM.

Right click the VM, select settings, click Mount a CDROM, Select Mount an ISO or Image file.

Select ADD.

Browse and Locate the ISO you created with the "sudo dd if=/dev/cdrom of=cd5.iso" command.

Select it and double click it (or hit OK).

Click OK.

Start the VM.

Voila! Your boot OS HDD or CDROM is now running in a VM ;-)

share|improve this answer

It's not a straightforward method to create a virtual machine from a physical and run in VirtualBox. But, it's possible with the steps mentioned in Sun VirtualBox P2V.

share|improve this answer

Most virtualization software has the ability to run an installation straight off the physical drive or from an image made from that drive.

For example, I've routinely created images from hard drives using "dd" and then "booted" the installation on that image using Qemu under FreeBSD. Other than the OS having some issues with the new virtual hardware, things worked as expected.

share|improve this answer

I did this, but not using Virtualbox. I would have liked to, but the solution was not available. This is entirely possible and relatively easy to do with VMware's free tools. Take the drive that you want to turn into a VM out of the box it's in and drop it in a Windows or Linux box, create a full disc image, and convert it to a VM using either the vmware supported VMware vCenter Converter (http://www.vmware.com/products/converter/) or using qemu-img, which works just as well. There are tons of walkthroughs on how to create images using qemu-img, and the man page is very good.

share|improve this answer

I'd use Clonezilla to do it. Way easier. Just make sure that when you create the virtual machines hard drive, that it is approximately slightly larger or the same size as the old hard drive.

share|improve this answer
1  
which clonezilla file do u use to create a virtualbox vm? –  skyfoot Jun 11 '11 at 23:51

I would copy an image.

Be careful, as if you don't follow the guide after restoring the image on the virtual machine, the virtualized Windows won't boot anymore as VirtualBox by default does not emulate I/O APIC (as it is faster, they say).

share|improve this answer
    
yes, not enabling IO APIC has kicked me in the pants before. Took me forever to figure this out. The VirtualBox log was not helpful! –  Adam Oct 8 '10 at 21:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.