Architecture
The following figure shows the Disk Layout needed to perform Dual
Booting.
MBR (Master Boot Record)
The master boot record (MBR), also the
partition sector, in IBM PC architecture, is a 512-byte sector at the beginning of a hard
disk drive that contains a sequence of commands necessary for booting an operating
system.
The boot code contained within the ROM BIOS loads
and executes the master boot record. The MBR of a drive usually includes the drive's
partition table, using which it can load and run the boot record of the partition that is
marked with the active flag. This design allows the BIOS to load any operating system
without knowing exactly where to start inside its partition.
Partition Table
In PCs, partitions have traditionally been supported
using a structure called the Partition Table, which is written down in the end of
the Master Boot Record (MBR). The table, which can contain up to 4 partition
records (which are also called partition descriptors), specifies for each its
beginning, end and size in different addressing modes, as well as a single number called
the partition type, and a marker that tells whether a partition is active. Only
one partition can normally be active at a time. The active marker is used during boot:
after the BIOS loads the MBR into memory and executes it, the DOS MBR checks the
partition table at its end, and locates the active partition. Then it proceeds to load
the boot sector of that partition into memory and runs it. Unlike the MBR, which
is generally operating-system independent, the boot sector is installed together with the
operating system and that way it can know how exactly to load the particular
system.
Note that while the presence of an active marker is
standardized, it is not normally used by any program but the boot loader, and so the boot
loader is not obliged to load the partition that was marked active. Some boot loaders use
this to boot operating systems from non-active partitions. For example, the boot loader
GRUB do not look up the partition table altogether, but simply load a second stage (which
might be contained in the rest of cylinder 0 or in a filesystem). After the second stage
is loaded, it can be used either to load the boot sector from any of the disk's
partitions (thus enabling the user to load the system from it), or if the boot loader
knows how, to locate the operating system's kernel on one of the partitions and load it
(for recovery purposes, it may allow the user to specify additional kernel
options).
We use the following Partition Table
# fdisk /dev/hda
Command (m for help): p
Disk /dev/hda: 60.0 GB, 60011642880 bytes
255 heads, 63 sectors/track, 7296 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start
End Blocks Id System
/dev/hda1 *
1 3187 25599546 7
HPFS/NTFS
/dev/hda2
3188 3212 200812+ 83
Linux
/dev/hda3
3213 3337 1004062+ 82 Linux
swap
/dev/hda4
3338 7296 31800667+ 83
Linux
The first Partition /dev/hda1 is
reserved for Windows 2000, the other Partitions are used for Linux:
# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda4 31300924 19008428 10702464 64% /
/dev/hda2 194449 9325 175084 6% /boot
Boot Sector
The Boot Sector is a region of a hard disk, floppy disk or
similar. It is loaded to memory and executed as a part of the bootstrap sequence. The
boot sector often contains the Boot Loader that loads the operating system into
memory and transfers control to it.
Boot Loader
The Boot Loader is most often not itself an operating
system, but only a second-stage boot loader, such as LILO or GRUB. It will
then be able to load the operating system proper, and finally transfer execution to it.
The system will initialize itself, and may load device drivers and other programs that
are needed for the normal operation of the OS.
The GRUB Bootloader
GRUB is a Multiboot boot loader. It was derived
from GRUB, GRand Unified Bootloader, which was originally designed and implemented
by Erich Stefan Boleyn. For an Introduction of the GRUB Bootloader see: http://www.gnu.org/software/grub/manual/grub.html
GRUB is a very powerful boot loader, which can load a wide variety
of free operating systems, as well as proprietary operating systems (such as Windows
2000) with chain-loading.
Chain-Loading
Chain-Loading is the possibility to load another boot loader
to boot unsupported operating systems
If you want to boot an unsupported operating system (e.g. Windows
2000), chain-load a boot loader for the operating system. Normally, this boot
loader is embedded in the boot sector of the partition on which the operating
system is installed.
Installing the GRUB Bootloader (Gentoo Linux)
The most critical part of understanding GRUB is getting comfortable
with how GRUB refers to hard drives and partitions. Your Linux partition /dev/hda1 is called (hd0,0) under
GRUB. Notice the parenthesis around the hd0,0 - they are
required. Hard drives count from zero rather than "a" and partitions start at zero rather
than one.
To install GRUB, let's first emerge it:
# emerge grub
To start configuring GRUB, you type in grub. You'll be presented
with the grub> grub command-line prompt. Now, you need to type in the right
commands to install the GRUB boot record onto your hard drive.
# grub
In the example configuration we want to install GRUB so that it
reads its information from the boot-partition /dev/hda2,
and installs the GRUB boot record on the hard drive's MBR (master boot record) so
that the first thing we see when we turn on the computer is the GRUB prompt.
The tab completion mechanism of GRUB can be used from within GRUB.
For instance, if you type in "root (" followed by a TAB,
you will be presented with a list of devices (such as hd0). If you type in "root (hd0," followed by a TAB, you will receive a list of available
partitions to choose from (such as hd0,0).
By using the tab completion, setting up GRUB should be not that
hard.
grub> root (hd0,1) (Specify
where your /boot partition resides)
grub> setup (hd0) (Install GRUB in the MBR)
grub> quit (Exit
the GRUB shell)
Although GRUB is now installed, we still need to write up a
configuration file for it, so that GRUB automatically boots your newly created kernel.
Create /boot/grub/grub.conf
GRUB Configuration
Here is our /boot/grub/grub.conf
File:
default=0
timeout=30
splashimage=(hd0,1)/grub/splash.xpm.gz
title Gentoo Linux 2.4.25
root (hd0,1)
kernel /kernel-2.4.25 root=/dev/sda4
initrd /initrd-2.4.25
title Windows 2000 Professional
rootnoverify (hd0,0)
chainloader +1
GRUB's root device to the partition (hd0,0, but don't attempt to mount the partition. This is needed
because Windows 2000 is outside of the area of the disk that GRUB can read, but setting
the correct root device is still desired.
Set the active partition on the root disk to GRUB's root device.
This command is limited to primary PC partitions on a hard disk.
chainloader
Load the Windows 2000 boot loader. Like any other file loaded by
the filesystem code, it can use the blocklist notation to grab the first sector of the
current partition with +1.
Conclusion
Sharing a computer between two operating systems often requires
dual booting. You can use either operating system on the computer, but not both at once.
Each operating system boots from and uses its own hard drives or disk partitions. Using
GRUB as the primary Boot Loader you can boot another OS such as Windows XP /
2000.
|