28

I'm searching for a solution to boot a native OS on a hard disk as a virtual machine.

It's like what VMware Fusion did on a Mac which boots Windows in Boot Camp as a virtual machine.

In detail, I have Windows installed on /dev/sda2 and Ubuntu 11.10 on /dev/sda5.

Is there anyway to use a virtual machine software to boot the Windows on /dev/sda2 as a virtual machine while I'm using Ubuntu?

jesterjunk
  • 2,342
  • 22
  • 18
YankeeWhiskey
  • 1,522
  • 4
  • 20
  • 32
  • 1
    VMWare allows this, see https://help.ubuntu.com/community/VMware/Workstation/NativeVirtualMachine. Unfortunately, this may not be possible with a free version. – tcovo Mar 21 '12 at 19:57
  • @tcovo Thanks for the link. But it seems that I still need to reboot when I use Windows. I should state it clearly that I'd like use Native Windows in an un-native way in Ubuntu, or can it? – YankeeWhiskey Mar 21 '12 at 20:48
  • 1
    The article describes how to set up a Windows XP installation on a partition such that it can be used for native Windows booting _as well as_ for running in a virtual machine. This might even be more than you need. If you don't ever need to boot Windows natively anymore, you might want to consider [VMware Converter](http://www.vmware.com/products/converter/), if you haven't already. It lets you convert a physical machine into a virtual machine. – tcovo Mar 22 '12 at 13:50

3 Answers3

12

Yes, I did this long ago following this guide:

https://lists.ubuntu.com/archives/ubuntu-us-nm/2008-February/000521.html

of course, always backup and be careful!

Essentially:

  1. Used a USB 3.5 HD enclosure and connect the XP drive to it.

    If the drive was shutdown uncleanly you may need to manually 
    

mount it with the following command.

   sudo mount ntfs-3g /dev/whereyourdriveis /mount/somemountpoint -o 

force

   Once the drive is mounted under linux contiunue to step 2.
  1. Launch VMWare.
  2. Go to File -> New -> New Virtual Machine.
  3. Select "Custom"
  4. Select Next
  5. Select your operating system (i.e. Win XP)
  6. Select Next
  7. Give it a name like "WindowsXP"
  8. Select Next
  9. Specify processor One or Two
  10. Select Next
  11. Choose public or private (on a single-user machine this doesn't matter)
  12. Select Next
  13. Select the memory to devote to the virtual machine. 512 MB is a pretty useful number.
  14. Select your network connection
  15. Select Next.
  16. Leave SCSI set to BusLogic
  17. Select Next
  18. Select Use Physical Disk
  19. Select Next
  20. Select Use Entire Drive
  21. Select Next
  22. Specify the place to save the VM
  23. At this point you're done Select Power On to boot the Physical drive in VMWare!

More Info: I should add, I have successfully done this, but I also had success using this method years even years before. So there are at least two known and tested ways for accomplishing this that I can tell you.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
TryTryAgain
  • 7,632
  • 11
  • 46
  • 82
11

You can do this via VirtualBox raw disk access. (http://www.virtualbox.org/manual/ch09.html) It basically creates a "virtual" disk file that points to the actual partition and loads it as a disk drive in the VM. I've installed Linux guest in VB on Windows host in such a way, and the installation can boot from the VM or by itself.

jianglai
  • 401
  • 5
  • 13
2

As answered, this also can be done in VirtualBox, this is the way that works for me

Always, make sure that you are running as Administrator(Windows) or Sudo(Linux), any changes that you do will write to the REAL disk, so be carefull

In Windows

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe internalcommands createrawvmdk -filename "E:\virtualbox\linuxhd.vmdk" -rawdisk "\\.\PhysicalDrive1"
RAW host disk access VMDK file E:\virtualbox\linuxhd.vmdk created successfully.

In Linux

$ VBoxManage internalcommands createrawvmdk -filename "~/linuxhd.vmdk" -rawdisk "/dev/sda"

It will create a file with something around 1kb that is a link to the physical hard drive.

Then create a Virtual Machine as ever you do.

If you want to map only a partition

At Windows

\\.\Physicaldrive1 -partitions 1

(Disk start with 0, partitions with 1)

At Linux (Much more intuitive)

/dev/sda1
/dev/sda2
etc.

Eventually you can get resolution issues

Eventually you can get resolution issues even after install vboxadditions, in my experience the problem is your /etc/X11/xorg.conf it is configured to your specific real hardware specs(I have a offboard GPU for example), least in my case I solve it simply removing this file (xorg auto configure at boot, only will not work if you set some specific setting), so run:

sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.original && sudo rm /etc/X11/xorg.conf

Reference

deFreitas
  • 4,196
  • 2
  • 33
  • 43
  • In Linux, user should be in `disk` group to be able to access raw partitions https://unix.stackexchange.com/questions/284704/verr-access-denied-when-trying-to-add-a-raw-disk-to-virtual-box#399354 – Meraj al Maksud May 28 '22 at 10:34