Jump to content











Photo
- - - - -

Using same vhd for Native vhd boot as well as in Virtualbox


  • Please log in to reply
7 replies to this topic

#1 oriensol

oriensol

    Frequent Member

  • Advanced user
  • 216 posts
  •  
    India

Posted 10 September 2010 - 11:50 AM

I am writing this so that someone trying something similar may find it useful.

When you boot the same vhd (Windows 7 Ultimate/Enterprise) natively as well as in Virtualbox, the Computer (HAL) is detected differently (at least in the case of an Intel Core 2 Duo). When natively booted, the device under computer is "ACPI X86 Based PC" and within (Oracle) Virtualbox it is "Advanced Configuration and Power Interface (ACPI) PC".

This leads to the device driver being installed each time you switch from Native vhd to Virtualbox and vice versa (asking for a reboot). The easy way to get around this is to check "Enable IO APIC" under the Virtualbox machine System Motherboard settings, which makes it "ACPI X86 Based PC" in both cases. I know this is supposed to slow things down a bit in Virtualbox, but I didn't see much of a difference.

This way you can boot both ways without using "bcdedit /set {guid} hal on".

Hope this helps.

#2 oriensol

oriensol

    Frequent Member

  • Advanced user
  • 216 posts
  •  
    India

Posted 10 September 2010 - 04:31 PM

Here's a batch script to create a new bcd store - save as bcdsetup.bat. Hope this helps. Note the delete of the bcd store if it exists!

set BCD-File=D:\boot\BCD

set VHD-Partition=D

set VHD-File=\win7.vhd

del %BCD-File%

bcdedit /createstore %BCD-File%

for /f "tokens=1-3" %%a in ('bcdedit /store %BCD-File% /create /d "Windows 7" /application osloader') do set guid=%%c

bcdedit /store %BCD-File% /set %guid% systemroot \Windows

bcdedit /store %BCD-File% /set %guid% path \Windows\system32\winload.exe

bcdedit /store %BCD-File% /set %guid% device vhd=[%VHD-Partition%:]%VHD-File% 

bcdedit /store %BCD-File% /set %guid% osdevice vhd=[%VHD-Partition%:]%VHD-File%

bcdedit /store %BCD-File% /set %guid% detecthal yes

bcdedit /store %BCD-File% /create {bootmgr} /d "Windows 7 BootManager"  

bcdedit /store %BCD-File% /set {bootmgr} timeout 6 

bcdedit /store %BCD-File% /set {bootmgr} displayorder %guid%

bcdedit /store %BCD-File% /set {bootmgr} path \bootmgr

bcdedit /store %BCD-File% /default %guid%

bcdedit /store %BCD-File% /enum all

Carefully modify the italicised parts to suit your situation, before you use the script:

set BCD-File=D:\boot\BCD
set VHD-Partition=D
set VHD-File=\win7.vhd

Warning: Be careful when playing around with boot files. You are warned.

#3 Nuno Brito

Nuno Brito

    Platinum Member

  • Team Reboot
  • 10465 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 10 September 2010 - 06:02 PM

Very interesting to keep in mind, thanks for sharing this tip.

#4 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13797 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 10 September 2010 - 06:16 PM

Maybe something like this would help?
@ECHO OFF

SETLOCAL ENABLEEXTENSIONS

SETLOCAL ENABLEDELAYEDEXPANSION

set BCD-File=%1

set VHD-Partition=%2

set VHD-File=%3



IF NOT DEFINED BCD-File SET BCD-File=D:\boot\BCD 

IF NOT DEFINED VHD-Partition SET VHD-Partition=D

IF NOT DEFINED VHD-File SET VHD-File=\win7.vhd

So that you can call the batch with parameters also.

A couple of questions/suggestions:

set BCD-File=D:\boot\BCD
set VHD-Partition=D
set VHD-File=\win7.vhd


Isn't the file ALWAYS named BCD, ALWAYS residing in "VHD-Partiion" and ALWAYS in \boot\ directory? :)

If this is the case, having ONLY one variable parameter:
set VHD-File=D:\win7.vhd
contains all the needed info.

As a general "standardizing" note a file name does NOT begin with a backslash, so it should be advisable to have:

set VHD-File=win7.vhd

and

bcdedit /store %BCD-File% /set %guid% device vhd=[%VHD-Partition%:]\%VHD-File%
bcdedit /store %BCD-File% /set %guid% osdevice vhd=[%VHD-Partition%:]\%VHD-File%


:hyper:
Wonko

#5 oriensol

oriensol

    Frequent Member

  • Advanced user
  • 216 posts
  •  
    India

Posted 11 September 2010 - 02:16 AM

@Wonko,

Thanks for the comments and suggestions. :hyper:

I wanted to post this to help users that know what they are doing - hence posted as a codebox instead of as a batch file. Also wanted to post this quickly before going off to sleep :)

As to the questions about the bcd name, partition, etc. I believe they are not necessarily "always" the same : http://homepage.ntlw...ot-process.html

Also, while preparing for deployment, the root of the boot directory could be different.

Further, the bcd file need not be in the same partition. And the partition letters will be different depending on how you have booted while creating the bcd vs. when using it. Advanced users may also want to use [locate] instead of [D:] for the partition (similar to 'find' of grub4dos). You may also be setting the active partition after creating the store thus making it unsafe to automatically determine the active partition. Adding this as another parameter now. No error checking still for the parameters, so users should take care while using.

Will upload the new script code later on.

#6 oriensol

oriensol

    Frequent Member

  • Advanced user
  • 216 posts
  •  
    India

Posted 11 September 2010 - 11:28 AM

I have uploaded the script in a separate thread : http://www.boot-land...showtopic=12466

Hope this helps.

#7 Nuno Brito

Nuno Brito

    Platinum Member

  • Team Reboot
  • 10465 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 12 September 2010 - 11:54 AM

This work has been mentioned on this week's newsletter. :hyper:

#8 oriensol

oriensol

    Frequent Member

  • Advanced user
  • 216 posts
  •  
    India

Posted 12 September 2010 - 01:32 PM

Thank you Nuno. :hyper:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users