I freshly arrived in a new working environment and the first thing I did was to run an Ubuntu Linux instead of Windows. However some things are only accessible under Windows so I googled a bit in order to find an easy way to boot Windows XP from my existing Windows partition which comes by default with the PC we have here.
So this is possible with virtual box 1.5.4 which can be downloaded from here and this is generally called booting from a raw partition.
Once virtual box installed, you can use the tool VBoxManage to create a disk image (vmdk) pointing to your partition.
RAW host disk access VMDK file ./WinXP.vmdk created successfully.
my-desktop:>
Note that if you also want to directly register your image to VirtualBox you can also use the -register option.
The previous VBoxManage command will work but is extremely dangerous as in the virtual machine, you have access to all your partitions and you could inadvertently boot the host OS as a guest OS (the host being Ubuntu in my case) !!!
This could create incurable damages to your installation so the solution to avoid that is to create the disk image and restricting it only to the windows partition.
You will also have to create in a file a new master boot manager which will concern only the windows partition and use the new mbr to create the disk image.
1) Create a Master Boot Record manager in a file
To do this you need to use install-mbr which is part of the Debian package mbr and call install-mbr with the --force option:
The produced file myBootRecord.mbr should be 512 bytes.
2) Call VBoxManager with the right options
First we need to know which is our WinXP Partition:
For me it is the partition number 1. Here is the magic command:
Now we have a virtual disk call WinXP.vmdk which will allow us to boot our existing partion.
3) Use the VirtualBox GUI to create a new Virtual Machine Profile
Now let's launch VirtualBox to create and configure a Virtual Machine.
The first thing to do is to use the Virtual Disk Manager to add the newly created disk:
Now, let's create a virtual machine with this new disk:
Finally you will have to tweak the options and especially tick the Enable IO APIC value:
4) The Conclusion
If you are lucky you should then be able to run WinXP and access all the network disks already configured by your wonderful Win Admin => Good !!
Note that you should create another Hardware profile in WinXP to not confuse it too much as the virtual machine might comes with some cruder hardware devices (sound card, graphic card, etc).
There could also be an issue regarding the write permssions on your "hard drive" if you want to run your Virtual Machine as a standard user. You might need a chmod 777 /dev/sda with /dev/sda unmounted.
5) References
Here are the two threads which helped me find a solution for my problem
http://forums.virtualbox.org/viewtopic.php?t=333&highlight=createrawvmdk
http://forums.virtualbox.org/viewtopic.php?t=2019
So this is possible with virtual box 1.5.4 which can be downloaded from here and this is generally called booting from a raw partition.
Once virtual box installed, you can use the tool VBoxManage to create a disk image (vmdk) pointing to your partition.
#>VBoxManage internalcommands createrawvmdk -filename ./WinXP.vmdk -rawdisk /dev/sda
VirtualBox Command Line Management Interface Version 1.5.4
(C) 2005-2007 innotek GmbH
All rights reserved.
VirtualBox Command Line Management Interface Version 1.5.4
(C) 2005-2007 innotek GmbH
All rights reserved.
RAW host disk access VMDK file ./WinXP.vmdk created successfully.
my-desktop:>
Note that if you also want to directly register your image to VirtualBox you can also use the -register option.
The previous VBoxManage command will work but is extremely dangerous as in the virtual machine, you have access to all your partitions and you could inadvertently boot the host OS as a guest OS (the host being Ubuntu in my case) !!!
This could create incurable damages to your installation so the solution to avoid that is to create the disk image and restricting it only to the windows partition.
You will also have to create in a file a new master boot manager which will concern only the windows partition and use the new mbr to create the disk image.
1) Create a Master Boot Record manager in a file
To do this you need to use install-mbr which is part of the Debian package mbr and call install-mbr with the --force option:
#> apt-get install
#> install-mbr --force myBootRecord.mbr
The produced file myBootRecord.mbr should be 512 bytes.
2) Call VBoxManager with the right options
First we need to know which is our WinXP Partition:
#>fdisk -l /dev/sda
Disk /dev/sda: 82.3 GB, 82348277760 bytes
255 heads, 63 sectors/track, 10011 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xf3c1f3c1
Device Boot Start End Blocks Id System
/dev/sda1 * 1 2623 21069216 7 HPFS/NTFS
/dev/sda2 2624 9704 56878132+ 83 Linux
/dev/sda3 9705 10011 2465977+ 5 Extended
/dev/sda5 9705 10011 2465946 82 Linux swap / Solaris
Disk /dev/sda: 82.3 GB, 82348277760 bytes
255 heads, 63 sectors/track, 10011 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xf3c1f3c1
Device Boot Start End Blocks Id System
/dev/sda1 * 1 2623 21069216 7 HPFS/NTFS
/dev/sda2 2624 9704 56878132+ 83 Linux
/dev/sda3 9705 10011 2465977+ 5 Extended
/dev/sda5 9705 10011 2465946 82 Linux swap / Solaris
For me it is the partition number 1. Here is the magic command:
#>VBoxManage internalcommands createrawvmdk -filename ./WinXP.vmdk -rawdisk /dev/sda -partitions 1 -mbr ./myBootRecord.mbr -relative -register
VirtualBox Command Line Management Interface Version 1.5.4
(C) 2005-2007 innotek GmbH
All rights reserved.
VirtualBox Command Line Management Interface Version 1.5.4
(C) 2005-2007 innotek GmbH
All rights reserved.
Now we have a virtual disk call WinXP.vmdk which will allow us to boot our existing partion.
3) Use the VirtualBox GUI to create a new Virtual Machine Profile
Now let's launch VirtualBox to create and configure a Virtual Machine.
The first thing to do is to use the Virtual Disk Manager to add the newly created disk:
Now, let's create a virtual machine with this new disk:
Finally you will have to tweak the options and especially tick the Enable IO APIC value:
4) The ConclusionIf you are lucky you should then be able to run WinXP and access all the network disks already configured by your wonderful Win Admin => Good !!
Note that you should create another Hardware profile in WinXP to not confuse it too much as the virtual machine might comes with some cruder hardware devices (sound card, graphic card, etc).
There could also be an issue regarding the write permssions on your "hard drive" if you want to run your Virtual Machine as a standard user. You might need a chmod 777 /dev/sda with /dev/sda unmounted.
5) ReferencesHere are the two threads which helped me find a solution for my problem
http://forums.virtualbox.org/viewtopic.php?t=333&highlight=createrawvmdk
http://forums.virtualbox.org/viewtopic.php?t=2019
41 comments:
This looks the answer I have been seeking for months. I'm not a Sys
Admin, a programmer, or well versed in Linux, either. I do have two machines with Kubuntu installed, and need to use WinXP for some proprietary applications.
If I understand correctly, I would install XP, then Linux. After which,
I would install VB under Linux. The, I would follow the above
directions to create a "raw" partition, using the partition XP was
installed on. This method would not allow a VB user to access the host,
or Linux in this case, partition, which probably would destroy the data
contained on it.
Using this method, can I go back and forth from XP to Linux? In other words, can I have VB open and minimized, and continue working in Linux? What if I were downloading a somewhat large file in Linux, would I be able to use XP in the VB at the same time? It just seems that 2 systems attempting to access the same disk at the same time wouldn't work.
Thanks for taking the time to document what you've achieved, and posting it. I appreciate it.
Hi,
I am glad if that helps somebody ;-)
Now to answer your questions, let's say that you already have a windows installed on your machine and that you would like to use it under Linux.
In that case you can follow this little recipe to see your Windows from Linux under virtualbox.
If you don't have windows already installed on your machine, the best is probably to install Windows from scratch within virtualbox (exactly as if you would install Win XP on a new machine but here it is under VB).
Then after you can use both operating systems seamlessly. to simplify, 2 OS accessing the same disk is no more than 2 programs accessing the same disk, it is perfectly ok.
Note that there are also other virtualization programs like VMWare for example.
The problem is, I have a Tablet PC. There isn't a separate install media available for them, unless you have an enterprise license.
All anyone gets with a Tablet PC is a recovery cd. The CD's check the BIOS for machine ID. VB won't let the OS "see" the BIOS. And there are other issues, as well.
I've tried so many methods, I've slipstreamed with an XP Pro sp2 cd, I've made an iso out of an installation, I've tried individually installing modules, and installing from the i386 folder, etc. Nothing has been successful. I've followed even Microsoft's kb articles for sys admins, nothing.
The best I have been able to get is the Tablet PC Edition WinXP installed without the Tablet superset.
So, when I saw your post on VB, I thought this might be an answer I hadn't tried yet. Although, I've been told that it would be very easy to wipe out my Linux partition id I did it.
Thanks again for the post.
Thanx for the guide.
Some comments:
1) When creating the .vmdk with VBoxManage I go errors containing "VERR_FILE_NOT_FOUND". I was corrected using full path to the (new) .vmdk and the myBootRecord.mbr.
2) It is not really clear that you describe 2 different method... the second one being more safe. Maybe a better separation could be used?
3) Trying to boot WinXP from VirtualBox, I get BSOD without usefull information...
*** STOP: 0x0000007B (0xF894C524,...
Me again, I was able to boot! What I needed was to boot windows normally, then execute the MergeIDE .bat and .reg from http://www.virtualbox.org/wiki/Migrate_Windows
This disable a search for IDE drives, which was the cause of the BSOD.
Rebooting into linux and then launching VirtualBox allowed me to boot windows. I just need to activate this windows...
Me again-again...
For activation, please read this:
http://mazimi.wordpress.com/2007/07/11/getting-around-windows-activation-when-virtualizing/
The script work for vmware... it could be adapted for virtualbox
Hi big_gie,
thanks for the comments. I haven't encountered any of the problems you are mentioning but I will try to update my how to as soon I a bit of time.
Will this work with Vista?
John Hayward
I follow the instructions and end up with the following output from your 'magic' command. Could this be because it is not Vista but XP?
RAW host disk access VMDK file ./WinXP.vmdk created successfully.
[!] FAILED calling aVirtualBox->OpenHardDisk(filename, hardDisk.asOutParam()) at line 640!
[!] Primary RC = 0x80004005
[!] Full error info present: true , basic error info present: true
[!] Result Code = 0x80004005
[!] Text = VD: error opening image file '/root/.VirtualBox/WinXP.vmdk' (VERR_FILE_NOT_FOUND)
[!] Component = HardDisk, Interface: IHardDisk, {fd443ec1-000f-4f5b-9282-d72760a66916}
[!] Callee = IVirtualBox, {76b25f3c-15d4-4785-a9d3-adc6a462beec}
John
Hi,
I've never tried to boot Vista because I don't own a Vista :-(
Ok for your problem, it seems to me that the file has not been found ? Are you sure that the full path is correct.
Please put the output of the full command maybe it will be clearer.
In order to have it working you also might have to run mergeide.
see:
http://www.virtualbox.org/wiki/Migrate_Windows
and
http://mazimi.wordpress.com/2007/07/11/getting-around-windows-activation-when-virtualizing/
Errata:
sudo apt-get install mbr
The magic command does not work with VirtualBox 1.6:
Syntax error: Invalid command 'createrawvmdk'
Any ideas?
Thanks for this how-to. It helped me create a tutorial on how to boot an existing partition of Windows XP:
http://ubuntuforums.org/showthread.php?t=769883
@Anonymous:
It sounds like you're using the open source version of VBox. For some reason, only the closed source version has that command.
you're welcome,
that is the power of the web no.
I think I will have to update this how to very soon as there is a new version of VirtualBox
Is it still possible to boot the Windows as a standalone system?
Or can you only run it with VirtualBox?
This worked for me. Thank you! I had much trouble with the Ubuntu thread by Sand Lee.
Mr. Lee does not point out these serious issues as you have. (I had to do a freash install with Mr. Lee's instructions.)
You have written this "how to" in a most professional and complete tutorial.
My hat is off to you sir!
Before I go ahead and try this, I'd also like to know if I can continue to boot directly from my XP partion?
Thanks!
Thanks Ronald
Very happy to help.
I've written this little post because I myself struggled a lot to find the right info and the right procedure
I will try to update this post when I will do it again on my laptop with the latest version of Virtual Box.
Cheers Guillaume
Hi Steeve,
Sorry but I was away on holiday.
On my computer I can still boot directly on windows so I guess that it should work for you.
Cheers Guillaume
Hi,
Im using Fedora7 and dont have install-mbr. Can u suggest a way to create the winxp.mbr file in fedora?
thanks
Note that the open source version of VirtualBox does not contain the commands you need to do this. You can download the free personal edition from Sun's web site.
is this possible to do with Windows Vista?
Hi Seth,
I guess so but I never tried with vista
If you are successful please let me know
I did everything, but i'm getting an error. Any ideas? Unmounting the partion does not help:
~$ VBoxManage internalcommands createrawvmdk -filename ./WinXP.vmdk -rawdisk /dev/sda -partitions 1 -mbr ./myBootRecord.mbr -relative -register
VirtualBox Command Line Management Interface Version 2.1.0
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.
Error opening the raw disk '/dev/sda': VERR_ACCESS_DENIED
The raw disk vmdk file was not created
Cancel that, I just had to prefix sudo to the command.
Sorry (Slaps himself on the forehead)
I did get some more errors on registering, but it says that the vmdk was created successfully.
Ok this time it's more difficult. When creating the vdmk, i got the following output:
VirtualBox Command Line Management Interface Version 2.1.0
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.
RAW host disk access VMDK file ./WinXP.vmdk created successfully.
[!] FAILED calling aVirtualBox->OpenHardDisk2(filename, hardDisk.asOutParam()) at line 1250!
[!] Primary RC = VBOX_E_IPRT_ERROR (0x80BB0005) - Runtime subsystem error
[!] Full error info present: true , basic error info present: true
[!] Result Code = VBOX_E_IPRT_ERROR (0x80BB0005) - Runtime subsystem error
[!] Text = Could not get the storage format of the hard disk '/root/.VirtualBox/WinXP.vmdk' (VERR_FILE_NOT_FOUND)
[!] Component = HardDisk2, Interface: IHardDisk2, {ed6e2525-c2fd-42a4-917a-7a9045ac9e15}
[!] Callee = IVirtualBox, {339abca2-f47a-4302-87f5-7bc324e6bbde}
So it didn't get registered. But I went ahead and fired up VirtualBox, and tried to create the machine. at the media selection, i went to add the vdmk. I have two files as output from the above:
WinXP-pt.vmdk
WinXP.vmdk
Trying to add either one of them in the Media Manager gives the following:
Could not open the hard disk '/home/swiftarrow/VMDK/WinXP-pt.vmdk'.
VD: error opening image file '/home/swiftarrow/VMDK/WinXP-pt.vmdk' (VERR_ACCESS_DENIED).
Result Code:
NS_ERROR_FAILURE (0x80004005)
Component:
HardDisk2
Interface:
IHardDisk2 {ed6e2525-c2fd-42a4-917a-7a9045ac9e15}
Callee:
IVirtualBox {339abca2-f47a-4302-87f5-7bc324e6bbde}
Same for the other file.
I noticed that they were owned by root only, so I chown'ed them. Still get the same error. I regenerated the vdmk, but still continue to get this error.
Is there something I'm missing?
Im on XUbuntu Intrepid, up to date, with the latest Virtual box, in 64 Bit. I have installed 32 bit Windows XP. Could that be the problem?
Any help is very gratefully accepted, i would dearly love to get this working.
With the help from this post:
http://blarts.wordpress.com/2007/12/06/how-to-run-virtualbox-using-a-physical-partition-using-ubuntu-feisty-fawn/
i got it booting, but i was unable to do the partition thing. It's booting the entire disk.
@Swift Arrow,
Happy to see that you managed to boot your windows XP partition (even if you had to map the entire disk).
I think that you had an ownership issue and you needed to add yourself in the disk and vboxusers groups:
sudo usermod -G disk,vboxusers -a USERNAME_HERE
This should solve the (VERR_ACCESS_DENIED) issues.
VBoxManage internalcommands createrawvmdk -filename ./WinV.vmdk -rawdisk /dev/sda -partitions 1 -mbr ./myBootRecord.mbr -relative -register
VirtualBox Command Line Management Interface Version 2.0.4_OSE
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.
Error while creating the raw disk VMDK: VERR_ALREADY_EXISTS
Please help?
I was trying to link my vista using this method, but i get this error, what am i doing wrong?
The howto is written wrong. Do NOT execute first command. It will make the vmdk file already, and when you execute second, you run into this VERR_ALREADY_EXISTS error. Make sure you dont already have .vmdk file in same folder when you execute command. Have fun. Thanks to erstazi @ freenode irc #vbox, for this update.
His comment:
To Harold,
You have to follow the instructions from step 1) to 4) to have it working properly. Gostovanje is right you probably have executed the command createrawvmdk. before that. Just delete the .vmdk file and start again.
To Gostovanje, the howto is not wrong as the beginning of the article explains what is wrong when you create a .vmdk mapping all your disk with createrawvmdk.
Hi,
Thanks for this post. It is exactly what I'm looking for, but unfortunately I can't get it to work.
After creating a new machine as described in step 3 I get the following error when I try step 4:
MBR
FATAL: NMI Handler called
This error appears in the VB window right after the Sun post screen, before the Windows loading screen.
Do you know what might be causing this?
Cheers
Van
hi the information shared is very useful i tryed it to boot xp and i was able to do so
now i am trying the same thing for vista but am having a big problem booting it
when i follow the first method (without mbr) it is works fine but when i try second method i cant boot the win
i have created vmdk successfully and attached it to my vista but when i try to boot my vista i get following message
"
Windows boot manager
windows failed to start. a recent software or hardware change might be the cause. to fix the problem:
1. insert your windows installation disk and restart your computer
2. choose your language settings and click next
3. click "repair your computer."
if you do not have this disk, contact your system administrator or computer manufecturer for assistance
file: \windows\system32\winload.exe
status: 0xc000000e
info: the selected entry could not be loaded because the application is missing or corrupt
"
can anyone help me
interesting article
Hi, Thanks for this post.
I tried the steps but omitted the MBR steps. XP boots from the VB Window (Ubuntu host). XP's "Preparing Network Connections" window shows up, then the System BSODs...
I can boot into "Safe Mode with Networking".
Can anyone comment on what to do?
I just do it following the howto. My question is when i start the window from VB, the process just stop with MBR output.
Why and how to resolve this problem.
I am running fedora and I do have apt installed, however, I cannot get install-mbr at all. I have tried
apt-get install mbr
and it does not exist.
What can I do at this point?
To get the Fedora version of mbr :
# yum install ms-sys
Thanks so much for this tutorial.
One trick I've noticed on a couple laptops (HP nc6000-something and thinkpad X60): you need to edit the vmdk file in a text editor and change biosHeads="255" from 255 to 240. Something (that I don't fully understand) to do with drive geometry and the way that the 2.6 kernel reports it.
Before making this change, I would get "MBR A disk read error has occured."
Changing the biosHeads worked for me - thanks Blaise!
Post a Comment