View Single Post
  #1   (View Single Post)  
Old 17th February 2009
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default multibooting OpenBSD 4.4 through Vista's boot manager

Quote:
I previously posted an earlier version of this guide on BSDForums. There, the focus had been on OpenBSD 4.0, but nothing has changed with subsequent releases of OpenBSD. I am currently using the same information with OpenBSD 4.5-beta, & I don't expect anything to change in the near future (although Windows 7 may be another story...). Nevertheless, users should back up sensitive data before proceeding if losing any is an unbearable outcome.
The official OpenBSD FAQ provides information on how to multiboot OpenBSD 4.4 using the boot manager found in Windows NT/2000/XP, but Vista no longer uses the boot.ini file of old. So, scouring the Internet ensued to find the incantation needed to boot OpenBSD via Vista's boot manager.

Microsoft has moved boot information into Boot Configuration Data (BCD), and provides the bcdedit command-line utility to fully manage this database. There are still a few duplicated features controlling multibooting found in the Systems applet GUI (Start | Control Panel | System and Maintenance | System | Advanced system settings | Advanced tab | Startup and Recovery Settings | System startup), but adding new BCD entries can only be done from the command-line.

Those familiar with earlier versions of Windows (but unfamiliar with UAC...) will undoubtedly be surprised when they try to invoke bcdedit from the command-line after logging in as an Administrator:
Code:
C:\Windows\System32>bcdedit
The boot configuration data store could not be opened.
Access is denied.

C:\Windows\System32>
In Microsoft's effort to enhance security, Vista implements stricter authority through User Access Control (UAC). Although applications may be run from an Administrator account, applications still actually run with normal user rights. To truly run bcdedit with Administrator credentials requires cmd.exe also be explicitly run with Administrator credentials. Right click on the Command Prompt icon (Start | All Programs | Accessories | Command Prompt), or open the Start window and type cmd. When the search facility shows the application's icon, right click it and select Run as administrator from the local menu.

UAC can be disabled, but this defeats the purpose of UAC's security features.

Running bcdedit with no arguments provides an overview of the BCD database:
Code:
C:\Windows\system32>bcdedit

Windows Boot Manager
--------------------
identifier              {bootmgr}
device                  partition=C:
description             Windows Boot Manager
locale                  en-US
inherit                 {globalsettings}
default                 {default}
resumeobject            {f4bad82f-d5dc-11db-b83c-fff6129dfa33}
displayorder            {default}
                        {current}
toolsdisplayorder       {memdiag}
timeout                 10
customactions           0x10000ba000001
                        0x54000001
custom:54000001         {572bcd55-ffa7-11d9-aae0-0007e994107d}

Windows Boot Loader
-------------------
identifier              {current}
device                  partition=C:
path                    \Windows\system32\winload.exe
description             Microsoft Windows Vista
locale                  en-US
inherit                 {bootloadersettings}
osdevice                partition=C:
systemroot              \Windows
resumeobject            {f4bad82f-d5dc-11db-b83c-fff6129dfa33}
nx                      OptIn

C:\Windows\system32>
To view the plethora of functions bcdedit performs, append the /? switch:
Code:
C:\Windows\system32>bcdedit /?

BCDEDIT - Boot Configuration Data Store Editor

The Bcdedit.exe command-line tool modifies the boot configuration data store.
The boot configuration data store contains boot configuration parameters and
controls how the operating system is booted. These parameters were previously
in the Boot.ini file (in BIOS-based operating systems) or in the nonvolatile
RAM entries (in Extensible Firmware Interface-based operating systems). You can
use Bcdedit.exe to add, delete, edit, and append entries in the boot
configuration data store.

For detailed command and option information, type bcdedit.exe /? <command>. For
example, to display detailed information about the /createstore command, type:

     bcdedit.exe /? /createstore

For an alphabetical list of topics in this help file, run "bcdedit /? TOPICS".

Commands that operate on a store
================================
/createstore    Creates a new and empty boot configuration data store.
/export         Exports the contents of the system store to a file. This file
                can be used later to restore the state of the system store.
/import         Restores the state of the system store using a backup file
                created with the /export command.

Commands that operate on entries in a store
===========================================
/copy           Makes copies of entries in the store.
/create         Creates new entries in the store.
/delete         Deletes entries from the store.

Run bcdedit /? ID for information about identifiers used by these commands.

Commands that operate on entry options
======================================
/deletevalue    Deletes entry options from the store.
/set            Sets entry option values in the store.

Run bcdedit /? TYPES for a list of datatypes used by these commands.
Run bcdedit /? FORMATS for a list of valid data formats.

Commands that control output
============================
/enum           Lists entries in the store.
/v              Command-line option that displays entry identifiers in full,
                rather than using names for well-known identifiers.
                Use /v by itself as a command to display entry identifiers
                in full for the ACTIVE type.

Running "bcdedit" by itself is equivalent to running "bcdedit /enum ACTIVE".

Commands that control the boot manager
======================================
/bootsequence   Sets the one-time boot sequence for the boot manager.
/default        Sets the default entry that the boot manager will use.
/displayorder   Sets the order in which the boot manager displays the
                multiboot menu.
/timeout        Sets the boot manager time-out value.
/toolsdisplayorder  Sets the order in which the boot manager displays
                    the tools menu.

Commands that control Emergency Management Services for a boot application
==========================================================================
/bootems        Enables or disables Emergency Management Services
                for a boot application.
/ems            Enables or disables Emergency Management Services for an
                operating system entry.
/emssettings    Sets the global Emergency Management Services parameters.

Command that control debugging
==============================
/bootdebug      Enables or disables boot debugging for a boot application.
/dbgsettings    Sets the global debugger parameters.
/debug          Enables or disables kernel debugging for an operating system
                entry.


C:\Windows\system32>
Providing a full tutorial on using bcdedit is beyond the scope of this document, however, understanding some of its capabilities is necessary given that this is now the interface for generating Vista boot manager configurations. Nominal study of bcdedit's capability may help diagnose problems also not foreseen by this document. Readers wanting or needing more information should search Microsoft's site for more information. One source can be found at the following:

http://technet.microsoft.com/en-us/l.../cc709667.aspx

The official OpenBSD FAQ describes what is needed to copy OpenBSD's PBR to a file:

http://openbsd.org/faq/faq4.html#Multibooting

...and this is no different when using Vista. Even if Microsoft has enhanced the boot manager interface, the basic process of booting through the MBR (Master Boot Record) has not fundamentally changed. It is still necessary to provide enough information to the boot manager to load OpenBSD's kernel into memory from its appropriate partition.

The remainder of this document will be tagged with "MANDATORY" & "SUPPLEMENTARY" as some steps are necessary while others are provided for to show additional functionality.
  • MANDATORY: Once the PBR has been generated, transfer it to Vista's system partition.
  • MANDATORY: Next, BCD has to be instructed to create a new boot entry/Registry subhive:
Code:
C:\Windows\system32>bcdedit /create /d "OpenBSD/i386 4.5" /application bootsector
The entry {05a763ce-d81b-11db-b3ec-000000000000} was successfully created.

C:\Windows\System32>
Note that creating a new boot manager entry returns a GUID representing a new Registry subhive. Be forewarned that this value is unique (based on the hard drive used...), so do not copy the GUID value shown above; this is provided simply for illustrative purposes. Because bcdedit identifies this new boot manager entry through the returned GUID, mark and paste the GUID for easier retrieval. It will be used several more times.
  • SUPPLEMENTARY: For those wanting more context, look at what help bcdedit provides for the create option:
Code:
C:\Windows\system32>bcdedit /? create

This command creates a new entry in the boot configuration data store. If
a well-known identifier is specified, then the /application, /inherit and
/device options cannot be specified. If the <id> is not specified,
or if <id>is not well-known, then you must specify an /application, /inherit
or /device option.

bcdedit /create [{<id>}] /d <description> [-application <apptype> |
    /inherit [<apptype>] | /inherit DEVICE | /device]

    <id>                    Specifies the identifier to be used for the new
                            entry. For more information about identifiers, run
                            "bcdedit /? ID".

    <description>           Specifies the description to be applied to the new
                            entry.

    /application <apptype>  Specifies that the new entry must be an application
                            entry. <apptype> specifies the application type.
                            <apptype> can be one of the following:

                                BOOTSECTOR
                                OSLOADER
                                RESUME
                                STARTUP

                            If you use other application types instead of
                            one of these, you must also specify a well-known
                            identifier.

    /inherit [<apptype>]    Specifies that the new entry must be an inherit
                            entry, and <apptype> specifies the application
                            type. If <apptype> is not specified, then the entry
                            can be inherited by any entry. If specified,
                            <apptype> can be one of the following:

                                BOOTMGR
                                BOOTSECTOR
                                FWBOOTMGR
                                MEMDIAG
                                NTLDR
                                OSLOADER
                                RESUME

                            The modifier prevents the inherit entry from being
                            inherited by an application entry of <apptype>.

    /inherit DEVICE         Specifies that the new entry must be an inherit
                            entry, and that the entry can only be inherited by
                            a device options entry.

    /device                 Specifies that the new entry must be an additional
                            device options entry.

Examples:

The following command creates a NTLDR based OS loader entry (Ntldr):

    bcdedit /create {ntldr} /d "Earlier Windows OS Loader"

The following command creates a RAM disk additional options entry:

    bcdedit /create {ramdiskoptions} /d "Ramdisk options"

The following command creates a new operating system boot entry:

    bcdedit /create /d "Windows Vista" /application osloader

The following command creates a new debugger settings entry:

    bcdedit /create {dbgsettings} /d "Debugger Settings"

C:\Windows\system32>
  • MANDATORY: Mark the new BCD entry as bootable, and specify the pathname of the PBR file.
Code:
C:\Windows\system32>bcdedit /set {05a763ce-d81b-11db-b3ec-000000000000} device boot
The operation completed successfully.

C:\Windows\system32>bcdedit /set {05a763ce-d81b-11db-b3ec-000000000000} path \openbsd.pbr
The operation completed successfully.

C:\Windows\system32>
Note the absolute pathname of the imported PBR file. Do not add a drive letter as it is assumed that the file is placed in the system partition. bcdedit will not complain about an explicit drive specification, but the boot manager will balk later claiming it cannot resolve the designated pathname.
  • SUPPLEMENTARY: Further information on the set option can be found at the following:
Code:
C:\Windows\system32>bcdedit /? set

This command sets an entry option value in the boot configuration data store.

bcdedit [/store <filename>] /set [{<id>}] <datatype> <value>

    <filename>  Specifies the store to be used. If this option is not
                specified, the system store is used. For more information,
                run "bcdedit /? store".

    <id>        Specifies the identifier of the entry to be modified.  If not
                specified, {current} is used. For more information about
                identifiers, run "bcdedit /? ID".

    <datatype>  Specifies the option data type that will be created or
                modified. Run "bcdedit /? TYPES" for more information about
                data types.

    <value>     Specifies the value that should be assigned to the option. The
                format of <value> depends on the data type specified. Run
                "bcdedit /? FORMATS" for more information about data formats.

Examples:

The following command sets the application device to the partition C: for the
specified operating system entry:

    bcdedit /set {cbd971bf-b7b8-4885-951a-fa03044f5d71} device partition=C:

The following command sets the application path to
\windows\system32\winload.exe for the specified operating system entry:

    bcdedit /set {cbd971bf-b7b8-4885-951a-fa03044f5d71} path
        \windows\system32\winload.exe

The following command sets the NX policy to OptIn for the current operating
system boot entry.

    bcdedit /set nx optin

C:\Windows\system32>
Now is the time to deal with the cosmetics of what the boot manager displays. bcdedit only provides for inserting at the beginning (/addfirst) or end (/addlast) of the list. If there are more than two operating systems, repeated /displayorder commands can be used to bubble the entries to their desired ordering.
  • SUPPLEMENTARY: Specify the position of the new entry:
Code:
C:\Windows\system32>bcdedit /displayorder {05a763ce-d81b-11db-b3ec-000000000000} /addfirst
The operation completed successfully.

C:\Windows\system32>
  • SUPPLEMENTARY: Further help for /displayorder can be viewed by the following command.
Code:
C:\Windows\system32>bcdedit /? displayorder

This command sets the display order to be used by the boot manager.

bcdedit /displayorder <id> [...] [ /addfirst | /addlast | /remove ]

    <id> [...]      Specifies a list of identifiers that make up the
                    display order.  At least one identifier must be specified
                    and they must be separated by spaces.  For more information
                    about identifiers, run "bcdedit /? ID".

    /addfirst       Adds the specified entry identifier to the top of
                    the display order.  If this switch is specified, only a
                    single entry identifier may be specified.  If the specified
                    identifier is already in the list, it will be moved to the
                    top of the list.

    /addlast        Adds the specified entry identifier to the end of
                    the display order.  If this switch is specified, only a
                    single entry identifier may be specified.  If the specified
                    identifier is already in the list, it is moved to the
                    end of the list.

    /remove         Removes the specified entry identifier from the
                    display order.  If this switch is specified, only a single
                    entry identifier may be specified.  If the identifier is
                    not in the list then the operation has no effect. If
                    the last entry is being removed, then the display order
                    value is deleted from the boot manager entry.

Examples:

The following command sets two OS entries and the NTLDR based OS loader in
the boot manager display order:

    bcdedit /displayorder {802d5e32-0784-11da-bd33-000476eba25f}
        {cbd971bf-b7b8-4885-951a-fa03044f5d71} {ntldr}

The following command adds the specified OS entry to the end of the boot
manager display order:

    bcdedit /displayorder {802d5e32-0784-11da-bd33-000476eba25f} /addlast

C:\Windows\system32>
Note in the command above the new entry is specified to be listed first. One would naturally think this would be the default operating system to be booted (no active selection made at boot time then boots a predetermined OS...), but this is not the case. Specifying the default OS booted requires yet another command.
  • SUPPLEMENTARY: Change the default OS booted to the new boot manager entry.
Code:
C:\Windows\system32>bcdedit /default {05a763ce-d81b-11db-b3ec-000000000000}
The operation completed successfully.

C:\Windows\system32>
  • SUPPLEMENTARY: Help for the default option results in the following information:
Code:
C:\Windows\system32>bcdedit /? default

This command sets the default entry that the boot manager will use when the
timeout expires.

bcdedit /default <id>

    <id>    Specifies the identifier of the boot entry to be used as the
            default when the time-out expires. For information about
            identifiers, run "bcdedit /? ID".

Examples:

The following command sets the specified entry as the default boot manager
entry:

    bcdedit /default {cbd971bf-b7b8-4885-951a-fa03044f5d71}

The following command sets the NTLDR based OS loader as the default
entry:

    bcdedit /default {ntldr}

C:\Windows\system32>
Finally, the boot manager's timeout value (which also can be changed in the System applet...) can be changed through bcdedit.
  • SUPPLEMENTARY: Change the timeout value (If no OS selection is made after this prescribed time lapses, boot the default OS.) of the default OS.
Code:
C:\Windows\system32>bcdedit /timeout 10
The operation completed successfully.

C:\Windows\system32>
  • SUPPLEMENTARY: More information on this command follows:
Code:
C:\Windows\system32>bcdedit /? timeout

This command sets the time to wait, in seconds, before the boot manager selects
a default entry. For information about setting the default entry, run
"bcdedit /? default".

bcdedit /timeout <timeout>

    <timeout>   Specifies the time to wait, in seconds, before the boot manager
                selects a default entry.

Example:

The following command sets the boot manager <timeout> to 30 seconds:

    bcdedit /timeout 30

C:\Windows\system32>
The result of all changes can be seen by reissuing the bare bcdedit command:
Code:
C:\Windows\system32>bcdedit

Windows Boot Manager
--------------------
identifier              {bootmgr}
device                  partition=C:
description             Windows Boot Manager
locale                  en-US
inherit                 {globalsettings}
default                 {default}
resumeobject            {f4bad82f-d5dc-11db-b83c-fff6129dfa33}
displayorder            {default}
                        {current}
toolsdisplayorder       {memdiag}
timeout                 10
customactions           0x10000ba000001
                        0x54000001
custom:54000001         {572bcd55-ffa7-11d9-aae0-0007e994107d}

Real-mode Boot Sector
---------------------
identifier              {default}
device                  boot
path                    \openbsd.pbr
description             OpenBSD/i386 4.5

Windows Boot Loader
-------------------
identifier              {current}
device                  partition=C:
path                    \Windows\system32\winload.exe
description             Microsoft Windows Vista
locale                  en-US
inherit                 {bootloadersettings}
osdevice                partition=C:
systemroot              \Windows
resumeobject            {f4bad82f-d5dc-11db-b83c-fff6129dfa33}
nx                      OptIn

C:\Windows\system32>
In summary, multibooting OpenBSD through Vista isn't significantly more difficult than earlier versions of Windows. The biggest issue is grasping enough of bcdedit's capabilities to form a working boot manager configuration.

Questions and/or comments are welcomed.
Reply With Quote