Boot Control: alternative MBR software

Gertjan Klein
August 14, 1999


1 Introduction.
   1.1 What is Boot Control?
   1.2 Why use Boot Control?
   1.3 When not to use Boot Control?
   1.4 Availability, price and contacting the author
2 Features
   2.1 General
   2.2 MBR 0
   2.3 MBR 1
   2.4 MBR 2
   2.5 MBR 3
   2.6 MBR 4
   2.7 MBR 5
   2.8 MBR 6
   2.9 MBRs 7 and 8
3 Options and installation
   3.1 Before installing Boot Control
   3.2 Getting help
   3.3 Installation
   3.4 Setting MBR options
   3.5 Restoring a saved MBR
4 Technical details
   4.1 Booting
   4.2 The Master Boot Record
   4.3 Cylinder-Head-Sector translation
   4.4 Partition Types
5 Miscellaneous
   5.1 Changing drive assignments
   5.2 Removable drives
   5.3 Tested with. . .
   5.4 Drive letter issues
   5.5 type5to6.com
   5.6 Timer quirks
References
About this document


1  Introduction.

This documentation describes Boot Control version 0.41. Changes in this version (from V0.4) are primarily bugfixes:

1.1  What is Boot Control?

Boot Control is a set of alternative Master Boot Records, together with an installation program. The installation program replaces the current MBR with one of Boot Control's, which displays a small menu at boot time. The menu shows up to four (named) partitions, and lets you choose which one you want to boot. Some of the MBRs also allow you to boot other drives.

1.2  Why use Boot Control?

The main purpose of Boot Control is to allow you to boot multiple Operating Systems in an easy, straight-forward manner. Each OS must be installed in its own primary partition. Using the standard MS-DOS MBR software, if you want to load a different OS, you are required to use the current OS's FDISK utility to set the active flag in the MBR to the OS you want to boot, and then reboot. This is terribly inconvenient, and may also scare away less technical users. MS-DOS's MBR also has no provision for booting other drives than the first harddisk. Boot Control lets you make your choice at boot time, displaying the name of each OS you can choose from. As it installs in the Master Boot Record, it requires no special files, and although the installation utility is an MS-DOS program, Boot Control doesn't depend on the presence of a specific operating system or file system once installed.

1.3  When not to use Boot Control?

If you are not interested in having more than one operating system on your PC, Boot Control is not for you. If you are satisfied with the interface that e.g. LILO [5] (Linux Loader) offers, there is also no need to switch. Users of OS/2 may be satisfied with its Boot Manager, although it uses one precious slot in the partition table. Also, in some situations Boot Control may be considered a slight breach in system security. Most of Boot Control's MBRs need to rewrite themselves to disk at boot time (more on that in section 2.1), and hence the BIOS MBR virus protection must be turned off. (On the other hand, BC can be told to make a backup copy of the MBR to a file, and can restore it in case integrity has been violated. Also note that any security implemented by the operating system is not affected by Boot Control, as the latter is only active before the operating system is loaded).

Another reason not to install Boot Control is when you have installed other software in your MBR, such as OnTrack's Disk Manager [2], or MicroHouse's EZ-Drive or DrivePro [3]. These programs are used to support large harddisks (> 504 MB) on systems without a translating BIOS (see 4.3). As this support must be added before the operating system can load from the harddisk, these programs install themselves in the MBR. As they change the partition table, the harddisk may become inaccessible if you overwrite their MBR software. (It may be possible to restore their MBR by running an installation program). If you have a modern BIOS that supports larger harddisks natively, you won't need the above software. IDE controllers with on-board BIOS that does support large harddisks are also available, as are BIOS-only cards (often called LBA cards), that replace the motherboard's disk I/O BIOS.

1.4  Availability, price and contacting the author

Boot Control is free software. I do retain copyright, though--you are not allowed to sell this program to anyone else. If you find Boot Control of value, you can express your opinion by sending me email. My email address is gklein@xs4all.nl.

You can find the latest version of Boot Control on the WWW at address http://www.xs4all.nl/~gklein/bcpage.html.

If you have problems with Boot Control, you are welcome to contact me. You may also suggest features you'd like implemented in Boot Control or one of its MBRs; I don't guarantee I'll implement them, but if many people request something and it's feasible, I probably will.


2  Features

BC comes with nine different MBRs you can choose from, each with its own features. Except for the first one, they all have in common that they display a tiny menu at boot time that shows the available OSes, and prompts the user which OS should be booted. A default choice is highlighted, and booted after a configurable timeout. If you have multiple drives, all MBRs can be installed to any one of them. Not all four partitions need to be shown at boot time--partitions with an empty name don't appear in the boot menu, and can't be booted from. Unused partitions also won't be shown.

2.1  General

The MBRs have different combinations of the following options:

The default.
The default partition to boot can be the first one, the one with the active flag set, or can be configurable, depending on the MBR. Some MBRs set the active flag in the MBR to the selected partition, and hence default to it the next boot. This requires rewriting the MBR, and therefore may conflict with virus protection present in some BIOSes.

Note that there is another reason for setting the active flag to the booted partition, and rewriting the MBR: MS-DOS gets horribly confused if it is booted from another partition than the one with the active flag set. If e.g. the active flag is set for the first partition, and MS-DOS is booted from the second partition, the system will likely hang.

Other hard disks.
Some of the Boot Control MBRs can boot other harddisks too. They do this by loading and executing the MBR of that drive, just as BIOS does with the MBR of the first harddisk. Some check the number of installed harddisks the BIOS reports, and display an uppercase letter for every drive but the current one. (This letter should not be confused with DOS's drive letters!) In any case, in order to show up in Boot Control's boot menu, the harddisk must be supported by the BIOS; harddisks requiring special device drivers will probably not be seen by Boot Control. In some other MBRs it can be configured which drives should be shown at boot time. Pressing one of the displayed letters will load and execute the MBR of the appropriate drive--which can also be a Boot Control MBR, with another menu. Unfortunately, MS-DOS refuses to be booted from any other than the first harddisk, but e.g. Linux happily boots from any drive. Note that even if you don't want a second-level menu to appear when the MBR of the second harddisk is loaded, you may still need to install MBR 0 on it (see 2.2).

Other operating systems.
Some operating systems require specific features to work. Explicit support is added in some MBRs for one of two operating systems:

PC-MOS
Currently, most Boot Control MBRs explicitly support PC-MOS. This operating system requires that the number of the partition it is booted from is written to a fixed location in memory. If this condition is met, it doesn't require the active flag to be set to that partition, as MS-DOS does.

OS/2
This operating system can't handle multiple primary FAT partitions. Its own boot manager hides all non-active primary FAT partitions by changing their system indicator (see 4.2). Boot Control can mimic this behaviour; see the MBR descriptions for more details.

Description size.
As a MBR is only 512 bytes long, and has to contain a partition table, there are only 446 bytes of space available for all the code and data/text. This means that extra functionality in one area inevitably leads to less functionality in another. For example, the friendly prompt of MBRs 1 and 2 ("Please select partition to boot" . . . ), has been removed to make room for the harddisk selection code in MBRs 3 and 4. The description size (the number of characters available to describe the partition or OS) is one of those areas that can differ, depending on other options: it currently varies between 8 and 13 bytes.

All MBRs are highly configurable. The colors of all text items can be configured, the number of seconds to wait before booting the default partition, and the partition or operating system descriptions. Some MBRs have additional configurable options. See the section on Installation (3.3) for details on how to configure these items. Responses to the boot prompt include the displayed partition numbers and drive letters, and ENTER or SPACE for the default.

2.2  MBR 0

MBR 0 is a special case: it doesn't display a boot time menu, it merely boots the currently active partition. The reason it is included is that the standard MS-DOS MBR software (the one that FDISK installs) is incapable of booting partitions on any other than the first harddisk. This MBR doesn't have that flaw. It can be used if e.g. you have only one bootable partition on one of your other drives, and hence you don't need a second-level boot menu. This MBR can display the following error messages:

After all these messages, a prompt appears to correct the problem and press a key. This gives you a chance to e.g. insert a bootable floppy.

2.3  MBR 1

MBR 1 is currently the only MBR that doesn't rewrite itself to disk to save the active flag. As a consequence, there can only be one MS-DOS partition, and the active flag must be set to it. (It is of course possible to change the active flag with e.g. FDISK, and switch between multiple MS-DOS partitions this way, but this rather defeats the purpose of Boot Control). At boot time, the menu in figure 1 is displayed. As you can see, this MBR has eleven characters available to describe the partition or operating system. The default partition is the one with the active flag set, and its choice is highlighted. This MBR does not boot other drives. Possible error messages are:

After the error message is displayed, the MBR is immediately reloaded so you can pick another choice.   
Please select partition too boot.  
Choose from:  
 
1. 123456789AB  
2. 123456789AB  
3. 123456789AB  
4. 123456789AB  
 
?

Figure 1: The MBR 1 boot menu

Please select partition too boot.  
Choose from:  
 
1. 12345678  
2. 12345678  
3. 12345678  
4. 12345678  
 
Boot?

Figure 2: The MBR 2 boot menu


2.4  MBR 2

This MBR is only slightly different from MBR 1. Apart from the messages, the only difference is that this MBR rewrites itself to disk with the active flag in the partition table set to the chosen partition. The boot time message differs only on the last line, as can be seen in figure 2. The error messages are also different:

Other than the above, this MBR has the same functionality as MBR 1.

2.5  MBR 3

This MBR is able to boot other harddisks, by loading and executing the MBR of those harddisks. It checks the number of installed hard disks, and assigns each of them a choice letter, starting with A for the first harddisk. The choice letter for the current harddisk (the one that displays the boot menu) is suppressed. The harddisks are checked for at boot time; after a new harddisk is installed, it will automatically appear in the boot menu. The default is the last booted partition. The menu is considerably more terse that that of the previous two MBRs (see figure 3). The error messages are also extremely terse, to save space:

After the error message is displayed, the MBR is immediately reloaded so you can pick another choice.   


B. HD2  
C. HD3  
1. 12345678  
2. 12345678  
3. 12345678  
4. 12345678  
 
Boot?

Figure 3: The MBR 3 boot menu

B. HD2  
C. HD3  
1. 123456789A  
2. 123456789A  
3. 123456789A  
4. 123456789A  
 
Boot?

Figure 4: The MBR 4 boot menu


2.6  MBR 4

This MBR is a clone of MBR 3. The only difference is that this MBR always defaults to the first partition. Since this saves code space, the partition or operating system description strings can be a bit longer (see figure 4). There are no other differences with MBR 3.

2.7  MBR 5

MBR 5 is the first one to drop PC-MOS support, in favor of support for OS/2. It also changes the way other drives are supported. Instead of displaying every drive available (through BIOS) at boot time, it lets the user configure which drives (up to eight) to show in the boot time menu. The installation program performs no check on the validity of the drives you enter here. If you enter a non-existing drive, and subsequently try to boot it at boot time, an error message will be displayed (see below). It also probably doesn't make much sense to display the drive this MBR is installed to in the boot time menu.

OS/2 is supported if installed on a primary partition. At installation or configuration time, the user specifies which partition holds or will hold OS/2. Whenever this partition is booted, the MBR checks all other primary partitions to see if they are a BIGDOS FAT partition (type 6). If so, they are hidden (changed to type 16h), exactly like OS/2's boot manager does it. If on the other hand any other partition is booted, all hidden partitions are changed to non-hidden. That way, you can still access all partitions when booting anything except OS/2. The primary partitions are also unhidden before booting from another drive. Note that this MBR does not explicitly support (i.e., hide/unhide) partitions of type 4, sometimes used for DOS partitions smaller than 32 MB.   


B. Drive 2  
C. Drive 3  
1. 123456789A  
2. 123456789A  
3. 123456789A  
4. 123456789A  
 
Boot?

Figure 5: The MBR 5 boot menu

B. Drive 2  
C. Drive 3  
1. 123456789ABC  
2. 123456789ABC  
3. 123456789ABC  
4. 123456789ABC  
 
Boot?

Figure 6: The MBR 6 boot menu


This MBR sets the active flag to the partition that is booted. If another drive is booted, the active flag is not set (previous MBRs left it wherever it was). This has no consequences for the accessibility of the partitions. The description size is ten characters. The drive string is a little more verbose than the terse "A. HD1" of MBRs 3 and 4, and its colors are better configurable. (see figure 5 for a sample of the boot menu; not all possible drives are shown).

This MBR is also the first MBR that can default to another drive. The default to boot is the last booted partition or drive; this means that if the operating system you use most is installed on another drive, you can now rely on Boot Control to default to it (and to boot it after the configured timeout) if you booted it the previous time.

Error messages are still terse:

2.8  MBR 6

MBR 6 has the same features and error messages as MBR 5. The only difference is that MBR 6 has a fixed default partition or drive, independent of what was booted the previous time. The saving in code space this resulted in was used to extend the description length: MBR 6 supports descriptions of up to 12 characters (see figure 6).

2.9  MBRs 7 and 8

These two MBRs have the same functionality as 5 and 6, respectively, except where the hiding of partitions is involved. MBRs 5 and 6 hide all other primary DOS partitions when the OS/2 partition is booted, because OS/2 chokes on multiple primary DOS partitions. MBRs 7 and 8 hide all primary DOS partitions other than the one booted, no matter which one that is. This is done to cater for installations where e.g. DOS/Windows 3.11 and Windows '95 are both installed in their own primary partition, and should not be allowed to `see' each other. A reason for such a setup could be that older DOS disk utilities could damage the Windows '95 long filenames, and Windows '95 should not be allowed to write its long filenames to the DOS/Windows 3.11 partition.

In addition to this, the description strings are one character longer than those of MBRs 5 and 6.   


B. Drive 2  
C. Drive 3  
1. 123456789AB  
2. 123456789AB  
3. 123456789AB  
4. 123456789AB  
 
Boot?

Figure 7: The MBR 7 boot menu

B. Drive 2  
C. Drive 3  
1. 123456789ABCD  
2. 123456789ABCD  
3. 123456789ABCD  
4. 123456789ABCD  
 
Boot?

Figure 8: The MBR 8 boot menu



3  Options and installation

3.1  Before installing Boot Control

Before installing Boot Control, you should have already partitioned your harddisk the way you want to have it. Boot Control is no help here, and setting up multiple primary partitions can be a bit complicated - at least under MS-DOS. If you run a different OS that makes partitioning easier (such as Linux), you can skip this section. As an example, I will describe how to set up two FAT partitions, one for MS-DOS (possibly with Windows 3.x), and one for Windows 95. The main problem here is that MS-DOS's FDISK utility refuses to create more than one primary partition. You'll need either a disk editor, or the utility that comes with Boot Control (type5to6.com--see also section 5.5).

I'll assume we start with an unpartitioned harddisk. (Using a utility like FIPS [6] you may be able to resize an existing partition without losing your data--but it still is a wise thing to back up, just in case). Start FDISK, and create a primary partition, leaving room for any other partitions you may want. Then create an extended partition with the size you want to give your next primary partition. When FDISK asks you if you want to create logical drives in the extended partition, ESC out back to the FDISK options--don't define any logical drives! Exit FDISK; it will restart the system.

After rebooting, DOS will have reserved a drive letter for the first primary partition, but not for the extended partition. In fact, DOS will get confused by the fact that an extended partition exists with no logical drives defined. We must now change the extended partition into a normal primary partition. This is exactly what the utility type5to6 does. (An extended partition has type 5, a normal DOS partition has type 6). Type type5to6 drive, where drive is a drive number between 1 (for the first harddisk) and 8. type5to6 converts the first empty extended partition it finds to a primary DOS partition. After type5to6 is done, you must reboot the computer to make DOS reprocess the MBR. You can now format both primary partitions, and install the operating systems on it (since the Windows '95 installation program is very predatory, you may want to install it before installing DOS/Windows 3.x). Note that both the Windows 95 and the MS-DOS 6.22 installation programs overwrite the MBR with their own software, so it's best to wait with installing Boot Control until after you have installed either of them.

3.2  Getting help

When typing BC without parameters (or BC /?), a help screen (Figure 9) is displayed. If a commandline error is detected, the suggestion to type BC /? is usually displayed after a more specific error message.  


Boot Control V0.41 (C) Copyright 1995-1997 G.Klein  
 
Available options are:  
 
/i - Install new MBR  
     Use:  BC /i [mbr [drv] [/b file]]  
     Where  mbr is the number of the MBR you wish to install,  
            drv is the drive to install it to,  
        /b file sets the name of the file to save the old MBR to.  
     If the mbr parameter is not given, a list of available MBRs  
     will be presented. If the drv parameter is not given, the first  
     harddisk is taken.  
 
/s - Set current MBR options  
     Use:  BC /s [drv]  
     Where  drv is the drive who's MBR options you want to update.  
 
/r - Restore previously saved MBR  
     Use:  BC /r [drv] file  
     Where  drv is the drive to restore to and  
           file is the name of the file that contains the saved MBR.

Figure 9: The Boot Control help screen


3.3  Installation

Installing BC is as simple as typing BC /i [mbr]. The [mbr] is the number of the MBR you wish to install (see section 2 for a listing of the MBRs and their features). If you don't supply an MBR number, Boot Control will show you the syntax for the /i command, followed by a short list similar to the one in figure 10, showing the available MBRs and their main features. The columns show:

Type
The MBR number you must type in when installing.

Drives
If the MBR supports multiple drives: "1" if it can only boot the partitions on the drive it is installed to; "all" if it can boot all other detected harddisks; "select" if you can select which drives (if any) to show in the boot time menu.

Rewrite
"Y" if this MBR needs to rewrite itself to disk when booting, "N" otherwise.

Default
What partition the MBR defaults to: "1" for the first partition; "active" for the partition currently marked active; "any" for the last booted drive or partition; or "fixed" for a drive or partition selected at configuration time. Note that if the default is "active" and the MBR rewrites itself to disk (as in MBRs 2 and 3), this effectively means it defaults to the last booted partition.

Desc
The number of characters available for the partition names.

PC-MOS
If specific PC-MOS support is present in the MBR.

Hide
If the MBR hides other primary partitions than the one it is booting; "N" if it doesn't, "Y" if it does, and "OS/2" if it only does this if one specific partition (the OS/2 partition) is booted.

 


 
Type Drives Rewrite Default Desc PC-MOS Hide
0 (Standard MBR, no boot menu) N N
1 1 N active 11 Y N
2 1 Y active 8 Y N
3 all Y active 8 Y N
4 all Y 1 10 Y N
5 select Y any 10 N OS/2
6 select Y fixed 12 N OS/2
7 select Y any 11 N Y
8 select Y fixed 13 N Y
Figure 10: The MBR listing

If you want to install the new MBR to a drive other than the first one, you must supply the drive number too. Drives numbers start with 1, so to install MBR type 4 to your third harddisk you'd type BC /i 4 3.

If you want to have a safety backup of your original MBR (so you can restore it if things suddenly stop working), you can add /b file to the commandline. This makes Boot Control save the current MBR before it attempts to overwrite it. It is advisable to save the MBR to a bootable floppy, together with the Boot Control executable, so you can restore the MBR if the harddisk becomes inaccessible. (This can happen if you have large harddisk support software installed in your MBR--see section 1.3). To install MBR type 1 to the first harddisk, saving a copy of the original MBR to a file on drive A:, type: BC /i 1 /b a:\mbr.dat. The file will be created with the ReadOnly attribute set, to prevent accidental deletion. (If you are sure you want to delete the file, use the DOS ATTRIB command to remove the ReadOnly attribute. Note that Boot Control will overwrite an existing backup file without a warning, even with the ReadOnly attribute set).

After Boot Control has scanned the commandline and detected no errors, it saves the current MBR if so requested, and puts the configuration menu on screen. This is the exact same menu as under BC /s--see below for details. If you press ESC here, the installation is aborted (although the created backup file, if any, is not removed). Pressing ENTER makes Boot Control save the new MBR with the displayed defaults.

3.4  Setting MBR options

During installation, or if you type BC /s [drv] (the drive is optional and defaults to 1), you will be presented with the configuration menu. This menu is slightly different for each MBR, as not all options are available in all MBRs. A sample can be found in figure 11.  


Boot Control V0.41 (C) Copyright 1995-1997 G.Klein  
 
A - Color: harddisk letter   : B.       1 - Partition 1 : OpSys 1  
B - Color: default harddisk  : B        2 - Partition 2 : OpSys 2  
C - Color: harddisk string   : Drive 2  3 - Partition 3 : OpSys 3  
D - Color: partition number  : 1.       4 - Partition 4 : OpSys 4  
E - Color: default partition : 1.  
F - Color: partition name    : MS-DOS  
G - Color: boot prompt       : Boot?  
H - Color: selection         : 1  
I - Color: error message     : Error  
 
J - Timeout value            : 10  
K - OS/2 Partition           : <none>  
L - Default MBR/partition    : 1  
M - Valid drives to boot     : <none>  
 
Please select item to configure (ESC: Exit, Enter: OK)

Figure 11: The Boot Control configuration menu


Configurable items include:

The colors.
The colors of all strings in the MBR can be configured to your liking. To configure e.g. the color the partition names are displayed in, choose (in this example) F. The letter F in the menu will be highlighted so you can see what color you are changing, and the bottom line of the menu will change to read:

Left,Right: foreground; Up,Down: background; ESC: back out, Enter: OK

The bits of text after the colon are example strings, and are displayed in the current color. You can see the colors change as you press the Up or Down arrows to change the background, or the Left and Right arrows to change the foreground color. Pressing ESC aborts and restores the original color, ENTER confirms the current color and restores the bottom menu line to its previous state.

The timeout value.
Pressing (in this example) J will let you change the timeout value. The J in the menu will be highlighted, and the input field for the timeout value will change color. The bottom line of the menu will change to:

Enter new timeout value (1 - 3600) in seconds?

If the first key you press is a non-editing key (i.e., a number), the default value present in the input field will be erased and you can type in the new value. If the first keypress is an editing key (left or right arrow, home, end, backspace), the default value won't be erased so you can edit it. The timeout value can be set between 1 and 3600 seconds (1 hour). As usual, ESC aborts the input and restores the previous value, and ENTER confirms the input if it is in range. If the input is out of range or not a number, you are prompted again to provide valid input.

The partition names.
The most important item to configure: the name of the operating system installed on your partition. Boot Control defaults to "OpSys <n>", as it has no way of knowing what is installed on any partition. Only used partitions show up in this part of the configuration menu, so you can't assign a name to a partition before you've created it. You can edit the name by pressing the appropriate number; the bottom menu line will change to:

Enter new partition name (empty = don't show)?

The input field works the same way as that of the timeout value. It will only allow entries up to the maximum size that the MBR you're configuring allows. Other than that, you can put there whatever you want, including spaces.

In case you have a partition that you don't want to be shown in the boot menu (e.g., a Linux swap partition), you can prevent that by providing an empty name. Note that merely spaces is not considered empty! You can make sure an input field is really empty by pressing CTRL-Y.

The OS/2 Partition.
Some MBRs behave differently if the partition they have to boot contains OS/2 (see section 2.7). When configuring these MBRs, this option allows you to specify which partition that is. The appropriate menu item letter (in this example K) will be highlighted, and the bottom menu line will change to:

Enter OS/2 partition number (1-4, 0 = none)?

If the default was "<none>", it will change to "0". This indicates that OS/2 is not installed to any of the partitions. You can respond with either 0 for none, 1 - 4 for any of the four partitions, or ENTER to accept what's displayed.

The default MBR/partition.
If the MBR you are configuring defaults to a fixed partition or MBR, then this option allows you to specify which one that is. As usual, the appropriate option letter is highlighted, and the bottom menu line changes to:

Enter default partition or drive (1-4, A-H, Enter)?

Valid responses are 1-4 for any of the four partitions, A - H for any of the possible eight drives, or ENTER to accept what's displayed. Note that Boot Control doesn't check if the partition or drive you specify here exists. It will write whatever you type here to the MBR; if you have specified an invalid (empty) partition, the MBR will effectively have no default. If you've specified a non-existing drive, and the MBR times out at boot time (or you press ENTER or SPACE), then the MBR will try to load the MBR of that drive, fail, and display an error message - after which the process starts over again.

The valid drives to boot.
Some MBRs allow you to specify which drives (if any) should be displayed at boot time. You may have, for example, four drives, but only the first and the third contain bootable partitions. Using e.g. MBRs 3 or 4, all four drives except the current one (i.e., initially drive 2 - 4) will show up in the boot time menu. This option cures that cosmetic problem. The bottom menu line changes to:

Enter bootable drives (A-H, ESC, empty = none)?

Your input is the letter of every drive you want to show up in the boot menu (don't use spaces between them). When you are satisfied, press ENTER to set the new drive letters. Boot Control will redisplay them in uppercase and in alphabetical order. ESC restores the previous values.

Note that the menu letters in the above examples are not fixed. For every MBR a menu is built at run-time, consisting of only those options appropriate for that MBR. This means there is no fixed relation between the option letter and the option.

When installing or changing the MBR options, Boot Control checks the current MBR to see if it is a BC MBR. If so, it attempts to take all possible defaults from the installed MBR, so you don't have to retype the partition names or reset the colors to your liking. Default values can even be taken from a different type MBR (although it is not possible, of course, to e.g. take the color for the harddisk string from a type 0, 1 or 2 MBR).

3.5  Restoring a saved MBR

Boot Control includes an option to restore an MBR that you saved during installation. This is hardly ever required, as the MS-DOS FDISK /MBR command will also rewrite the standard MBR software. (Boot Control never alters the partition table, other than the active flag and (in some MBRs) the system indicator). One reason why you would want to restore the old MBR is that you had Disk Manager or similar software [23] installed (see 1.3). Another is that a virus has ruined your partition table (in which case you'd probably want to reinstall Boot Control after restoring the previous MBR).

The command to restore a saved MBR is BC /r [drv] file. The drive is optional and defaults to 1. Boot Control goes through a lot of trouble to assure you won't make a mistake and restore rubbish to the MBR. It checks that the file size is exactly 512 bytes, and refuses to restore from a file with any other size. It also refuses to restore if the last two bytes of the saved MBR don't contain the boot sector signature (55 AA). If the file appears to be a genuine MBR, it compares the partition table in the file with the current one. If they are not equal, a prompt appears asking you if you are really sure you want to continue. If you answer Y, the MBR is restored from the file.

To prevent error messages to occur if the only difference between the saved MBR and the current one is that the active flag is set to a different partition, or that different partitions are hidden, Boot Control checks the partitions as follows:


4  Technical details

This section is not required reading to use Boot Control; it is merely intended to provide some more detailed information for those interested.

4.1  Booting

After doing all sorts of self tests and initializations, the BIOS of a PC will attempt to load the operating system from disk. It does this by reading the first disk sector of drive A: (the first floppy drive); if this fails, it attempts to read the first sector of the first hard disk. (Some BIOSes let you change the order in which booting is attempted, e.g. C: first, then A:). Control is then passed to the loaded boot sector; this is called booting.

The first sector of a floppy disk is called the boot sector. Under MS-DOS, it contains information on the disk characteristics, and some code that loads (part of) IO.SYS to memory. Under other operating systems things may be different--the BIOS doesn't care about the contents of the boot sector, although most BIOSes do check for a 55 AA signature at the very end of the boot sector; some also want to see a jump instruction at the beginning of a floppy boot sector. Hard disks are organized a little more complicated.

4.2  The Master Boot Record

The first sector of a hard disk is called the Master Boot Record. The MBR also contains some code, and the partition table. The BIOS loads it in the same way as a floppy boot sector.

The Partition Table in the MBR is a way of dividing a hard disk in sections, called partitions, that can be treated as completely separate disks. It has four entries, each of which describe:

The code in the MBR does some rudimentary validity checking on the partition table, and determines which one is marked active. It then loads the first sector of that partition to memory, and starts executing its code. The first sector of a partition is called the partition boot sector. The boot sector of an MS-DOS partition contains the exact same code as that of a floppy disk boot sector, and does the exact same thing: locate and load (part of) IO.SYS.

There are two basic partition entries: primary and extended (primary partitions that don't have their active flag set are sometimes called secondary partitions. I don't use that terminology in this documentation). Primary partitions directly describe a partition, extended partitions describe a segment of the disk that contains another MBR with a partition table (see section 4.4).

4.3  Cylinder-Head-Sector translation

Sometimes the partition table doesn't reflect the true disk geometry due to Cylinder-Head-Sector translation, or CHS translation for short. This is a work-around for the infamous 504 MB IDE harddisk size limit. In case you are wondering where that comes from: all operating systems rely upon the BIOS for disk I/O, at least during booting. (MS-DOS keeps using BIOS, other (protected mode) operating systems, once booted, provide their own drivers). The BIOS disk I/O interface accepts 10 bits for the cylinder number (or at most 1024 cylinders), 8 bits for the head number (or at most 256 heads), and 6 bits for the sector number (or at most 63 sectors). Given a sector size of 512 bytes, the maximum harddisk size using the BIOS interface is therefore:

1024 * 256 * 63 * 512 = 8455716864 bytes, or almost 8 GB.
Unfortunately, the IDE interface itself has some limitations too. It accepts 16 bits for the cylinder number (or at most 65536 cylinders), 4 bits for the head number (or at most 16 heads), and 8 bits for the sector number (at most 255 sectors). Combining the two interfaces gives the following maxima: cylinder: 10 bits (1024); head: 4 bits (16); sector: 6 bits (63). Using these maxima, the maximum supported IDE harddisk would be:
1024 * 16 * 63 * 512 = 528482304 bytes, or 504 MB.
In these days, this is clearly an unacceptable limit. The CHS translation provides a temporary answer by pretending that the disk geometry is different from what it really is. Since the IDE interface can only handle at most 16 heads, 4 of the 8 bits of the head number in the BIOS interface are unused. On the other hand, 4 of the 16 bits of the IDE interface's cylinder number are inaccessible through the BIOS interface. Hence, the CHS translation algorithm effectively says:
while the number of cylinders is greater than 1024
    divide number of cylinder by two
    multiply number of heads by two
So, if you have a harddisk of 2048 cylinders, 16 heads, and 39 sectors, the BIOS would pretend (to DOS) that it is 1024 cylinders, 32 heads, and 39 sectors instead. The harddisk size doesn't change, but DOS suddenly can access the entire drive. The maximum IDE drive size that can be supported with CHS translation is a little under 8 GB. (Usually, the logical geometry a harddisk reports has little or nothing to do with the physical geometry anyway).

Numbering sectors sequentially, as done on SCSI drives, makes much more sense, and will be the future standard. Using sequential numbering, 32 bits are available for the logical sector number, which allows for drives up to 2 TB (TeraByte) - sufficient for a while. The Logical Block Addressing you may have heard of is part of this new standard: it defines how to use 32 bit sector numbers in the interface between the BIOS and the drive. Note that the interface between DOS and the BIOS doesn't change, and hence LBA mode is not in itself a solution to the 504 MB problem. Most BIOSes do present nicely translated drive parameters when you turn on LBA mode, though.

Unfortunately, most BIOS manufacturers started including CHS translation in their BIOSes very late, and many people are stuck with a BIOS that doesn't support the larger drives. This is why many harddisk manufacturers started to deliver special programs [23] with their harddisks, that intercept disk I/O and perform the translation before passing the calls on to the BIOS. These programs must be located in the MBR of the drive, so any subsequent disk activity (like loading the operating system) will be done with the translated disk parameters. The partition table will also contain the translated parameters. If the MBR code isn't executed, the partition table will still contain the translated values--but the translation is no longer there. This can make the disk completely inaccessible, which is what happens when you install Boot Control over the MBR containing the translation software. (Further reading on all this and more can be found in the Enhanced IDE FAQ [4]).

4.4  Partition Types

Many different system indicators exist. A comprehensive list can be found in the interrupt list [1] (look under int 19h); we'll describe a few here.

As all partitions are treated as completely separate logical drives, it is possible to put whatever you want on them. For example, you can have a partition containing an MS-DOS file system, and another one containing Linux's second extended file system. MS-DOS won't recognize the Linux partition, and will completely ignore it. (Linux can be made to recognize the MS-DOS partition, though). The MBR software will boot (i.e., load the first sector of) the partition with the active flag in its partition table entry set. This means that you normally can have up to four different operating systems on one harddisk. Setting the active flag is normally done with an FDISK-like utility.


5  Miscellaneous

Some miscellaneous notes; please read at least the first two, as they warn you of possibly serious problems.

5.1  Changing drive assignments

If one of Boot Control's MBRs is installed to a drive, and the drive is subsequently assigned another drive number (e.g. by switching master and slave drives on the IDE bus), you probably won't be able to boot from it. This is because the drive number is hard-coded in the MBR. You will be able to access the drive, though, and the remedy is as simple as running BC /i or BC /s.

Please note that if you don't refresh the MBR code, and the MBR is one that rewrites itself, it will rewrite itself to the old drive number it used to have next time you boot it! This includes overwriting of the partition table, and can make the other drive completely inaccessible! For a more concise explanation, see the next section.

5.2  Removable drives

If you have a system with removable drives, you will need to take extra care when planning your setup, and may not be able to use Boot Control at all. This is because all Boot Control MBRs, for space reasons, have the BIOS number of the drive they are installed to hardcoded in themselves. If these numbers change, due to adding or removing a removable drive, Boot Control will still use the old number, with possible disastrous consequences!

An example: a system with one SCSI drive, and one removable IDE drive. If the IDE drive is not present, the SCSI drive will have drive number 80h (BIOS starts counting harddrives at 80h). If a Boot Control MBR is installed, it will know this drive number, and use it to load the configured partition bootsectors. So far, so good. Now, the IDE drive is inserted. Most likely, the BIOS will assign it the first drive number (before the SCSI drive), so the IDE drive will have number 80h, and the SCSI drive will now have number 81h.

If Boot Control is now installed to the IDE drive with an MBR that allows to boot other drives, disasters can happen! If you select the option of booting the other drive, that MBR (of the SCSI drive) is loaded. It will give you it's usual options, but when you select one, it will try to load the first sector of the partition you selected as indicated in the partition table -- but from the first drive! This will usually not be a boot sector on that drive, and will probably result just in an error message. Much worse things will happen if you installed a Boot Control MBR that rewrites itself to disk. Since it still believes to be installed to the first drive, it will rewrite itself to that drive -- which is now the IDE drive! This means the MBR, including the partition table, of the SCSI disk will be written to the MBR of the IDE disk. This will most likely make the entire disk inaccessible, and if you've not used the /b option when installing Boot Control (saving a backup copy of the MBR), you are in big trouble.

In general, only use Boot Control on systems with removable drives if you know exactly what you're doing, and please be sure to make backup files so you can undo any possible damage.

5.3  Tested with. . .

I have tested Boot Control with MS-DOS 5.0 and 6.22, several Linux distributions and kernel versions, PC-MOS 5.1, Windows NT 3.5 and Windows 95, and OS/2 3.0. Of course, I haven't tested every possible combination of these OS', but I've had each one of them installed in its own primary partition, and they coexisted peacefully. Keep in mind, though, that some operating systems are very unpleasant when being installed. When installing Windows 95 or MS-DOS 6.22, the installation code overwrites the MBR with its own code without asking or even telling you. Fortunately, once installed, it no longer objects to Boot Control's presence, and you can simply reinstall it. A note on Linux: you can still use LILO to pass parameters to the kernel, or choose between different kernel versions, or use any of its other (many) features: just install it to the partition Linux is installed to (e.g. /dev/hda4, not /dev/hda).

As Boot Control needs to access the MBR directly, installation is unlikely to work under any kind of protective OS. If you run one of these, you may be able to shut down to plain DOS mode (as in Windows 95); otherwise you have no choice but to boot from a DOS floppy. Remember to turn off (and, for most MBRs, keep off) the BIOS MBR virus protection!

5.4  Drive letter issues

If you have created two primary DOS partitions, and installed Boot Control, you may be surprised to find that when booting from the second partition you still booted from `C:'. This has to do with the rather complicated way DOS assigns drive letters. It does that according to these rules:

This means that whatever partition you boot from will be `C:'. This can be a bit inconvenient if you want to run programs on both partitions regardless of which partition you booted from, since a program installed on partition 1 will find itself on e.g. drive D: when booting from partition 2. There are several ways of dealing with this, depending on your particular hardware.

One option is to create an extended partition somewhere, and move all programs you want to share there. As the number of active partitions normally won't change (only which ones are active), the first extended partition will always have the same drive letter. In my personal setup I use the first primary partition on the second harddisk (which is always active) to hold all the shared programs. This partition is always drive `D:'. Yet another option is to find a drive letter swapping utility (if you are using MS-DOS 5.0 or below, you could try assign), and call this utility in autoexec.bat to make sure the drive letters are the same no matter what partition you boot from. As can be seen from all this, creating multiple (primary) DOS partitions probably requires careful planning.

5.5  type5to6.com

This section gives a more detailed description of the utility type5to6 that comes with Boot Control (section 3.1 gives a practical example of its usage). It is a small program to help people without a disk editor and only DOS's FDISK to create multiple primary (bootable) DOS partitions, as FDISK won't let you do that. The basic idea behind it is to let FDISK create an extended partition, and then convert that extended partition to a primary partition by changing the system indicator from type 5 (extended partition) to type 6 (BIGDOS partition). When started without parameters, type5to6 gives the help screen shown in figure 12. The drv parameter must be a number between 1 and 8.  


type5to6 V1.0 (C) Copyright 1996 G.Klein  
 
Usage: type5to6 drv  
 
drv is the drive to check for an empty partition with type 5.  
It will be converted to a BIGDOS (type 6) partition.

Figure 12: The type5to6 help screen


The program does a few sanity checks to prevent catastrophic errors (as changing the wrong extended partition). It insists that there are no logical drives defined in the extended partition. The way it checks this is this:

If an error is found on the commandline, type5to6 will display

Commandline error:

followed by the part of the commandline it disapproves of. Other error messages are:

5.6  Timer quirks

Boot Controls MBRs use the system timer counter to measure how much time has expired since the system booted. This is a simple counter that gets updated about 18 times per second. In order to minimize the amount of space required for the timeout code, the counter value at timeout is calculated, and then the code continuously checks for this specific value. This has a few consequences:


 References

[1] Ralf Brown's Interrupt List is an indispensable online document that can be found on many FTP sites, including on Simtel in the directory msdos/info.
[2] More information on Ontrack's Disk Manager can be found at:
http://www.ontrack.com/.
[3] More information on Micro House's EZ-Drive and DrivePro can be found at:
http://www.microhouse.com/
[4] The Enhanced IDE/Fast-ATA/ATA-2 FAQ by John Wehman (jwehman@got.net) and Peter den Haan (pieterh@sci.kun.nl) can be viewed at and downloaded from
http://thef-nym.sci.kun.nl/~pieterh/storage.html
[5] The latest version of Werner Almesberger's LILO can be found at:
ftp://lrcftp.epfl.ch/pub/linux/local/lilo/ (primary site), or
http://sunsite.unc.edu/pub/Linux/system/boot/lilo (or one of its many mirrors). The documentation that comes with it explains the boot process much more comprehensively than this document.
[6] Information on Fips, and the program itself, can be found at:
http://www.igd.fhg.de/~aschaefe/fips/.


 About this document

This document was converted from the LaTeX source with an alpha version of the utility "TeX4ht". For more information about TeX4ht, please view the web page at http://www.cis.ohio-state.edu/~gurari/TeX4ht/mn.html, or contact Eitan Gurari (gurari@cis.ohio-state.edu), the author.


Gertjan Klein (gklein@xs4all.nl)