16

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
  • 8,239
  • 17
  • 51
  • 64

4 Answers4

16

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.
Mircea Vutcovici
  • 16,706
  • 4
  • 52
  • 80
  • Could you elaborate on this? I am very interested in the *how* aspect. – Aron Rotteveel Mar 01 '11 at 15:05
  • I've updated the answer. – Mircea Vutcovici Mar 01 '11 at 16:30
  • Thanks! Out of curiosity: what would actually *happen* if I'd dual-mount a disk? – Aron Rotteveel Mar 02 '11 at 17:00
  • You can have filesystem corruption. But there are filesystems that allow to be mounted by two different machines (e.g. GFS). See: http://en.wikipedia.org/wiki/Global_File_System – Mircea Vutcovici Mar 04 '11 at 22:05
  • 1
    The 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 Mar 04 '11 at 22:12
  • Another 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 Mar 04 '11 at 22:15
  • About 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. – Mircea Vutcovici Mar 04 '11 at 22:20
  • Awesome, just booted Windows 8 64bit this way! No problems at all – Seth Hikari Sep 09 '12 at 09:14
  • Can 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. – Samuel Edwin Ward Feb 06 '13 at 16:14
  • It 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 Feb 06 '13 at 20:13
  • Try 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. – Mircea Vutcovici Feb 06 '13 at 20:23
  • Okay 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? – Kushal May 24 '13 at 07:47
  • You 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). – Mircea Vutcovici May 26 '13 at 17:55
  • When launching that VBoxManage command I get: `Syntax error: Invalid parameter '-register'` – knocte Jul 05 '13 at 23:36
  • Hi, I'm getting a `Invalid parameter '-register'` as well. – Jürgen Paul Aug 03 '13 at 21:58
  • It seems that this parameter is not supported in some versions of VirtualBox. See: https://forums.virtualbox.org/viewtopic.php?f=7&t=38532&p=177224&hilit=register#p177224 for a workaround – Mircea Vutcovici Aug 06 '13 at 14:41
0

Right now, there's no specific support for sharing a bootable partition with a VM. There's been some attempts at coercing VirtualBox into doing this on Macs w/ BootCamp, but it looks like a very difficult to accomplish and fragile process.

If you search the VirtualBox forums, you can find out what kind of success others have had. If this is something you intend to use in any kind of production environment, I'd wait until Oracle is at least attempting to implement it as a usable feature before trying to use it.

I know that Parallels Desktop for the Mac provides explicit support for sharing a VM with a BootCamp partition, and it's very easy to set up. So as far as it being possible to do, then yes. I don't know if they provide the same feature for their Windows and Linux products or not. It'd be worth a look.

afrazier
  • 710
  • 4
  • 7
0

I would suggest this is almost certainly not possible, or at least practically infeasible. Even if you could find a way to either boot natively from a VirtualBox image, or to boot a VB guest from a real partition (the latter is possible, I think), you'd still face the issue of the underlying hardware platform changing massively every time you switched. That at least would break your activation in a fairly short order.

SmallClanger
  • 8,947
  • 1
  • 31
  • 45
0

VMWare Workstation used to be capable of something like that, but it has been ages I used this so I don't know if (a) the function still exists and (b) it would work with modern Windows versions and their activation crap.

Sven
  • 97,248
  • 13
  • 177
  • 225