Bienvenido! - Willkommen! - Welcome!

Bitácora Técnica de Tux&Cía., Santa Cruz de la Sierra, BO
Bitácora Central: Tux&Cía.
Bitácora de Información Avanzada: Tux&Cía.-Información
May the source be with you!

Sunday, July 4, 2010

Guide to the Multiboot Process


The XP and Vista boot process in general.
The Windows dual and multiboot method of operation.
The limitations of the Windows method and some alternatives.
How third-party bootmanagers operate.

logo-7The information on this page also applies to Windows 7 - except where indicated.
What follows may seem over simplified, but it is just about all you really need to understand.
The Boot Sequence Programs
The first program is built into your computer's motherboard. It is on a small chip and so is always in the same place so that when the computer is turned on it knows where to find it. This program is called the BIOS. It will do its job and then look for and start the next program. The BIOS is pretty clever and can actually search for the next program and look in various places for it. Normally it will find it all by itself, so you don’t usually have to do anything, but you do have the option if need be of setting the BIOS boot order so that it will look in the place you want it to – floppy, CD, hard drive, etc.
If you are booting an OS on the hard drive then the next program is, unsurprisingly, on the hard drive. To make it easy for the bios to find the second program it is always put in the same place and the bios will only look in that place. It is always right at the very beginning of the drive, starting on the first bytes of the very first sector. This program is commonly called the MBR (Master Boot Record), but this is a little misleading because the MBR is actually the bootprogram and the partition table. The most common name for the bootprogram part of the MBR is the Initial Program Loader (IPL). Just like the BIOS program the IPL is often not specific to any OS, so it won't care if it’s Windows or Linux that is on the hard drive, it only wants to start the next little program. The Microsoft IPL is very small and quite limited and its main job is just to find and start that next program in the chain. It looks at the partition table to see if any of the entries there is waving a flag in the air and shouting - Pick Me! If the IPL sees a partition that is pointing to itself then it goes to the first bytes of that partition and starts the little program that it finds there. If you take the flag away from one partition and give it to another then the IPL will then pick that partition and start that one’s little program. When you move the flag you are not changing anything else about a partition or its details in the partition table, you are literally just moving a pointer that tells the IPL which partition to pick. The partition with the flag is called the Active partition, so changing or setting the active partition is simply moving a pointer, (the correct tech-speak is actually flag).
The third little program in the chain is at the very beginning of the partition. This one is called the PBR (partition boot record) or in some cases it can be called the VBR (volume boot record). Now the PBR will do its job and then start the next program. However, unlike the BIOS and IPL, the PBR is operating system specific and needs to know the name and location of the file it has to start. This next file will be different for various operating systems, so during the install of an OS the PBR will be written with the information necessary to find the correct file. For WinNT before Vista this will be ntldr, which will always just be in the root of the partition. That is it will not be inside any folder or directory, but just right there on its own, next to the Windows and Program Files folders.
For all WinNT before Vista the ntldr will be the 4th and last program in the boot sequence chain. It's called the bootloader and it is the one that does the actual job of starting Windows from the System32 folder. (The ntldr also has the auxiliary function of a bootmanager which can with the aid of a partition list held in the boot.ini start a Windows OS on a different partition to the one it is itself on).
For Win 2K/XP etc the boot sequence is:- BIOS - IPL - PBR - ntldr - Windows
boot sequence
In these graphics the MBR is shown as a separate section at the very start of the hard drive. It is indeed separate and not connected in any way to the following partitions. Convention is to reserve a small section of the drive specifically for the MBR to reside on. I’ve shown the PBR as a separate section but it is actually a part of the partition it is in. Windows reserves the first 16 sectors of its partition to be used exclusively for the partition boot record.

The Vista and Win7 boot sequence is slightly different because ntldr has been superseded. In old WinNT the ntldr was both bootmanager and bootloader, but from Vista these two functions have been separated out into two different programs. The bootmanager function of finding and selecting the OS to be started is now called bootmgr. The bootloader function of actually starting the OS is now a new file called winload.exe. The bootmgr program stays in the root of the partition and winload.exe has been placed inside the System32 folder alongside the Windows OS it has to start. This has added an extra step to the boot sequence chain, so in Vista it is the 5th program that starts Windows.
Vista boot sequence:- BIOS - IPL - PBR - bootmgr - winload.exe - Windows.
Vista boot sequence

Given free reign at install time Windows 7 may create a separate small partition just for the BCD and bootmgr files. See – Installing Win7. This is not essential for the operation of Win7 and Microsoft have said it was only introduced now so we can become familiar with the concept ahead of them making it standard practice for Windows on EFI firmware machines.

Dual-Boot Sequence
If you install Vista to a computer that already has a legacy WinNT installed on it and you don't take precautions to the contrary, then the Microsoft bootmanager will be automatically configured for dual booting. The previous Windows install will be modified to accommodate the method of operation necessary for bootmgr and ntldr to coexist. The boot sequence for Vista will be just as it was in the example above when Vista was the only OS on the hard drive. The same 5 programs run in the same order.
Vista dual boot sequence:- BIOS - IPL - PBR - bootmgr - winload.exe - Windows.
Vista dual boot
Notice however that the Vista install has placed bootmgr and the BCD file on the partition of the previous Windows install. Also that the XP partition's PBR has been replaced with a Vista one, so that it knows to look for bootmgr instead of ntldr. On bootup it will be bootmgr that will halt the process and offer the boot menu. On selecting Vista, bootmgr will jump directly to winload.exe in the Vista System32 folder, skipping the Vista partition PBR. The Vista partition may or may not get a valid PBR but this won’t be used anyway as part of the boot sequence chain. If you did at this point change the Active partition so the IPL would directly start the Vista partition's PBR, you would just get an error message that something was missing.
When you select the XP install from the dual boot menu the boot process will have changed slightly from the sole XP install shown above because bootmgr will have inserted itself in the chain. This adds an extra step and so XP now also has 5 programs in the sequence.
XP dual boot sequence:- BIOS - IPL - PBR - bootmgr - ntldr - Windows.
xp dual boot

In old WinNT the ntldr consults the boot.ini file to find out which hard drive and partition it needs to look on for the Windows/System32 folder it has to target. The ntldr then uses the BIOS to locate the hard drive and the Partition Table to locate the partition. In Vista and Win7 the bootmgr consults the BCD file to find out which hard drive and partition it should go to, but it does not use the BIOS or the partition table to locate the drive or partition. See Vista's Boot Files

Multi-Boot Sequence
If you already have a Windows dualboot and then add Vista as a third OS then you will not get three choices from the new Vista boot menu, because the original ntldr will continue to be used to select which of the old OSes to boot. Each of the bootmanagers in the chain will offer separate boot menus. Vista's bootmgr will offer 2 choices of Vista and previous OSes, then ntldr will display your original boot menu. Overall the multiboot sequence is no different to the dualboot one. Both bootmgr and ntldr will always be on the active partition of the boot hard drive and both will ignore PBRs and jump directly to Windows in the System32 folder. (The ntldr has also always skipped PBRs).
In the example below the sequence for the first and third partitions will be as the last two examples above. The middle partition Windows will be started as it originally was by the ntldr on the active first partition, except of course with bootmgr now in the chain.
Sequence for all old WinNT is the same:- BIOS - IPL - PBR - bootmgr - ntldr - Windows.
No matter how many Windows OSes or hard drives you have the boot sequence will always be the same and only the boot drive active partition will have an ntldr and bootmgr, through which all the others must be booted. Each Vista and will be started by bootmgr and each of the older WinNT will be started by ntldr.
Vista sequence is the same as always:- BIOS - IPL - PBR - bootmgr - winload - Windows
2drive multiboot

With no ntldr or bootmgr on the second hard drive then it cannot be made the boot drive in the computer and have any of its OSes directly started. An install of Vista to a second or higher drive will only write a Vista IPL to that drive's MBR if there is no IPL already present, so an older WinNT IPL will be left in place. If you do need to get such a drive to be bootable then any Windows IPL since Win9x is capable of starting a Vista PBR. The main thing to be aware of is that there might not be any partitions on the drive flagged as active, so the IPL will stall when it does not know where to look for a PBR.
Vista partitions on any hard drive might not actually have valid Vista PBRs which have been written correctly to look for bootmgr. If a PBR was present on the partition during the Vista install then it may be left in place. I haven’t tested all scenarios but an old WinNT PBR on an NTFS partition always seems to be left alone, which of course will point to ntldr instead of bootmgr. If you want to avoid this either make sure the partition is not formatted before the Vista install and so won't have a PBR, or format it only from Vista.
To make all your OSes independent and with their own boot programs on their own partition then you do of course have to install Windows in the correct manner. See "How to Install Vista and Avoid Changes to Other Operating Systems" on this page. (Similar rules apply for most WinNT OSes).

MBR Bootmanager
Dedicated Partition.
The next best option is a bootmanager that you keep on its own small dedicated partition, often at the start of the boot hard drive, but some will use a logical partition. Even though this may sound similar to the way ntldr and bootmgr operate it does not usually require the partition to become a system partition, so each Windows install can still be independent with its own ntldr or bootmgr and loaded by its own PBR. The bootmanager partition will always be the one started by the IPL. Be aware however that most bootmanagers of this type still replace the Microsoft IPL in the MBR so that it will always target the bootmanager partition at computer startup. The Active status of partitions will be ignored by the new IPL and will instead be controlled and changed by the bootmanager itself when you make your booting choice. Many of the issues relevant to pure IPL bootmanagers can also therefore apply to dedicated partition bootmanagers.
partition bootmanager
The size of the bootmanager partition shown above is of course not to any scale and in reality is usually very small. There are several of these types of bootmanagers around, each offering varying features. I've tested XOSL, BootMagic, Acronis OSS and BootIT-NG, all of which can work with Vista, but a couple have serious issues you need to be aware of. See the bootmanager page for specific details.

Inside a Current OS.
Most dedicated partition bootmanagers can also be installed inside a current OS. They will change the PBR of that OS so that it will load the bootmanager instead of the operating system's own boot files, they also of course change the IPL in the same way as a dedicated partition bootmanager. When you select a boot option they will either start the boot files of the OS they are in, or the PBRs of the other OSes on the computer. Again there is usually no system partition and each Windows install can be independent.

No comments: