Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've a drive with Fedora and Windows 7 on different partitions with dual boot.

Now, while running Fedora, I'd like to suck up the Windows partition and create an image I can run in VirtualBox - how can I do this ?

share|improve this question
1  
With some tricks, you can boot the partition directly. –  shellholic Feb 26 '11 at 18:09
    
@shellholic: How is that done? can you answer it here: superuser.com/q/463591/74616 –  Tamer Shlash Aug 19 '12 at 14:23
add comment

3 Answers

From what I have seen (testing under Ubuntu) this is possible, but you will need alot of spare disk space.

First off you need to take a raw image of your windows partition, then convert it to a more efficient compressed format, and finally delete the raw image.

(as root - replace /dev/sda2 with the device name of your windows partition)

# dd if=/dev/sda2 of=windows.img
# VBoxManage convertdd windows.img windows.vdi
# rm windows.img

Unfortunately VBoxManage can't get the size of the hard drive partition, so it needs the raw file to be able to work that out.

Once you have the disk image you can create a virtual machine and import the disk image into it.

You will probably find that Windows really doesn't like booting up in the virtual machine - all sorts of driver issues etc. Booting in Safe Mode then playing around with drivers in the Device Manager may work.

To be brutally honest it may be easier to just create a brand new windows installation in VirtualBox and install your software and files afresh from your old windows installation.

share|improve this answer
add comment

There's a documented "internal" function that you might be interested in. You can create a "raw disk" image which basically passes all commands to the partition on your hard drive. That way, you can keep your Windows partition and attempt to boot it from VirtualBox as well.

You can create a raw image as follows:

VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk -rawdisk /dev/sda -partitions 1,5

where 1,5 means partitions 1 and 5 on /dev/sda

Mind you, the chances of this working flawlessly are pretty slim. Windows is not exactly known for being adaptive to extreme changes in hardware.

You can read more about raw disks here: Chapter 9. Advanced storage configuration

share|improve this answer
add comment

As Matt said, you use the VBoxManage command, and that Windows might not like it. However, there's a faster way that doesn't use up as much disk space. You can use stdin as the input for the convertraw command (which, if you read Matt's answer, is the same as the convertdd command:

# dd if=$WinDevice | VBoxManage convertfromraw stdin windows.vdi $Bytes

Where $WinDevice is the device of the windows partition (such as /dev/sda2), and $Bytes is the exact number of bytes (for example, 1488581554176; you can determine this from within Windows by right-clicking on the C: drive in My Computer and hitting "Properties", it's the Capacity: line underneath the Used and Free space lines and above the pie chart).

Note that I have not tried this myself, and that I believe you might need to use /dev/sda instead of /dev/sda2, assuming you won't be writing to the drive that Windows is on. That way, you capture the partition table and bootloader.

share|improve this answer
    
As of now (currently Feb. 22, 2014), the number of bytes goes after the output filename. –  echristopherson Feb 22 at 21:05
    
Huh, you're right. Fixed. Do you know if that's always been the case and nobody's noticed until now, or if they changed the order some time within the last three years? I'd guess they wouldn't change the order, but I'd have also have expected somebody to notice by now. –  Daniel H Feb 22 at 22:34
    
I'm not sure if it was ever different... That's part of why I didn't just edit the answer. –  echristopherson Feb 23 at 4:06
add comment

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.