WIndows guest with raw disk - can't make it work

Discussions about using Windows guests in VirtualBox.
Post Reply
MidnightJava
Posts: 7
Joined: 9. Oct 2011, 05:01
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Windows 7

WIndows guest with raw disk - can't make it work

Post by MidnightJava »

I'm trying to create a Windows guest on an Ubuntu host, using a raw disk pointing to an existing Windows installation on the same system. I started off following the instructions in a post at viewtopic.php?f=28&t=33356, and also tried some ideas gleaned from other posts. When I launch the VM it fails to load Windows (currently it just displays "MBR"). This was expected per the aforementioned post, but loading a recovery disk in the VM and running bootrec /fixMBR was supposed to fix it and enable me to boot Windows either native or in the VM.

However, Windows still doesn't load in the VM after running bootrec. It wipes out grub nicely, but doesn't fix the VM Windows installation. When I boot Windows subsequently in the VM, I get an error message "A required device is not accessible". I also tried running the automated repair from the recovery disk in the VM. This fails to fix the VM Windows, and has the added benefit of making Windows native fail to boot, which fortunately can be fixed by running auto-recovery options from the recovery disk booted natively.

I have the following partitions on my system:

Code: Select all

 sudo blkid
/dev/sda1: LABEL="SYSTEM" UUID="F8C4B13FC4B100C4" TYPE="ntfs" 
/dev/sda2: LABEL="OS" UUID="36AA701CAA6FD6C1" TYPE="ntfs" 
/dev/sda4: LABEL="HP_RECOVERY" UUID="6CEAF910EAF8D774" TYPE="ntfs" 
/dev/sda5: UUID="5ebb92a5-b015-4a90-b55a-48a521237010" TYPE="ext4" 
/dev/sda6: UUID="cebc1c17-cd2f-4ccb-be81-20f81b659957" TYPE="swap" 
/dev/sda7: LABEL="Shared" UUID="1FF344F316D8343E" TYPE="ntfs" 
/dev/sdc1: LABEL="BACKUP" UUID="7EF5-1DEE" TYPE="vfat" 
My boot-info file is also pasted at the bottom of this post.

Here's what I'm doing to create the raw disk:

I create the MBR using one or other of the following two methods separately.

1.

Code: Select all

    sudo dd if=/dev/sda of=myMBR.mbr bs=512 count=1
2.

Code: Select all

$ sudo apt-get install mbr
$install-mbr -e12 --force myMBR.mbr
Then I create the raw disk as follows

Code: Select all

VM_NAME=Windows7Raw           # name of virtual machine
sudo VBoxManage internalcommands createrawvmdk -filename /home/$USER/VirtualBox\ VMs/$VM_NAME/$VM_NAME.vmdk -rawdisk /dev/sda -partitions 1,2 -relative -mbr myMBR.mbr
Then I run the following script to launch the VM:

Code: Select all

 #! /bin/bash
# Windows 7 VM boot script for VirtualBox 4.x-- you'll have to always use it instead of running VirtualBox
VBUSER=virtualbox          # name of custom account created (which is a member of disk group)
VM_NAME=Windows7Raw           # name of virtual machine


sudo chown -R $USER:$USER /home/$USER/.VirtualBox    # make sure $VBUSER will be able to access VirtualBox settings etc.
                     # we use sudo because $VBUSER creates files with its ownership on previous runs
chmod -R g=u /home/$USER/.VirtualBox          # $VBOXUSER permissions should be the same as ours
sudo chown -R $USER:$USER /home/$USER/VirtualBox\ VMs/$VM_NAME    # ditto for VirtualBox VMs directory.
chmod -R g=u /home/$USER/VirtualBox\ VMs/$VM_NAME
xauth extract /home/$USER/cookieTmp $DISPLAY
chmod g+r /home/$USER/cookieTmp
sudo chmod g+x /home/$USER/
echo "merging"
sudo -u $VBUSER XAUTHORITY=/tmp/.Xauthority_${VBUSER} xauth merge /home/$USER/cookieTmp
rm /home/$USER/cookieTmp

sudo -u $VBUSER XAUTHORITY=/tmp/.Xauthority_${VBUSER} VBOX_USER_HOME=/home/$USER/.VirtualBox VBoxManage startvm $VM_NAME
The example above specifies partitions 1 and 2. I also tried partition 1 only, and partitions 1,2,and 3. I'm not sure which partitions I should be including, as sda1 through sda3 are part of the Windows installation. I'm also not clear on how with MBR option 1 I should specify more than one partition.

Any help would be greatly appreciated. Here is my boot-info file:

Code: Select all

                    Boot Info Script 0.60    from 17 May 2011


============================= Boot Info Summary: ===============================

 => Grub2 (v1.99) is installed in the MBR of /dev/sda and looks at sector 1 of
    the same hard drive for core.img. core.img is at this location and looks
    for  on this drive.
 => No boot loader is installed in the MBR of /dev/sdc.

sda1: __________________________________________________________________________

    File system:       ntfs
    Boot sector type:  Windows Vista/7
    Boot sector info:   No errors found in the Boot Parameter Block.
    Operating System:
    Boot files:        /bootmgr /Boot/BCD

sda2: __________________________________________________________________________

    File system:       ntfs
    Boot sector type:  Windows Vista/7
    Boot sector info:   No errors found in the Boot Parameter Block.
    Operating System:  Windows 7
    Boot files:        /Windows/System32/winload.exe /wubildr
                       /ubuntu/winboot/wubildr /wubildr.mbr
                       /ubuntu/winboot/wubildr.mbr /ubuntu/disks/root.disk
                       /ubuntu/disks/swap.disk

sda2/Wubi: _____________________________________________________________________

    File system:       ext4
    Boot sector type:  -
    Boot sector info:
    Operating System:  Ubuntu 11.04
    Boot files:        /boot/grub/grub.cfg /etc/fstab

sda3: __________________________________________________________________________

    File system:       Extended Partition
    Boot sector type:  Unknown
    Boot sector info:

sda5: __________________________________________________________________________

    File system:       ext4
    Boot sector type:  -
    Boot sector info:
    Operating System:  Ubuntu 11.04
    Boot files:        /boot/grub/menu.lst /boot/grub/grub.cfg /etc/fstab
"RESULTS4.txt" 834 lines, 31587 characters
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: WIndows guest with raw disk - can't make it work

Post by mpack »

There is a separate (in fact the original) howto that deals with running XP both in a VM and native. You should be using that instead of the Win7 howto you linked to.

Other than that, I'm afraid I consider raw disk access so dangerous that there is absolutely no way I'll help anyone use it. It's documented in the user manual as an expert level feature, meaning if you are qualified to use it then you don't need any help from me.
MidnightJava
Posts: 7
Joined: 9. Oct 2011, 05:01
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Windows 7

Re: WIndows guest with raw disk - can't make it work

Post by MidnightJava »

Well I had a look at the XP Howto, and it requires that I have a Windows VM to use as the managing VM to create source and target VDIs and then copy from the one to the other and attach the source in a new VM. However, one of the motivations for me to try raw disk access is that my HP system did not come with a WIndows installation disk, and HP does not seem ready to provide one.

So I'll modify my question. Can I use the recovery disk created from my existing Windows installation to create a Windows installation in the VM? I'd been assuming this was not an option, but maybe that's not the case. If this is not possible, then what do people generally do in this situation?
BillG
Volunteer
Posts: 5106
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: WIndows guest with raw disk - can't make it work

Post by BillG »

No, you cannot use a restore disk to load the operating system into a different computer, and a vm is just that!

Most people create a new virtual hard disk and install the OS from the Windows installation disk or an .iso file of the installer.
Bill
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: WIndows guest with raw disk - can't make it work

Post by mpack »

MidnightJava wrote:However, one of the motivations for me to try raw disk access is that my HP system did not come with a WIndows installation disk, and HP does not seem ready to provide one.
Are you sure? I'm using an HP desktop right now, they have been my employers standard PC brand for years.

I mention that because I'm looking at the HP CD bundle pack right now, there is an "HP Restore Plus!" CD, and there's another labelled "Operating System DVD" subtitled (in my case) "Windows Vista Business Service Pack 1". In fact I never used these CDs on my PC as I installed XP Pro retail instead. However out of curiosity I recently tried using these to install Vista in a VM - and it worked fine. I started with the OS DVD, but at a certain point it asked me to put the "Restore CD" in the drive for verification - and it was only satisified if I connected the VM to the physical CD in the host drive with "Passthrough" enabled in the VM settings - after which the OS install went swimmingly.
MidnightJava
Posts: 7
Joined: 9. Oct 2011, 05:01
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Windows 7

Re: WIndows guest with raw disk - can't make it work

Post by MidnightJava »

Yes I'm sure there was no installation disk provided with the system. This site (http://neosmart.net/blog/2009/windows-7 ... air-discs/) says this is the case with most OEMs, and it provides a recovery disk for those who don't have even that. The site mentions Windows 7 specifically, so maybe it was different with Vista. (It certainly would be appropriate for MS to not be overly concerned about people pirating Vista.) My system has a means to create a recovery disk, but the one provided by the site I mentioned was needed to fix my MBR when it was corrupted by what I did with the VM. The generated recovery disk didn't help.

It's unfortunate they don't provide the Windows installer. I've paid for a copy of Windows and will not pay for another one. The use case I'm trying to enable, booting the same instance of Windows either in a VM or natively, and not both at the same time, should only require one license. I'll contact HP and see if they can help, but I'm not very hopeful.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: WIndows guest with raw disk - can't make it work

Post by mpack »

MidnightJava wrote:(It certainly would be appropriate for MS to not be overly concerned about people pirating Vista.)
Piracy isn't the concern - you have a license to run Vista/Win7 etc on the bundled hardware. That should include the ability to reinstall the OS after e.g. upgrading the hard disk. Also, with respect: I don't need to visit a website to read someones ideas about what royalty vendors normally do, I have direct personal experience garnered over the last decade of what this particular company actually does! Admittedly that personal experience doesn't include a Win7 bundled PC, as my most recent supplied PC was Vista era.
Tuckjet
Posts: 1
Joined: 12. Nov 2011, 07:04
Primary OS: MS Windows XP
VBox Version: OSE other
Guest OSses: Windows 7

Re: WIndows guest with raw disk - can't make it work

Post by Tuckjet »

If the windows install is the only thing on that Hard drive, you might try a whole disk rawdisk instead of a partion rawdisk that you have written below.

Code: Select all

 sudo VBoxManage internalcommands createrawvmdk -filename /home/$USER/VirtualBox\ VMs/$VM_NAME/$VM_NAME.vmdk -rawdisk /dev/sda 
MidnightJava wrote:
Then I create the raw disk as follows

Code: Select all

VM_NAME=Windows7Raw           # name of virtual machine
sudo VBoxManage internalcommands createrawvmdk -filename /home/$USER/VirtualBox\ VMs/$VM_NAME/$VM_NAME.vmdk -rawdisk /dev/sda -partitions 1,2 -relative -mbr myMBR.mbr
I hope that helps.
MidnightJava
Posts: 7
Joined: 9. Oct 2011, 05:01
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Windows 7

Re: WIndows guest with raw disk - can't make it work

Post by MidnightJava »

Well thanks for that suggestion, Tuckjet. It's certainly worth a try. I currently have Ubuntu and Windows on the same disk, so I'll have to buy another disk for Ubuntu. I just spent a boatload of money on some amateur radio equipment, so will have to hold off on any further tech purchases for a while. I'll report back here when I get around to trying it.
steveriley
Posts: 15
Joined: 21. Jul 2011, 01:20
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 7 x64
Location: Seattle, WA, USA

Re: WIndows guest with raw disk - can't make it work

Post by steveriley »

mpack wrote:Other than that, I'm afraid I consider raw disk access so dangerous that there is absolutely no way I'll help anyone use it. It's documented in the user manual as an expert level feature, meaning if you are qualified to use it then you don't need any help from me.
Agreed. This feature seems sufficiently brittle and dangerous that I think it's best to avoid it. I'm not aware of any performance gains that make it worth the risk.
MidnightJava
Posts: 7
Joined: 9. Oct 2011, 05:01
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Windows 7

Re: WIndows guest with raw disk - can't make it work

Post by MidnightJava »

steveriley wrote:
mpack wrote:Other than that, I'm afraid I consider raw disk access so dangerous that there is absolutely no way I'll help anyone use it. It's documented in the user manual as an expert level feature, meaning if you are qualified to use it then you don't need any help from me.
Agreed. This feature seems sufficiently brittle and dangerous that I think it's best to avoid it. I'm not aware of any performance gains that make it worth the risk.
Well performance improvement is not my motivation. I just want to be able to boot in a VM the instance of Windows that I paid for without receiving an installation disk. I'd like to be able to boot it either native or in the VM (but not at the same time), but that's not the critical requirement. The main issue is that I want to run Windows in a VM and I don't want to buy another copy to do that, as the intended use case does not violate the license agreement. If there's another way to accomplish my objective, please let me know.
Post Reply