My Ubuntu 12.04 is installed on /dev/sda5
and Windows 7 on /dev/sda1
. When I am running Ubuntu, I would like to use Virtualbox to run Windows 7 in a VM. The Windows 7 partition is 1 TB and is half full, i.e. large, so I don't want to copy it into a virtual hard disk.
I have read that it is possible to use a real hard disk for a Virtualbox VM, but the various instructions I have found differ from each other, and I can't seem to get it to work. Does anyone know a way to make it work in Ubuntu 12.04 and Virtualbox 2.1.12_Ubuntu r77245 (the latest Ubuntu installed the repos)?
Please post how it works for you as I want to retry any method that might work.
The command you want is
This will create a special VMDK virtual disk file (Win7.vmdk) which is actually a pointer to the host disk partition
/dev/sda1
.In theory, you can then use this as the disk file for a VM to run directly from the actual disk partition, but...
Yes you can do that with the internal
createrawvmdk
command, which will not create an entire disk image, but a pointer to the actual hardware.There are two ways to do that
A. Full disk image (of /dev/sdb)
B. Partition image
As @StarNamer showed, you ca use only one or few partitions.
To create image of just one (/dev/sda1) partition:
To create custom partition table which will map /dev/sda2 and /dev/sda1 in that order:
Most striking difference will be that full disk image will use bootloader and partition table exactly as they are in your disk, so in theory (I did that previously only in qemu) you will be able to setup OS from your virtual machine. And from my limited experience I can say that full disk image will work exactly as
qemu -hda /dev/sdb
.Note: If you're using user to access the disk, you need to add it to
disk
andvboxusers
groups, e.g.then make sure you re-login or restart your computer.
Further reading:
2).-mbr
option (see 1) when creating the VMDK.VERR_ACCESS_DENIED
error, check: Virtualbox doesn't work with a real partition.There is an Disk option called "Immutable", so in theory if you select this option for the vmdk linking to your raw disk, it should not change the original partition.
To do so open "Virtual Media Manager" found under "File", select your image and click "Modify" (You have to make sure this image is not attached to any machine, otherwise you get an error). Now you can set the media type to "Immutable".
I have not tested this, though. If anyone does (of course with a test setup) it would be good to report back here.
Has anyone considerations which speak against this idea?
For several years now, I have been running dual-booted Windows and Ubuntu with the Ubuntu Partition also booting into Windows VirtualBox to take advantage of the touch-screen capabilities that Linux hasn't yet mastered.
I set it up with instructions similar to below;
The new machines can simultaneously handle both OSs better than single systems on old machines.
Downside: You need to save the instructions you use for setup in case an update disables the VirtualBox connection (my current problem).
After many tries I ended up with a neat and clean solution:
Troubleshooting in case of UEFI:
If you get stuck at the EFI Shell, run the following command:
VirtualBox has lot of disadvantages. I leave it some years ago. Now I use qemu-kvm and beside other fine feature it can be configured to use the disk device in the same way as the disk image. The trick is to configure the virtual "-drive if=sd,id=sda,format=raw,file=/dev/sda" .
But! You must first make some changes while running the MSW on the bare metal, before you try to virtualise it: look at "Drivers" folder for the proper drivers to be present and the "Registry" tree to be those drivers enabled and set to be run prior the system start like:
You have to look for apropriet driver with respect to the virtual machine if you do not want to see the BSOD.
It is hard to say which drivers to activate. The best way is to install a test system first, then search register in it for register key with the "Start"=dword:00000000 and then set these key on the bare metal machine. It is also recomended to check the MAC address on the bare metal to put it in the qemu configuration. You can prevent the system to ask for new activation.