Boot Loaders - An Introduction
Boot Loaders - An Introduction
Barry Nauta
1 Introduction 5
2 The Bootloader 7
2.1 Bootstrapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 Partitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3 Bios/Mbr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3.1 Volume Boot Record . . . . . . . . . . . . . . . . . . . . . 10
2.4 Efi/Gpt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.5 MBR, GPT - Side by Side . . . . . . . . . . . . . . . . . . . . . . 12
2.6 Bootsector virus . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3
4 CONTENTS
4 Some experiments 27
4.1 Dualboot: Xp and then Vista . . . . . . . . . . . . . . . . . . . . 27
4.2 Dualboot: Vista and then Xp . . . . . . . . . . . . . . . . . . . . 28
4.3 Multiboot: Xp, Vista, 2008, Linux . . . . . . . . . . . . . . . . . 30
4.3.1 Step 1: partitioning . . . . . . . . . . . . . . . . . . . . . 30
4.3.2 Installing Windows Xp . . . . . . . . . . . . . . . . . . . 30
4.3.3 Installing Windows Vista . . . . . . . . . . . . . . . . . . 31
4.3.4 Installing Windows 2008 Server . . . . . . . . . . . . . . . 32
4.3.5 Linux installation . . . . . . . . . . . . . . . . . . . . . . . 33
4.3.6 Multiboot installation conclusions . . . . . . . . . . . . . 33
C Utilities 39
D Glossary 41
Chapter 1
Introduction
This document is the result of a study performed for the course “Operating
Systems and Security”. The course is given at the “Vrije Universiteit Brussel”
(Vub) by Prof. Timmermans as part of the study “Master in applied computer
sciences”.
As the title suggests, this article is an introduction on bootloaders. There are
many operating systems and many bootloaders available, what you will find in
this document is a small explanation on Bios/Mbr versus Efi/Gpt architec-
tures, and some explanations on the bootloading process using Ntldr, Bcd and
Lilo/Grub. Additionally, there are some experiments by using multiboot sys-
tems on common operating systems including Windows Xp, Windows Vista and
Linux (Ubuntu). The experiments are all based on the Bios/Mbr architecture.
5
6 CHAPTER 1. INTRODUCTION
Chapter 2
The Bootloader
When a computer is turned on, the first thing it does, is loading a small program
into memory, which aids in choosing and loading the desired operating system
(Os). This process is called ‘bootstrapping’ or ‘booting’ in short. The program
that is initially loaded is called the ‘bootloader’.
2.1 Bootstrapping
2.2 Partitions
Hard-disks are often divided into partitions, which is a physical division of the
disk. There are several reasons to use partitions, the most obvious for the boot-
process is the use of different operating systems. Different operating systems are
often placed on different partitions since they may have a similar file structure or
even files that may cause conflicts (a good example is the c:\Windows directory
for Windows Xp and Windows Vista, those operating systems cannot coexist on
the same partition) or that they have a different filesystem (for example Ntfs
for Windows Xp and Ext2 for Linux).
When a computer starts up, it needs to know which partition contains the op-
erating system that will be started. On Ibm-Pc architectures, this information
can be found in the Master Boot Record (Mbr), a small segment on a harddisk
that can be found in front of the very first partition. On newer architectures
(Itanium), this information can be found in the Guid Partition Table (Gpt).
Both the Mbr (in combination with the Bios) and Gpt (in combination with
Efi) will be discussed in more detail in the next sections.
7
8 CHAPTER 2. THE BOOTLOADER
The Bios is the only available software (more precise: it is firmware; software
that is embedded in hardware) available to a personal computer when it has
not yet booted.1 When a computer starts, the Bios loads and executes a small
program (the bootstrap program) which resides in the Master Boot Record
(Mbr).2 This program is also called the “Master Boot Code” (also known as
‘Initial Program Load’ (Ipl) . a term that comes from the Ibm mainframe
systems. 3
The “Master Boot Code”, on its turn, reads the partition table that resides at
the end of the sector. The partition table is used to determine which partition
is bootable.4 It is, of course, the bootable partition that must contain the stage
2 boot-loader (more on this later).
The Ibm-Pc architecture supports up to 4 primary partitions. The Mbr ac-
tually has a partition table that is split into 4 entries. If more partitions are
needed, one of those primary partitions can be changed to an extended partition
which can on its turn contain 24 logical partitions.
1 The Bios is basically a set of basic instructions (machine code) that enable the commu-
nication between the hardware and the operating system that is going to be loaded.
2 The Master Boot Record (also called the ‘partition sector’ or the ‘master boot block’) is
the first physical sector of the first boot device. The boot device is usually a hard disk, but
it can also be a floppy disk/Cd-Rom etc.
3 These terms are often used in an ambiguous way; the Ipl is sometimes confused with the
Mbr and vice versa. The Mbr is actually the combination of the Ipl and the partition table.
4 One (and only one!) of the four partitions in the Mbr partition table can have an ‘active’
status, indicating that this is the partition to use when a computer is booted.
2.3. BIOS/MBR 9
Each logical drive in the extended partitions has an ‘Extended Boot Record’
(Ebr), which describes the partitioning of the logical drive. The Ebr is also
called the ‘Extended Partition Boot Record’ (Epbr), it will always be located
on the first sector of the extended partition.
The primary partitions are limited and they are all described in the partition
table in the Mbr. This is not the case for extended partitions and since there
can be many logical partitions, each Ebr is placed in the beginning of a logical
partition. If there are multiple logical partitions, the preceding partition will
contain a pointer to the next logical partition (Ebr).
10 CHAPTER 2. THE BOOTLOADER
A Volume Boot Record (Vbr) (also know as the Volume Boot Sector) or “Pri-
mary Boot Record” (Pbr) is a type of bootsector. On non-partitioned devices
(and thus also external devices), the Vbr is the first sector of the device, on
partitioned devices, it is the first sector of any specific partion (in this case, the
first sector of the device itself is the Mbr).
The process of a bootloader invoking the Vbr is known as ‘Chainloading’, going
from the first stage to the second stage.
The Efi system partition (the partition that contains the bootloader programs
for all operating systems that are installed on the system) is formatted in a Fat
variant.
12 CHAPTER 2. THE BOOTLOADER
The following picture gives an overview of the partitions of a disk for an ibm-pc5
architecture (Mbr disk), compared to an Itanium6 Gpt disk (source: 5).
A bootsector virus is a virus that infects the very first sector of a disk (floppy
disk or hard disk). The first sector of your hard-disk is your bootsector and it
contains the Mbr. Since the Mbr is executed every time your systems starts,
the virus can be very harmful. Once the Mbr is infected, the virus loads into
memory and can infect every hard disk, or external disk, known to the system.
Bootvirusses were typically spread via infected floppy disks. When a user left a
floppy disk accidentally in the drive, the next time the system booted, it tried
to boot from the floppy (this is a feature that can nowadays be (de)activated
in the Bios) and the virus kicked in. 7 Any antivirus software is sufficient to
clean an infected bootsector/Mbr.
5 ibm-pc or x86 stands for the 32-bit instruction set architecture that is binary compatible
with the 80386, a microprocessor which has been the most commonly used processor for
personal computers from 1986 up until now (end of 2008).
6 Itanium is the brand name for Intel 64-bit microprocessors that implements the Intel
Itanium architecture (which was, despite the name, originally developed by Hewlett-Packard
(hp))
7 In the past, a lot of floppy disks were bootable, but a floppy disk does not need to be
Bootloading an operating
system
This chapter describes from a high-level point of view, the different steps in the
booting process of some of the major operating systems. First the differences
between the Bios and Efi startup processes are explained, after which the boot
processes of some of the major operating systems are examined.
3.1 BIOS
In a few words, we could say that on startup, the Bios runs a Post (Power-On
Self Test) to check for the availability of some vital hardware and executes the
Mbr afterwards. The full steps are shown below:
1. The computer is switched on, the (x86) Cpu is programmed to look at the
address FFFF:0000h, the last 16 bytes of memory in the first megabyte.
This address contains a jump (jmp) command to the Bios.
2. The Bios runs the Post. During this process (hardware vendor depen-
dent), a video Bios, a check for a warm/cold boot (a warm boot indicates
that a large part of the Post can be skipped)
3. Sets up the interrupt table containing the addresses to the interrupt rou-
tines. Interrupt 13 is the most important of these interrupts, it contains
the Bios fixed disk (native I/O) services.
4. Initializes (after performing some tests) vital hardware like the Cmos
(Complementary Metal–Oxide–Semiconductor; a special memory-chip
that stores information like the boot-order, system-clock etc), the Dma
(Direct Memory Access), controller, the keyboard controller, and the like.
13
14 CHAPTER 3. BOOTLOADING AN OPERATING SYSTEM
7. Finally, the Bios looks for a boot sector (Vbr) 1 on an external device,
or the Mbr on a hard disk (this option can usually be set in the Bios,
although this was not the case for older systems) and copies it to address
0x7c00.
3.2 EFI
On machines with Efi firmware, it is the firmware itself that contains a boot-
manager. It is the BootRom that performs a Post. Efi takes care of basic
hardware initialization and the selection of the actual operating system to start.
The Microsoft boot-manager entry is called “Windows Boot Manager” and can
be found at the following location: \EFI\Microsoft\Boot\Bootmgfw.efi. On
Macintosh machines, the file called /System/Library/CoreServices/boot.efi.
Since the Efi is modular and the specification an interface, each vendor provides
a different version. Microsoft even implements a second bootmanager with its
own menu with boot options.
3.3 Microsoft
Microsoft has three generations of bootloaders. The first one loads Dos based
operating systems like Dos itself, Windows 3.x and Windows 95/98. The Win-
dows Nt generation (version 4 and 5) include a new bootloader called Ntldr.
Windows Vista and Windows 2008 use Bcd as bootloader.
1 A VBR is the first sector of a device that has not been partitioned, or the first sector of
Once the Bios has completed its initialization phase, the boot process looks for
the bootable partition and starts the operating system by invoking the operating
system files (io.sys, msdos.sys and command.com)
1. The Bios loads the Mbrs boot code and executes it. It looks for the
boot device, if the device is a hard-disk, some additional steps (examining
the master partition table including retrieving information on extended
partitions) are performed:
(a) If the master boot code has found an extended partition, the extended
partition table will be loaded. This table lists the logical volumes in
the extended partition. The extended partition tables of the logical
volumes are chained, the process uses this feature to find and load
all extended partitions.
16 CHAPTER 3. BOOTLOADING AN OPERATING SYSTEM
(b) Once the (optional) extended partitions have been loaded the master
boot code tries to boot the active (primary) partition, resulting in
error codes on failure.
3. The Volume Boot Code inspects the disk from which it boots, resulting
in error codes on failure.
4. The root directory of the device that is used for booting must now contain
three files: (io.sys, msdos.sys and command.com) (If these files are not
found, an error message is displayed)
5. The boot program loads the three operating system files into memory and
executes them. The files, on their turn, load the command interpreter and
the system control files (config.sys and autoexec.bat)
The kernel image was implemented in two files (io.sys and msdos.sys) in older
Dos versions, Dos 7 implemented the kernel image in one file (io.sys). The
file msdos.sys was transferred to a text-based configuration file.
For the windows systems, the last line of the autoexec.bat called the file
win.com which on its turn loads the Windows kernel (krnl386.com) and some
additional modules. The Windows kernel finally loads the primary shell (progman.exe
for Windows 3.x, explorer.exe for later versions)
Since the windows kernel is loaded from the autoexec.bat file, this file can be
used to implement some sort of bootmanager. Different bootoptions are shown
in the accompanying image.
NTLDR
Ntldr has some tasks to perform before the user can select the actual operating
system to boot:
4. The loader reads the boot.ini file and presents the user with a menu,
based on the configuration in the boot.ini file. If this file is not present,
3.3. MICROSOFT 17
the system assumes default values, prints an error message and continues.
If only one boot option is present in the configuration file, the system
reads the configuration and continues without presenting the menu to the
user.
5. Ntldr loads the operating system that is selected by the user. If the
selected operating system is any of the ones mentioned in this section,
Ntldr set’s up the hardware and loads and executes ntdetect.com. For
other operating systems, the control is passed to the file bootsect.dos,
or any other bootloader.
6. ntdetect.com (osloader.exe on Risc systems) scans the hardware and
gives the discovered list to the Ntldr which loads ntoskrnl.exe and
gives it the list previously received. We now enter the Windows Load
Phases.
The Windows Load Phases for the mentioned systems can differ slightly from
one to another, however the general sequence for the mentioned systems consists
of the following:
18 CHAPTER 3. BOOTLOADING AN OPERATING SYSTEM
The ‘Kernel Load Phase’ loads the ‘Hardware Abstraction Layer’ (Hal, found in
the file hal.dll) and the registry is loaded and checked for additional needed
device drivers. ntoskernel.exe is loaded (but not executed). Ntldr now
initializes the kernel and passes control to it.
The drivers that were loaded in the ‘Kernel Load Phase’ as well as the kernel
itself are initialized. The registry hardware list is created with the information
collected by ntdetect.com.
The session manager is started who’s task is to check all programs that must be
started. The paging file is setup and the disk is checked for errors (chkdsk.exe).
The Win32 subsystem starts and invokes winlogon.exe. The service controller
checks the registry for services that must be started, right after the login screen
is presented indicating that the system has properly started.2
It is either the Bios or the Efi that loads the Windows Nt6 boot manager
called ‘Winload’.
It is Winload that bootstraps the Windows kernel3 , it loads the operating
system kernel, the Hardware Abstraction Layer (Hal) and the system registry.
2 Actually,
the boot process is not yet finished; it finishes after a successful logon and the
‘Last Known Good Configuration’ boot-sequence has been copied.
3 Winload is the equivalent of Ntldr for older Windows Nt systems, although it does not
implement features like hibernation (dispatched to the program called winresume or imple-
mentation of the bootmenu (already handled by the boot-manager))
3.3. MICROSOFT 19
The boot manager (which must be located at the root directory of the boot
volume) reads the ‘Boot Configuration Data’ file and presents the user a boot-
menu. Whenever an operating system is chosen, the bootmanager executes
winload.exe to load the operating system.
The steps the Winload takes are simpler than Ntldr, since some of the tasks
performed by Ntldr have already been performed by the bootmanager (pre-
sentation of the menu) or are delegated to other programs (winresume for hi-
bernation).
3. All (kernel, Hal, libraries and device drivers) the image files are checked
by their digital signature and loaded.
4. The registry is scanned to check all used device drivers, the device drivers
that are in the ‘boot’ classes are verified and loaded into memory.
20 CHAPTER 3. BOOTLOADING AN OPERATING SYSTEM
3.4 Grub4Dos
Not really a specific Windows bootloader, but has some interesting features that
are worth to mention.
Grub4Dos is a fork of the Grub project (see 3.6.2), but has evolved a lot.
Grub uses a staging mechanism, each stage containing a different small pro-
gram, to bootload an operating system, Grub4Dos on the other hand, uses one
single file (grldr or grub.exe, depending from which operating system you
boot) which can be chainloaded from other bootloaders like Ntldr, Grub4Dos
can be written to the bootsector of a device (using the file grldr.mbr) or grldr
can be loaded via the device’s Mbr. Additionally, Grub4Dos can be loaded in
multiple ways (it can be loaded by the bootloader in the Mbr, it can be loader
from the Windows Vista bootloader and it can serve as bootfile for bootable
Cdroms (El Torito). Finally, Grub4Dos implements functionality that allows
you to map virtual disks (harddisk or floppydisks) from image files which can
be used after Dos has started.
If the Grub4Dos bootloader (grldr of grub.exe) is chainloaded from another
bootloader, it scan the local disks for the configuration. This means that the
configuration file is not bound to a specific location, it can even be mobed
between disks.
If Grub4Dos (the Mbr of Grub4Dos) is installed in the Mbr, it scans all devices
for the loader, which on its turn scans devices for the bootmenu (menu.lst).
If no menu configuration is found, a command-line is presented, otherwise the
menu is shown.
3.5 Macintosh
The latest Mac versions come in two flavors, Power PC (Ppc which uses Open
Firmware (a Bios based bootloader) or Intel based Macs, which use Efi/Gpt.
Apple divides the boot process in ten major steps:
1. Power on. The hardware activates the Boot Rom firmware. In case of
OpenFirmware, a Bios variant, the following two steps are performed:
(a) Post, checks vital hardware
(b) Open Firmware, builds the device tree and selects which operating
system to boot.
2. Booter, the ‘BootX’ is the loader that loads the kernel. It is the bootloader
that passes control to this bootloader when Mac OsX is selected as the
operating system. The bootloader can be found at the following location:
/System/Library/CoreServices/BootX.
3. Kernel load, device drivers are loaded and the mach init process (the
process that manages all Cpu processes, like multi-tasking, memory usage
etc.) is launched.
3.6. LINUX 21
5. Startup items, these consist of programs and shell scripts that clean the
temporary files and launch daemon background processes.
6. Login. After the user has logged in, the users environment is loaded, the
Dock, Finder and UI server are started. Optionally the setup assistent is
loaded (in case an installation is in progress) and some of the applications
(user specified) are launched.
7. Authenticating users. This process occurs after the login process. It uses
the Directory Services to authenticate the user (the loginwindow manages
the authenticating process, but does not authenticate the user itself)
3.5.1 Bootcamp
Bootcamp is a utility that lets the user install other operating systems (like
Windows Xp or Windows Vista) on a Macintosch.
The Gpt specification uses a ‘protective Mbr’, as mentioned earlier, this Mbr
should have exactly one partition, its Id should be set to 0xEE.
Apple has bypassed this rule and Bootcamp uses a hyrbid Mbr/Gpt. What
happens is that when you create a new partition on the disk (using the tools
that are supplied by Apple!), this partition gets copied to the partition table of
the protective Mbr of the Gpt (and thus breaking the standard).
3.6 Linux
While technically spoken, Lilo and Grub are not ‘Linux’ bootloaders (they can
boot a multitude of operating systems), they are freely distributed with Linux
and are therefor often seen as ‘Linux’ bootloaders.
Both Lilo and Grub are staged bootloaders where the first stage (which is a
small part of code in the Mbr) is only used to load the second stage.
Once the second stage is loaded into the main memory, the user is presented
with a screen showing the different bootoptions (operating systems) that are
available.
22 CHAPTER 3. BOOTLOADING AN OPERATING SYSTEM
If the selected operating system is a linux flavour, the kernel is loaded from the
boot directory. If the selected operating system is not a linux flavour, another
bootloader will be invoked.
Lilo and Grub are very similar, their main differences are:
• Grub has an interactive interface, whereas Lilo only alows one command
with parameters for interaction.
• Lilo stores information about the operatings system (like kernel location
etc) in the Mbr. The downside of this approach is that after each kernel
modification, the bootloader needs to be adapted as well, Grub uses a
dedicated stage for this.
• Grub can handle many more partition types (Lilo cannot read ext2 par-
titions for example)
3.6.1 LILO
The first stage of the bootloader has finished, the second stage of the bootloader
displays the bootloader screen, reads the kernel and initrd into memory and
hands over the control of the machine to the kernel.
The bootprocess using Lilo shows the word Lilo, each letter indicating a mile-
stone within the boot process. The boot sequence will be explained using these
letters
1. L: When the primary bootloader begins to execute, the first ‘L’ is printed.
This is the first stage of the boot process. It reads the map file (which is
compiled into the boot code) which contains the pointers to the available
operating systems to boot. This map file also contains the address of the
second bootloader.
2. I: The ‘I’ is printed just before Lilo loads the second bootloader (stage
2). If during a boot you see the letters ‘LI’ appear, after which the system
halts, this indicates that the second bootloader cannot be found. (this
happens often after recompilation of a kernel or installation of another
kernel. It is possible to recompile a kernel, move bootloader etc., but
the command /sbin/lilo needs to be executed afterwards to update the
Mbr)
3. L: The first thing the second bootloader does is printing the second ‘L’.
It reads the map file afterwards to retrieve the additional needed files.
4. O: Lilo runs after the map contents have been loaded and verified. Lilo
is ready to pass the control to the kernel. Lilo can also load boot code
for a non-linux system.
3.6. LINUX 23
3.6.2 GRUB
This subsection deals with Grub 1, also known as Grub legacy. This is still the
most widespread version of Grub although Grub 2 has made a lot of progress.
Grub stage 1 is contained in the Mbr, its main task is to load the next stage
of Grub; stage 24
Grub stage 2 presents the user with a boot menu as well as a command prompt
which can be used to enter additional parameters for the boot process. Once
the options are known, Grub loads the kernel which takes over control. Grub
can also give control to another bootloader for operating systems that do not
support the multiboot standard. This process is called chainloading. The other
bootloader is loaded as if it was called by the Mbr directly.
A more detailed explanation of the boot sequence:
2. The bootloader code contains the address of the next stage, which is usu-
ally stage 1.5. Stage 1.5 is located in the first 30 bytes, right after the
Mbr. This space is also known as the “Dos compatibility space”.
3. Stage 1.5 knows about the bot filesyste,. It opens the filesystem, looks
for the stage 2 executable and passes control to it. This step is created to
give a greater flexibility in upgrading kernels, stage 2 upgrades etc, since
changes do not imply modifications to the Mbr (which is not the case for
Lilo).
4 Stage 1 can also load stage 1.5 which is located directly after the Mbr. Stage 1.5 is used
to load other filesystems than ext2 and ext3. Stage 1.5 is filesystem aware and simply loads
stage 2.
24 CHAPTER 3. BOOTLOADING AN OPERATING SYSTEM
After the bootloader has loaded the kernel, the kernel initializes, configures and
examines the system’s hardware. It looks for a initrd image in well known
location in it memory. The initrd image is mounted and the necessary drivers
5 In Lba, only one number is used to address data, rather than three. Each linear base
address describes a single block. The reason for using Lba instead of Chs in the filesystem is
because of its simplicity. (source: wikipedia)
3.7. MULTIBOOT 25
are loaded. Virtual devices (lvm or Software raid) are optionally loaded be-
fore the image is unmounted and the kernel continues by freeing up all unused
memory. The filesystem is setup, by creating a root device, which is mounted
as read-only. Again all unused memory is freed, we now have a fully-loaded and
operational kernel in memory.
Next step is to invoke the /sbin/init program (which is also simply called
‘init’), to setup a user environment (otherwise, we could not do a lot with the
computer).
The init process becomes the parent process of all subprocesses that will be
started. It starts by initializing the available run-levels, usually ending at run-
level 5 (graphical multi-user environment).
3.7 Multiboot
The image below shows some possible boot scenarios. There is one part with
dotted lines, it shows a path from the Ntldr to a file called bootsect.dos.
This file is actually installed by the Windows Nt installation process, simulating
a normal boot process (actually, it is a copy of the ’old’ bootsector before the
installation on Windows Nt).
26 CHAPTER 3. BOOTLOADING AN OPERATING SYSTEM
The image shows some of the possible paths during a multiboot bootprocess.
Most bootloaders are capable of chainloading another bootloader. This has one
big implication: multiple bootmenus. If you boot Grub, for instance, and you
use it to load Windows, you get redirected to the Windows bootloader. If this
bootloader only contains one entry, it will skip the menu, however, mutliple
entries lead to the effect that you will first see the Grub bootmenu, afterwards
the Windows menu.
A remedy might be to setup the multi-boot system in such a way, that each
operating system has its own bootloader. 6
A more complicated setup includes creating images of each operating system
to be installed, reinstalling them afterwards and let the bootmanager link the
different operating systems.
Both methods are undesirable, they require a lot of work, with limited outcome,
they are thus not part of the experiments. 7 .
6 This might work if the number of operating systems is limited and fit within the maximum
limit of four primary partitions (a partition can be set hidden when a new operating system
is installed, therefor the installer will not modify the specific boot process).
7 Dan Goodell did follow this setup
Chapter 4
Some experiments
27
28 CHAPTER 4. SOME EXPERIMENTS
c:\Windows\System32>bcdedit.exe
Using BCDedit, these options can be changed, new entries can be added etc.2
Bcd is an abbreviation for ‘Boot Configuration Data’ .
Vista no longer uses Ntldr, but Bcd. The configuration file (boot.ini) has
been backup and contains a message that this type of loading is no longer
supported.
Installing Windows Xp, after Vista has been installed, requires some manual
intervention afterwards. Windows Xp is older than Vista, the technology (read:
the boot process) is simply not built to cope with newer technologies.
When Vista is already installed, and a copy of Windows Xp is placed next to
it, the Windows Xp installation overwrites the Windows Vista bootloader and
replaces it by the one known to Xp: Ntldr. Since this bootloader has no
boot entries
2 There is also a utility called msconfig.exe which provides a Graphical User Interface
(GUI) that allows you to change some basic options like default boot option, timeout etc. Its
functionality is limited compared to BCDEdit
4.2. DUALBOOT: VISTA AND THEN XP 29
notion of Vista, you will find yourself booting straight into Xp, no option to
boot Vista is presented.
Intuitively, you might consider two rescue options: modify Xp’s bootloader to
also present the option to boot Vista or install Vista’s bootloader and configure
it to allow the choice of either Xp or Vista (and we have seen that this works
in the previous section)
After booting to Xp, a ‘boot.ini’ file is available with the following contents:
[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect
1. Use Bootsect.exe to restore the Windows Vista Mbr and the boot code
that transfers control to the Windows Boot Manager program. To do this,
type the following command at a command prompt:
Drive:\boot\Bootsect.exe /NT60 All
In this command, Drive is the drive where the Windows Vista installation
media is located.
locking the harddisks. There were some additional errors, but these appeared to be non-fatal
30 CHAPTER 4. SOME EXPERIMENTS
It should now be clear that we should start with the installation of the oldest
operating system first, working our way ‘up’ unto the latest, finishing with
Linux, since the Linux bootloaders recognize all other. Before that, however,
I used gparted to partition the disk, since not all operating systems provide a
partitioning option during installation.
Some things are convenient to know before starting:
• Linux uses a dedicated partition for its swap-space (not necessary, but
common practice)
The installation detects the partitions that I have recently setup (except for the
Linux partitions, which is quite logical) and after selecting the first partition,
4.3. MULTIBOOT: XP, VISTA, 2008, LINUX 31
the installer asks me what to do with the partition (format, convert to ntfs).
I chose not to format, not to convert the partition, thus leaving it in fat32.
The installer asks which version of Windows 2008 I purchased (actually, I didn’t
purchase any, I downloaded it from Msdn). Chose one of the available options
(beware that the ‘Core’ option gives a command-line only interface!) and after
booting we see that Windows 2008 adapted the bootoptions that were available
after Vista installation:
4.3. MULTIBOOT: XP, VISTA, 2008, LINUX 33
Windows 2008 Server installed without problems, the menu shows the three
expected boot-options.
The initial idea was to install Fedora (which allows the option to use Lilo
as bootloader as well as Grub), but the Fedora installer/partitioner does not
recognize any of the NTFS partitions (additionally it crashed when trying to
set it up), so I switched to Ubuntu.
The installation finishes and after a reboot, we are presented with Grub, which
allows us to boot to either Ubuntu, or go to the Vista/Longhorn loader. This
last option goes, as expected, to the Windows Bootloader as it was installed by
Vista. This means that if we would like to boot into any windows system, we
have to pass two bootloaders....
Proper planning is clearly needed, the partitions, their filesystem format and
sizes need to be known upfront. Once you have determined this information,
start with the oldest windows version first and work your way up to the newer
windows versions. Installing Linux with either Lilo or Grub afterwards should
not pose any problems, but be prepared to perform some manual interventions
afterwards.
34 CHAPTER 4. SOME EXPERIMENTS
Appendix A
The Mbr that I retrieved during of one of the experiments; Windows Xp (This
image is best viewed in full scale and in color)
35
36 APPENDIX A. MBR - A CLOSER LOOK
Viewing the result in a hexviewer is uninteresting, the magic number can be seen,
as well as a lot of nulls. The partition table is more interesting, especially with
the information following afterwards:
01B0: 00 00 00 00 00 00 00 00 90 63 00 00 00 00 00 FE
01C0: FF FF EE FE FF FF 01 00 00 00 2F 60 38 3A 00 00
01D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
01E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
01F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA
The disk signature is set to 90 63 00, one partition is visible, but it is non-
bootable.
37
38 APPENDIX B. GPT - A CLOSER LOOK
The Magic Number is not a surprise, what is surprising is the ‘unknown ID’.
Actually, this is not surprising at all; the identifier EE is used to protect the
Gpt to tools designed for the Mbr (like fdisk), but unaware of Gpt (see 2.4).
The following commands show a bit of information as well:
We clearly see the redundancy that is built in into Gpt; the partition table and
the header are duplicated. Furthermore, the Guid
C12A7328-F81F-11D2-BA4B-00A0C93EC93B indicates that we are dealing with
a Efi System Partition, 48465300-0000-11AA-AA11-00306543ECAC indicates a
‘Hierarchical File System’ (Hps) filesystem, which is the default filesystem for
Osx.
One last command, the outcome should be self-explanable:
Utilities
There are several useful utilties to work with bootloaders (Tools come with the
description provided by the vendors/developers)
1. BCDEdit
Boot Configuration Data (Bcd) files provide a store that is used to de-
scribe boot applications and boot application settings. The objects and
elements in the store effectively replace Boot.ini.
BCDEdit is a command-line tool for managing Bcd stores. It can be used
for a variety of purposes, including creating new stores, modifying existing
stores, adding boot menu options, and so on. BCDEdit serves essentially
the same purpose as Bootcfg.exe on earlier versions of Windows, but
with two major improvements:
BCDEdit is the primary tool for editing the boot configuration of Windows
Vista and later versions of Windows. It is included with the Windows
Vista distribution in the %systemroot%\System32 folder.
2. Beeblebrox
Beeblebrox is a partition table editor for Windows 95/98 or NT. With
Beeblebrox you can : backup and restore your partition tables, edit any
value in any partition table, hide/unhide partitions, change the active
partition, search for partition boot records to help in partition recovery,
view partition boot sector information and delete a partition.
39
40 APPENDIX C. UTILITIES
Glossary
41
42 APPENDIX D. GLOSSARY
Windows not loader (Ntldr to load Dos based operating systems, sim-
ulating the previous operating system’s normal boot procedure).
• Bootstrapping
In computing, bootstrapping (”to pull oneself up by one’s bootstraps”)
refers to techniques that allow a simple system to activate a more compli-
cated system. A common scenario is the start up process of a computer
system, where a small program, such as the Bios, initializes and tests
hardware, peripherals and external memory devices, then loads a pro-
gram from one of them and passes control to it, thus allowing loading of
larger programs, such as an operating system.
Bootstrapping was shortened to booting, or the process of starting up
any computer, which is the most common meaning for non-technical com-
puter users. The verb “boot” is similarly derived. A “bootstrap” most
commonly refers to the simple program itself that actually begins the ini-
tialization of the computer’s operating system, like Grub, Lilo or Ntldr.
• Chainloading
Chain loading is a method used by computer programs to replace the
currently executing program with a new program, using a common data
area (a so-called core common area) to pass information from the current
program to the new program. It occurs in several areas of computing.
In operating system boot manager programs, chain loading is used to pass
control from the boot manager to a boot sector. The target boot sector
is loaded in from disk, replacing the boot sector from which the boot
manager itself was bootstrapped, and executed.
The word Ram is mostly associated with volatile types of memory, where
the information is lost after the power is switched off.
47
48 APPENDIX D. GLOSSARY
bootmgr, 41 Firmware, 8, 43
bootsect.dos, 41
Globally Unique Identifier, 10, 44
80386, 12 GPT, see GUID Partition Table
GRUB, 44
Basic Input/Output System, 8, 41 Grub4Dos, 20
BCD, see Boot Configuration Data GUID, see Globally Unique Identifier
BIOS, see Basic Input/Output System GUID Partition Table, 10, 43
Boot Configuration Data, 28, 41
Booting, 41 HAL, see Hardware Abstraction Layer
Bootloader, 7, 41 Hardware Abstraction Layer, 18, 44
BootRom, 14 HFS, see Hierarchical File System
Bootstrapping, 7, 42 Hierarchical File System, 38
Bootx, 20
Initial Program Load, 8, 44
Chainloading, 10, 42 IPL, see Initial Program Load
CHS, see Cylinder-Head-Sector Itanium, 12
CMOS, see Complementary Metal Ox-
ide Semiconductor LBA, see Logical Block Addressing
Complementary Metal Oxide Semicon- Legacy MBR, 11
ductor, 13, 42 LILO, 44
Cylinder-Head-Sector, 11, 24, 36, 42 Logical Block Addressing, 11, 44
49
50 INDEX
x86, 12