How To Run VirtualBox using a Physical Partition using Ubuntu Feisty Fawn
Posted by Kim Nguyen on December 6, 2007
One of the new features in VirtualBox 1.5.0, is it’s ability to virtualize an existing partition without creating a virtual hard disk. This is achieved using .vmdk files.
Creating the .VMDK File
Reading VirtualBox’s manual specifically section 9.9, we are instructed to use the the following command to create a VMDK file for your whole partition:
VBoxManage internalcommands createrawvmdk -filename <Absolute Path to output File> -rawdisk /dev/sda -register
However, the manual states that read/write permissions to the device are required. If you run the command above you will get the following output from the terminal.
VirtualBox Command Line Management Interface Version 1.5.0
(C) 2005-2007 innotek GmbH
All rights reserved.
Error opening the raw disk: VERR_ACCESS_DENIED
The First thing I tried was to run the command using sudo. This worked but it created the .vmdk file that could only be accessed using root. Sticking true to the axiom of running as little as humanly possible as root or sudo, I did what any good techie would do, searched the Internet.
Searching though the VirtualBox Forums found these two threads:
http://forums.virtualbox.org/viewtopic.php?t=1565&highlight=raw+disk+access
http://forums.virtualbox.org/viewtopic.php?t=333&highlight=createrawvmdk
Both Posts deal with setting permissions, but since I am still a little bit unsure of how the chmod function works I decided to go with the first link and I entered the following command in the terminal:
sudo usermod -a -G disk <username>
After this Command successfully completes you will need to log off you system. Once logged back in you re-run the command and you will get the following output in the terminal window:
VirtualBox Command Line Management Interface Version 1.5.0
(C) 2005-2007 innotek GmbH
All rights reserved.
RAW host disk access VMDK file /home/kimchi/test.vmdk created successfully.
Special Considerations for Windows Operating Systems:
All versions of Windows:
IO APIC and VT-x/AMD-V both need to be enabled to run a Windows Guest Operating System. These options can be found in your virtual Machine Settings on the advanced tab
Windows XP:
Before you boot to your windows partition I highly recommend you create a second hardware profile. Why you ask? Well the first time I decided to try this i overlooked the fact that VirtualBox would install it’s virtual drivers, and after installing it’s drivers and loading the guest additions, i was not able to use my keyboard if i booted directly to my windows XP operating system. It appears as if my USB mouse worked so I’m guessing that a USB keyboard will work also but since I am testing this on my laptop that isn’t a viable option.
Windows Vista:
Windows Vista does not allow you to create hardware profiles, so loading the guest additions will cause the same issue as it does in windows XP. I do not recommend using the guest additions if you are running your virtual machines on a laptop or a system that doesn’t have a USB mouse or keyboard.
Pete said
Nice walk-through. I’m still fighting with a 0×0000007b stop error when I boot XP w/in VirtualBox, but I think that’s a matter of figuring out how to get the VBox SCSI driver installed in the additional hardware profile I created in XP.
One suggestion… I’m using the -partitions and -mbr options to give the VM access only to the XP partition and to provide a custom MBR. This way, the VM boots directly into XP, rather than going through grub, and I don’t have to worry about accidentally virtualizing my Ubuntu host OS.
Kim Nguyen said
Thanks, For Some Reason I could never get the -mbr function to work correctly, if i did it would be included on this how to. If you get it to work please let me know your steps so I can add it
Pete said
This thread on the VirtualBox user forums pointed me in the right direction.
I installed the “mbr” package from the Ubuntu repos, and then used it to generate a fake MBR file. Then:
I got the stop error straightened out as well, and have been successfully virtualizing my XP partition for a week now.
Rich said
Hey How did you sort out the stop error? I am having the same error.
Kim Nguyen said
Which Stop Error are you refering to? Is it the Error opening the raw disk: VERR_ACCESS_DENIED error? This is a permissions issue with the user and the disk. The write up says to use this command sudo usermod -a -G disk
Michael Quinn said
Pete – could you please post how you got rid of the stop error? I keep getting a blue screen with the error 0×0000007B, as you described.
Kim -
Thanks for the article!
Michael Quinn said
Nevermind, I figured it out by following the link you posted =)
You need to download and run the MergeIDE program available at http://www.virtualbox.org/attachment/wiki/Migrate_Windows/MergeIDE.zip
Rich said
Sorry…. The Stop error. Actually I am getting a different stop error now (0X00000050).
Peter Selc said
Hi, just wanted to be sure before damaging my data
Is it safe to run the “guest” windows XP from linux using different hardware profile, but also to boot into windows directly? Will then the original hardware profile be used?
Thanks,
Peter
Kim Nguyen said
Hi Peter,
I have had mixed issues with this. The first time I created a Hardware profile it overwrote both profiles. The second time I did this it worked. The only thing I did different was to create the profile before did anything in VirtualBox.
I can’t say the process is safe and I have had to reinstall windows multiple times on my laptop so I would say try at your own risk.
Junior said
Well, I did everything in your guide, and all went ok, accept from that when I start the embedded xp, the screen is just blank, no errors, nothing…It seems it’s unable to boot my xp partition. Any ideas why? Does it miss some grub boot loader or something?
Kim Nguyen said
I had the same problem first time i loaded up. Make sure the IO APIC and VT-x/AMD-V options are enabled on the windows guest settings.
Ric Smith said
I am really interested in booting my raw Windows XP partition in Ubunutu, but have some concerns about stability. Has your installation remained sound since your success with this configuration?
Pete said
Ric, I’ve been running this setup for about four months now, with no stability or data corruption issues. YMMV, of course, but it’s been fine for me both running the XP partition as a guest in Virtualbox *and* booting the XP partition natively.
Sam said
I’m having a problem here. After instqalling the fake MBR, if I try to boot, I get the error “A disk read error occurred Press Ctrl+Alt+Del to restart”
Any clues?
My fdisk -l is
$ sudo fdisk -l /dev/sda
Disk /dev/sda: 100.0 GB, 100030242816 bytes
240 heads, 63 sectors/track, 12921 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Disk identifier: 0xed6bed6b
Device Boot Start End Blocks Id System
/dev/sda1 * 1 4063 30716248+ 7 HPFS/NTFS
/dev/sda2 5419 5696 2101680 82 Linux swap / Solaris
/dev/sda3 4064 5418 10243800 83 Linux
/dev/sda4 5697 12921 54620969 f W95 Ext’d (LBA)
/dev/sda5 5697 10623 37246702+ 83 Linux
/dev/sda6 10624 12921 17372848+ 7 HPFS/NTFS
Zone of Mr. Frosti » Blog Archive » Jamiroquai Was Right said
[...] I was going to have to do some heavy reading in the throne room. Instead, I got VirtualBox up and running my existing Windows partition in about 10 minutes. I created a new hardware profile in Windows, and reactivated my product since [...]
Fendetestas said
@sam: I’m seeing the same error. This is my partition list:
Disk /dev/sda: 40.0 GB, 40007761920 bytes
240 heads, 63 sectors/track, 5168 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Disk identifier: 0xcccdcccd
Device Boot Start End Blocks Id System
/dev/sda1 * 1 1900 14363968+ 7 HPFS/NTFS
/dev/sda2 1901 1918 136080 83 Linux
/dev/sda3 1919 5168 24569969 f W95 Ext’d (LBA)
/dev/sda5 1919 3139 9230728+ 83 Linux
/dev/sda6 3140 5029 14288368+ 83 Linux
/dev/sda7 5030 5168 1050808+ 82 Linux swap / Solaris
I used the following command to create the vmdk:
VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/sda.vdmk -rawdisk /dev/sda -partitions 1,2 -register
I have GRUB installed in /dev/sda2. The GRUB menu appears without problems, but Windows XP does not start, printing the same error as yours.
The problem seems to reside in the windows boot code, as my linux partition boots in the VM without problems (other that not finding its root filesystem
The same error appears when I create the vmdk for the whole disk without the partitions parameter, and when using the fake MBR generated with the “install-mbr ./mbr -f -p 1″ command.
Regards,
Fendetestas said
-register
I have GRUB installed in /dev/sda2. The GRUB menu appears without problems, but Windows XP does not start, printing the same error as yours.
The problem seems to reside in the windows boot code, as my linux partition boots in the VM without problems (other that not finding its root filesystem
The same error appears when I create the vmdk for the whole disk without the partitions parameter, and when using the fake MBR generated with the “install-mbr ./mbr -f -p 1″ command.
Beau Newcomb said
This is a great tutorial and worked for me overall, but strangely, Windows hangs for a long long time (like, a half hour to an hour) at the boot screen. Just as the Windows logo starts to fade in, it hangs at about 50% opacity and will sit there… if i leave the VM running and check it later, the desktop is up. is there a way i can see what’s going on??
mjw said
I created a second hardware profile in WinXP BEFORE booting the VM with virtualbox and using that HW profile. However, windows then tries to install all sorts of hardware and cannot find drivers. Also the mouse does not work in the VM
Any thoughts? Should I install the drivers prior to booting with the VM? Where should I get the drivers?
Anton Andreev said
1. OK, is it worth the performance gain?
2. Can I do that on my laptop that has no hardware virtualization – Turion 64?
10x Anton
Firefishe said
I used the fake mbr method via the install-mbr package, but I still have the blue screen of death, then the entire vm reboots.
I bypass GRUB, at least, and get my windows startup splash screen for a split second, then get the blue screen, but it isn’t up long enough to see what the error is. How do I see this screen?
dexterlb said
I have another problem – the USB mouse does not work. Neither any other USB devices. In the USB devices list both my USB mouse and cam are inactive. Has anyone encountered it?
netmma said
Thanks for the write-up. I followed this to run Windows XP installed on a different partition via VirtualBox (1.6) in Ubuntu Hardy. I get to the Windows Splash screen and then it is just stuck there. Is there a place I can check some kind of a log to see what it is waiting for?
/Mahesh
jjhunt said
I have been getting the 0×0000007B Stop error for a few days now. I created a second hardware profile in xp. I’ve used the mbr and can get the xp splash screen. I’ve also done the IDE merge trick, but still get the stop error. Anyone have an idea?
Running existing Windows in VirtualBox on Ubuntu « anderstornvig.dk said
[...] able to find any thorough guide anywhere. I have to give a lot of credit to Kim Nguyen, who has the best article on the subject I’ve been able to find. Other information in this guide is compiled from the [...]
Brian L said
I tried this with virtualbox 2.0 on ubuntu hardy and I can’t get it working. I’m trying to use an existing XP partition. XP is on /dev/sda1, Vista installed on /dev/sda2. The normal boot process for the computer is grub (on the ubuntu partition /dev/sda5), then vista’s boot menu. I created the .mbr file with the mbr package, then created the vmdk with the VBoxManage command, including both partitions (xp and vista). When I run the virtualbox software and put everything together, though, I am shown vista’s boot menu, then whether I choose vista or xp, I get “windows failed to start. a recent hardware or software change might be the cause”. I’ve enabled IO APIC, but vt-x is greyed out. Is it not possible to run windows xp without vt-x?
Kelvin M said
When I start XP, I get the XP loading screen then for a split second after I get a blue screen and the VM restart, unfortunately I’m not quick enough to pause the VM to see the blue screen error message, anyone know whats going on?
Chris B said
When I follow the instruction I get this error, I search on the web but found no instances of anyone else with this problem:
chris@chris-desktop:/$ VBoxManage internalcommands createrawvmdk -filename /home/chris/.VirtualBox/WinXP.vmdk -rawdisk /dev/sda
VirtualBox Command Line Management Interface Version 2.0.4
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.
Error opening the raw disk ‘/dev/sda’: VERR_MEDIA_NOT_PRESENT
The raw disk vmdk file was not created
Am I missing something?
Does anyone know how to fix this?
Thanks
Jos de Kloe said
The following command:
VBoxManage setextradata VMNAME “VBoxInternal/PDM/HaltOnReset” 1
will halt the virtual machine “VMNAME” after a blue screen appears, so that you will have time to read it.
See also the virtualbox usermanual section 11.2.3 (pages 134/135 for manual version 2.0.4).
Good luck,
Jos.
Oracle said
Hey Anton had a question about AMD Turion based notebooks and doing this. I have the same type of processor and was wondering if this would work since (i believe) they don’t have virtualization support? Can anyone confirm?
(ot) MediaMonkey u otros organizadores de musica? - Página 3 | hilpers said
[...] no entendiste
? Para hacer eso hay que usar vdmk. Mírate cómo lo hacen aquí: http://blarts.wordpress.com/2007/12/…u-feisty-fawn/ pero si quieres un consejo, yo no intentaría arrancar una partición existente de windows con [...]
David said
I seem to have a problem with booting of the drive.
Aldo I tryed many ways to build the vmdk:
*-partitions 0,1
*-partitions 1
*no -partitions
*-mbr …
*no -mbr …
The problem is always the same:
*with -mbr it it boots up saying: MBR FA:
pressing a then 1 says Disk Read Error…
pressing a then 2..4 shows MBR FA: again
pressing a then 5.. locks up
*without -mbr all the combinations boot up the same:
“FATAL: INT 18: FAILURE”
To Specify: I have a dual boot Vista and Ubuntu the drive is /dev/sdb ( vista is sdb1 )
Also read this tutorial here: http://mesbalivernes.blogspot.com/2008/01/virtual-box-booting-from-existing.html
Solved all permission problems so that’s not it…
I think it’s because somehow the the disk is not seen as bootable.
PS: I haven’t restarted the laptop all night and now I’m kinda afraid of a grub problem due to all of this tinkering.
If any have constructive ideas and links to these issues please mail me at bodo2all yahoo com
Mark said
Great tutorial overall! Am wondering, does Virtual Box have superuser permissions only on the XP partition, or on the entire disk? This could basically undo a major reason for having linux in the first place…thanks!
Flamburt said
Can anyone publish their experience with solving the BSOD issue?
I see a number of posts related to this, and I myself am experiencing the same Blue Screen. XP boots in Safe Mode (with Networking).
Thanks.
Windows Vista in Virtualbox - openSUSE Forums said
[...] What I was asking that whether I can use the existing windows partition itself to create the image till now I thought this was not possible in VirtualBox, but I found something on Google that might be interesting How To Run VirtualBox using a Physical Partition using Ubuntu Feisty Fawn « Blarts [...]
Jippie said
Adding a user to the disk group is a bad idea because this user will have unlimited access to *any* disk or logical volume, also your root volume and therefore that user will have total control over the whole machine.
A better way is to change the ownership on your disk or logical volume. I myself use logical volumes and I create a udev rules file to change permissions on LV containing my webserver.
Please do refer to my web page on this:
http://webserver/mediawiki/index.php/VirtualBox:_migrate_vdi_based_machine_to_Logical_Volume_(LV)_based_machine#Export_current_vdi_disk_to_LV_.28vmdk.29
Body Of Knowledge: Virtualbox said
[...] [http://blarts.wordpress.com/2007/12/06/how-to-run-virtualbox-using-a-physical-partition-using-ubuntu...] An all VirtualBox solution [...]
SeanG said
This is very helpful — thank you!!
One note: I was able to get by without enabling the “VT-x/AMD-V” flag (Ubuntu 9.04, Jaunty Jackalope) — which is good, because it was grayed out!
Graham said
I’m working on a reliable and repeatable way of doing just this.
You can see the progress at http://grahams.free-online.co.uk/winxpvmconvert.html
I have a number of “used” WinXP installations and intend to make this work for the average WinXP user.
Comments welcome too.
Graham said
Hi,
If anyone’s interested I’m trying to make a howto for this.
It’s at http://grahams.free-online.co.uk/winxpvmconvert.html.
Still a work in progress, but the page links to other sites trying to solve the same problem.