VirtualBox: using physical partition as virtual drive

37

24

Background: I am using VirtualBox installed on Windows 7. From within VirtualBox I am using Xubuntu as a virtual OS. The reason I chose this approach is so that I don't have to keep turning off Windows and rebooting from Xubuntu every time I needed to switch OSes. And VirtualBox's seamless mode is pretty amazing to allow me see Xubuntu and Windows 7 all in one screen.

Issue: Now I am thinking of a way to have Xubuntu more integrated into my system. By this I mean I want to have a physical partition for Xubuntu. But I want to still have the feeling of the seamless mode.

Question: So finally, my question is: is it possible to load a partition in VirtualBox as a virtual OS?

Case examples: Ideal scenario would be: I physically boot up and login to Windows 7. Now I want to access Xubuntu, so I load VirtualBox and access my Xubuntu partition without rebooting. And the other way around too, i.e. I boot up the system, login to Xubuntu, and can access the actual Windows 7 partition through VirtualBox.

Other info: Please note that I am not talking about getting access to files, as I have a completely separate partition for my files, and am very familiar with VirtualBox's Shared Folders option.

Hamman Samuel

Posted 2012-02-21T22:23:11.913

Reputation: 626

Question was closed 2018-12-12T07:56:20.823

1

I came across a Life Hacker article that covers the question: http://lifehacker.com/how-to-dual-boot-and-virtualize-the-same-partition-on-y-493223329

– Hamman Samuel – 2016-04-04T05:37:16.743

My question was posted first (Feb '12), so actually the other question (posted Oct '12) is a possible duplicate of mine – Hamman Samuel – 2018-12-12T01:52:10.287

I think the answers from other posts are better, as actually showing the exact commands which should be used. This answer got only the link. – kenorb – 2018-12-12T15:04:44.103

Answers

37

What you are looking for is called "raw hard disk access" in VirtualBox.

Basically you create a virtual disk in vmdk format and configure it to direct to the desired partition or drive.

You can find a description in the manual under Advanced topics / Advanced storage configuration / Using a raw host hard disk from a guest

However keep in mind that, in the setup you are planning, the hardware that the operating systems see constantly changes. (your actual hardware when started as host OS, some virtualized hardware when started as a guest). Linux might cope with that but I am quite sure Windows will not handle that well. Also it might suspect you are using the same Windows licence on several computers and force you to reactivate often or flag itself as pirated.

Another issue might be how to tell the OS to use either the virtual drive (as guest) or the actual physical one (when started as host). Under Linux it might work to fiddle around so that both are assigned the same device name (like /dev/sdb1).

zpea

Posted 2012-02-21T22:23:11.913

Reputation: 1 363

2

Sadly, this still doesn't work for GPT drives in VirtualBox 4.3.28 on Windows. Let's hope they fix that before releasing VBox 5.0. :-/ https://www.virtualbox.org/ticket/11049

– clacke – 2015-05-15T10:45:24.777

Done this with Linux host and Windows guest and it worked. But with only 8GB of RAM and no real use for Windows, I decided to format my Windows partition and divided it up using LVM – Evan Langlois – 2016-10-24T16:55:53.520

3block device naming is a long-solved problem - use the partition's UUID or LABEL in /etc/fstab instead of the device name (/dev/sdb1). All formatted partitions have a UUID, and most filesystems let you set a label either when you format the partition, or afterwards (e.g. with tune2fs -L for ext2/3/4). – cas – 2018-01-22T14:09:10.343

Excellent answer @zpea, much appreciated! I'll post a comment later on when I try this to let anyone know how it goes – Hamman Samuel – 2012-07-15T16:04:18.187