Booting a native Windows install in Virtualbox: is it possible?
It is possible to boot your Windows installed on your computer in a VM running on a Linux installed on the same computer. The only thing to remember: do not mount a partition on both OS. I've used this setup in qemu, kvm and VirtualBox.
EDIT: The ideea is to use the entire physical disk and be careful not to mount the same partition twice (like booting the same OS twice, or trying to mount a partition from an OS that was hibernated) VirtualBox setup:
- Create a VMDK file pointing to a raw disk:
VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk -rawdisk /dev/sda -register
See: http://www.virtualbox.org/manual/ch09.html#rawdisk - create a new VM and use the raw disk for that VM.
- unmount all partitions that will be used by VM.
- boot the VM and in the Grub menu chose an OS that is not already booted.
Comments
-
Aron Rotteveel over 1 year
I am looking for something similiar to Bootcamp.
Currently, I run Ubuntu Maveric as my primary operating system and run Windows 7 in Virtualbox. For some tasks, however, running Windows virtualized just seems to result in too much overhead and speed loss, and I'd like to be able to boot natively.
The ideal situation would be to setup Windows and Ubuntu in dual boot on seperate partitions, with the ability to boot the Windows partition in Virtualbox on Ubuntu as well.
Is this possible?
Also, how it is that Bootcamp seems to be the only system capable of this?
-
Aron Rotteveel about 13 yearsThanks! Out of curiosity: what would actually happen if I'd dual-mount a disk?
-
Mircea Vutcovici about 13 yearsThe corruption is caused by the fact that part of the filesystem state is keept in the memory of each kernel. For example the dirty pages are kept in memory for few seconds and meantime the other kernel can change the same files, jurnal or fs structure at the same time. For example you delete a file from one OS and meantime the other OS will create another file in the same folder. Because the 2nd OS has a older copy of the folder cached in memory, it could write it to disk with the cached info (first file not deleted) and new file added. The firs OS fill not notice the added file.
-
Mircea Vutcovici about 13 yearsAnother problem is file locking. If the first OS will lock a file the other OS will not be aware of the lock and can write into that file. But if the partitions are mounted read-only in both OS it is OK.
-
Mircea Vutcovici about 13 yearsAbout 4 years ago I've installed a new Linux using qemu on a partition that was not used by the current Linux. This allowed me to upgrade the server with only 5 minutes downtime - just to reboot.
-
engr over 11 yearsAwesome, just booted Windows 8 64bit this way! No problems at all
-
Samuel Edwin Ward over 11 yearsCan kvm use this sort of vmdk file? I am trying it but it doesn't seem to be working and I can't seem to find a straight answer as to whether it's supported.
-
Mircea Vutcovici over 11 yearsIt is possible to use physical device in kvm. You do not need to define any "vmdk" file to use this kind of setup. Just use the disk (e.g. /dev/sda) directly as a "raw" disk image. Make sure you do not mount the same partition twice in the physical machine or any VM.
-
Mircea Vutcovici over 11 yearsTry on a test machine:
sudo kvm -hda /dev/sda
You need to be root to have access to the physical disk. Make sure you understand what are you doing before you will run this command. As long you are in the boot loader you are still safe. When you boot an OS make sure that it will not mount the partitions that are already mounted. -
Kushal almost 11 yearsOkay so here's doubt regarding a situation. I'm on Ubuntu, and have 4 partitions on my entire hard-drive. 2 of which are Ubuntu and Windows, and 2 partitions are for data. Now, I boot Windows partition within Ubuntu (where I already have 2 of my data partitions mounted), and from the loaded Windows within VM, can I access the same data partitions? Or do I have to
umount
it on Ubuntu before I access it in Windows? -
Mircea Vutcovici almost 11 yearsYou can not mount directly the same partition twice (in Windows and Ubuntu) at the same time. However you can share the partition via NFS or Windows file sharing (Samba).
-
knocte almost 11 yearsWhen launching that VBoxManage command I get:
Syntax error: Invalid parameter '-register'
-
Jürgen Paul almost 11 yearsHi, I'm getting a
Invalid parameter '-register'
as well. -
Mircea Vutcovici almost 11 yearsIt seems that this parameter is not supported in some versions of VirtualBox. See: forums.virtualbox.org/… for a workaround