Discuss: HOWTO: Windows 7: In both VM and native

Discussions about using Windows guests in VirtualBox.
pedrogfrancisco
Posts: 10
Joined: 6. Jun 2010, 12:23
Primary OS: Fedora other
VBox Version: OSE Fedora
Guest OSses: Windows

Discuss: HOWTO: Windows 7: In both VM and native

Post by pedrogfrancisco »

[modedit]This is the discussion topic for the HOWTO: Windows 7: In both VM and native.
Last edited by pedrogfrancisco on 12. Jul 2010, 23:28, edited 1 time in total.
matteosistisette
Posts: 94
Joined: 20. Jun 2010, 19:02
Primary OS: Ubuntu other
VBox Version: OSE other
Guest OSses: windows vista

Re: HOWTO: Windows 7: In both VM and native

Post by matteosistisette »

Hi, this sentence is obscure:
pedrogfrancisco wrote: Terminology
  • VM - Virtual Machine, in this case, the Virtual Machine created in Virtual Box which disk is the partition(s) on your disk which has/have Windows 7 installed.
(emphasis added: which disk)

Did you mean "whose disk"?
This would make the sentence grammatically correct, but still unclear.

This is not for the sake of criticising: I really don't understand what virtual machine you are talking about here.
pedrogfrancisco
Posts: 10
Joined: 6. Jun 2010, 12:23
Primary OS: Fedora other
VBox Version: OSE Fedora
Guest OSses: Windows

Re: HOWTO: Windows 7: In both VM and native

Post by pedrogfrancisco »

Whose? Isn't 'whose' just used when the subject is a person?

Anyway, what I meant was, assuming the following step:
  • Create a Virtual Machine in Virtual Box named 'raw7';
then 'raw7' is the VM.

The sentence next is just because I'm going to call VM and Native to the same OS, which is installed in the same spot, just in 'VM' it's booting inside VirtualBox and in 'Native' I'm booting it in barebone 'metal'.

I'm sorry I can't explain better, but just point me which of these paragraphs is confusing you and I'll try to rephrase :)

EDIT: rephrased the definition in the first post, see if it's clearer.
matteosistisette
Posts: 94
Joined: 20. Jun 2010, 19:02
Primary OS: Ubuntu other
VBox Version: OSE other
Guest OSses: windows vista

Re: HOWTO: Windows 7: In both VM and native

Post by matteosistisette »

Thank you, it is much clearer now. Indeed I don't know how I would condense that into one statement, but now I have no difficulty in understanding it :)

P.S. afaik "whose" means both "of whom" and "of which"
ernaa
Posts: 1
Joined: 15. Jul 2010, 11:03
Primary OS: MS Windows Vista
VBox Version: OSE Mandriva
Guest OSses: 3.2.6

Re: HOWTO: Windows 7: In both VM and native

Post by ernaa »

Great. Thank You!
ngoonee
Posts: 4
Joined: 3. Dec 2010, 04:13
Primary OS: Linux other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7

Re: Discuss: HOWTO: Windows 7: In both VM and native

Post by ngoonee »

Just a quick note that in my case the instructions on [3] weren't really sufficient (go figure), it kept giving me an error about the version of the rescue system not being the same as the version of installed windows (a 32-bit/64-bit conflict according to google, but it was the same disc!).

Anyway, I just selected 'restore a saved restore point' and clicked cancel on the following dialog, which gave me the command prompt, from there BootRec.exe /fixmbr worked fine =). Thanks for the howto.
egalus
Posts: 1
Joined: 27. Dec 2010, 13:54
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Discuss: HOWTO: Windows 7: In both VM and native

Post by egalus »

Just a quick question:

After following this tutorial I now have a nice working Windows 7 Rawdisk VM in Ubuntu but this virtualized Windows 7 sees (regarding disk-manager) all my partitons (i guess that is caused by the mbr file that we created but i am not sure).
What happens if I try to access some part of the harddrive that is not shared via the partiton defined in the vmdk device? Will this cause some kind of crash on the virtual win7? Or will it cause some sort of filesystemcorruption on the host?


And another hint:
If someone else has the problem that he wants to use this on a thinkpad laptop with ssd in hdd bay and a sometimes a hdd in the ultrabay using /dev/sda or /dev/sdb is no wise decision as the thinkpad somehow loves to switch devicename for the ssd depending on hdd being in the ultrabay or not. In this case just follow the instructions as given and exchange /dev/sda1 in the generated vmdk file by the corresponding /dev/disk/by-uuid/your-win7-uudi for the partition. That way changed devicenames do not harm and everything works as expected. You can't do this directly with vboxmanage as it does not allow for /dev/disk/by-uuid mixed with -partition or -relative mbr.
Tomservo
Posts: 34
Joined: 13. Feb 2008, 13:42
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Solaris Express 11

Re: Discuss: HOWTO: Windows 7: In both VM and native

Post by Tomservo »

How much issues will Windows have with the switching hardware? In regards to both booting and activation. Because going from native to VM and back, it'll always get its rug pulled from below its feet.
PDP8User
Posts: 2
Joined: 14. Jan 2011, 04:54
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Windows 7

Re: Discuss: HOWTO: Windows 7: In both VM and native

Post by PDP8User »

Hi all
Just as you've got everything nicely documented (and a great thanks for doing it!), the rules change :(

VirtualBox 4.0 changes where a lot of the files are stored. In particular, the hidden $HOME/.VirtualBox directory is replaces by a "VirtualBox VMs" directory (not hidden, and with the space in the name). Each VM is represented in that directory by a subdirectory, with both settings and media stored within it. See the VirtualBox Help at: "10.1. Where VirtualBox stores its files" for more details.

I'm just working through the process now; when I'm done and it's working, I'll post amended scripts for the 4.0 directory structure.

Cheers
Brian
PDP8User
Posts: 2
Joined: 14. Jan 2011, 04:54
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Windows 7

Re: Discuss: HOWTO: Windows 7: In both VM and native

Post by PDP8User »

The scripts that have worked for me on VirtualBox 4 are:
1) The script to create the VMDK:

Code: Select all

VM_NAME=win7raw 	 		# name of virtual machine
sudo VBoxManage internalcommands createrawvmdk -filename /home/$USER/VirtualBox\ VMs/$VM_NAME/$VM_NAME.vmdk -rawdisk /dev/sda -partitions 1 -relative -mbr myMBR.mbr
2) The script to start the VM under its own account name:

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=win7raw 	 		# 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/

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
3) and a script to start the VirtualBox Manager (and to change the access rights to the files back to something usable) following a run of the VirtualBox:

Code: Select all

#! /bin/bash
# VirtualBox Manager start script for VirtualBox 4.x-- you'll have to use it following a standalone run of the VB VM
# this is the same as the VB Run script except for the last line
VBUSER=virtualbox 			# name of custom account created (which is a member of disk group)
VM_NAME=win7raw 	 		# 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/

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 VirtualBox

Cheers
Brian
mrmylanman
Posts: 1
Joined: 4. Dec 2010, 17:51
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Ubuntu minimal 10.10

Re: Discuss: HOWTO: Windows 7: In both VM and native

Post by mrmylanman »

Hello,

I got to the point where the VMDK file is created (which it did successfully), however as I am creating the VM, I get the following error:
"Failed to open the hard disk /home/mylan/Virtualbox VMs/Windows7/raw7.vmdk

The medium '/home/mylan/VirtualBox VMs/Windows7/raw7.vmdk' can't be used as the requested device type.

Details:

Result Code: NS_ERROR_FAILURE (0x80004005)
Component: Medium
Interface: IMedium {9edda847-1279-4b0a-9af7-9d66251ccc18}
Callee: IVirtualBox {d2de270c-1d4b-4c9e-843f-bbb9b47269ff}
Anyone know how to fix this? I was sure to run the sudo chown 666 [filename] command before attempting to add it.

I am using Debian, if that makes a difference.

Thanks, look forward to getting it working!
foreigner
Posts: 3
Joined: 1. Feb 2011, 21:13
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Windows 7

Re: Discuss: HOWTO: Windows 7: In both VM and native

Post by foreigner »

The grub error you get in step e.c is:

error: unknown filesystem.
grub rescue>
Attachments
grub_error.png
grub_error.png (9.19 KiB) Viewed 162209 times
foreigner
Posts: 3
Joined: 1. Feb 2011, 21:13
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Windows 7

Re: Discuss: HOWTO: Windows 7: In both VM and native

Post by foreigner »

The specific command you need to run in step e.d is:

bootrec /FixMbr

Maybe that's obvious to you guys but it wasn't to me. I guessed and it worked :-)

Also the HOWTO is emphatic that you need a Windows 7 *installation* disk. I don't have one of these because my Thinkpad didn't come with one (it has a special partition instead). However a Windows 7 *recovery* disk worked just as well.
foreigner
Posts: 3
Joined: 1. Feb 2011, 21:13
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Windows 7

Re: Discuss: HOWTO: Windows 7: In both VM and native

Post by foreigner »

Woohoo! I got it all working!

I also had to uninstall the Touchpad driver in order for Guest Additions not to bork the native boot.

A few things I had to do that were not in the guide:

1) CDROM - by default VirtualBox did not provision a CDROM drive for the VM. I had to add it explicitly through the UI. Then I had to add the "virtualbox" user to the "cdrom" group in order for it to be accessible.

2) Be patient - Windows 7 takes a *lot* longer to boot in the VM than natively. It freezes on a black screen for so long that the first time I was about to give up - you just have to wait.

Thank you so much for this HOWTO!
cumthsc
Posts: 12
Joined: 11. Feb 2011, 22:47
Primary OS: Fedora other
VBox Version: OSE Fedora
Guest OSses: Windows 7, RHEL 6

Re: Discuss: HOWTO: Windows 7: In both VM and native

Post by cumthsc »

Thanks for this tutorial. I have made it most of the way through, and almost everything has worked as advertised so far. I have a correction and a problem.

The correction: In my Dell Latitude E6410 laptop, "dmidecode -t1" reports the system version as 0001. Including this value in the parameter-setting script results in an error complaining that the value of DmiSystemVersion is not a string. The solution is to supply the value "string:0001" instead (http://www.virtualbox.org/ticket/2481).

The problem: I followed the instructions for fixing the MBR. Before carrying out this procedure, attempts to boot the Windows VM simply halted with the error "Missing operating system". After carrying out the procedure, the system still halts on boot with the same error. I also tried "bootsect.exe /nt60 ALL /mbr" as suggested on another page for Windows 7, but that didn't help either. Both commands claim to have correctly written the boot sector, but neither apparently does.

Suggestions for getting this working appreciated.
Post Reply