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 have a dual-boot system with Windows 7 and Ubuntu 11.10 installed on separate partitions, according to the following partitioning scheme:

1. MBR for windows
2. Windows system partition (NTFS) - i.e. C:\
3. Ubuntu / partition (ext4)
4. Ubuntu /home partition (ext4)
5. Ubuntu /boot partition (ext4)
6. Ubuntu swap partition
7. Data partition (NTFS) - mounted as D:\ in windows and /media/data/ in Ubuntu

When I'm in a Windows session, I'd like to be able to start a virtual box with the Ubuntu system from my disk. That is, I don't want yet another Ubuntu installation virtually on some .vhd file, but to actually start it with the data from my hard drive.

I've used Windows Virtual PC before, but never with an actual disk partition as the hard drive rather than just a .vhd file.

share|improve this question
add comment

5 Answers

up vote 3 down vote accepted

I have done that setup using http://www.virtualbox.org, it is described on the manual and the command is something like this: (Please read the documentation !!)

VBoxManage internalcommands createrawvmdk -filename linux.vmdk -rawdisk \\.\PhysicalDrive0 -partitions 7,8
  • The command creates a linux.vmdk and linux-pt.vmdk files on your hard drive, you can use these files as a "virtual disk" in the setup of your virtual machine.

  • This command limits the access of the Virtual disk to only some partitions of your hard drive to prevent damages, please adjust the partitions numbers accordingly.

  • In Windows 7, Virtualbox has to be run "as administrator" in order to access the linux partitions properly.

  • The first time you run the virtual machine Ubuntu should be able to detect the hardware in the virtual machine and configure itself again.

  • You will have to probably install GRUB again in the MBR of your virtual disk (which will be different from your hard drive MBR)

  • Do not attempt to mount the Windows data partition under Ubuntu, that will for sure corrupt the partition, but if you need to access the data, instead configure the networking and mount the partition as a samba share.


The following is the help message printed by VBoxManage:

Usage: VBoxManage internalcommands  [command arguments]

---snip---

  createrawvmdk -filename  -rawdisk 
                [-partitions  [-mbr ] ]
                [-relative]
       Creates a new VMDK image which gives access to an entite host disk (if
       the parameter -partitions is not specified) or some partitions of a
       host disk. If access to individual partitions is granted, then the
       parameter -mbr can be used to specify an alternative MBR to be used
       (the partitioning information in the MBR file is ignored).
       The diskname is on Linux e.g. /dev/sda, and on Windows e.g.
       \\.\PhysicalDrive0).
       On Linux or FreeBSD host the parameter -relative causes a VMDK file to
       be created which refers to individual partitions instead to the entire
       disk.
       The necessary partition numbers can be queried with
         VBoxManage internalcommands listpartitions
share|improve this answer
add comment

The manual seems to suggest that it's possible, although experimental (please backup!): http://www.virtualbox.org/manual/ch09.html#idp13647760

I've never tried for myself, though.

share|improve this answer
    
You're still dealing with an OS configured on non-virtual hardware being expected to run on virtual hardware. It may work, but it's not the same thing as running the Ubuntu install on the system it was configured to run on. –  music2myear Nov 21 '11 at 22:38
add comment

Extensions on jhcaiced's answer:

If you included your data partition in the "-partitions" parameter, vbox will obtain exclusive access to it when it starts the VM, so you can't actually corrupt the data on it through concurrent access via your Windows host.

However, due to compatibility reasons, you'd better leave that partition to Windows and access it through a vbox shared folder or a Windows file share. You can modify /etc/fstab to mount the share automatically to the same location on boot. (Install guest additions fist.)

Unlink Windows, the default Linux kernel can readily work on multiple hardware configurations, but your X (display) configuration may not. The lazy solution, which requires no configuration, is to keep the driver for your real graphics card activated. When you use Ubuntu in the VM, you will be switched to a fallback driver which works quite well.

share|improve this answer
add comment

This really wouldn't work. You can't safely mount the same partition on 2 operating systems at once. But if you REALLY REALLY WANTED, you could try using a /dev/something device from linux to serve as the drive for windows, but it'll be really UNSAFE. (also need root)

No idea if it could be done with windows as the host.

But, remove the auto-mount of the shared data, and you should be fine. Though: NO WARRANTY, MAKE A BACKUP.

share|improve this answer
add comment

I don't believe this is possible. The Virtual Box system uses virtual hardware on which the virtualized system runs. Your setup has the OSes installed on "real" hardware and it is fundamentally different.

If you're looking for running two OSes simultaneously on the hardware, you'll need a virtualization hypervisor framework, such as Xen, which will manage the two OSes and the hardware and allow interaction with the systems semi-simultaneously.

Update: answering Hello:

Yes it is Windows. He's running a dual boot machine with Windows 7 and Ubuntu 11.10. And in his scenario he has booted into Windows and is trying to load his Ubuntu load into a virtualized framework. Now please remove your downvote.

share|improve this answer
    
This is not Windows. –  Hello71 Nov 22 '11 at 3:25
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.