"Linux Gazette...making Linux just a little more fun!"

Booting Linux with the NT Loader

By Gustavo Larriera

On these days technical professionals like you and me often must deal with the following scenario: To make Linux and NT peacefully coexist on the same machine. Many HOW-TOs have been written -and it's a good advice to give them a look- about how to configure LILO (The Linux Loader) to do the task. Unfortunately, classic documentation have little references about the NT Loader. Yes, I know for some people there's some kind of religious war between Linux and NT out there :-) But from the point of view of a IT professional, the main objective is to have the job well done.

In many real-life situations we must tackle with a installation where it is not desirable to alter the NT boot process. May be it is your machine's boss and he/she prefers to keep on booting the same way for ever ;-) In this article I will focus on how to configure the NT Loader so as to boot Linux (and continue booting NT also!).

I hope these tips will help Linux users to successfully boot Linux through the NT Loader the easiest way. The procedure I will explain works for NT Server 4 and NT Workstation 4 running on Intel-compatible PC.

The Scenario

After long conversation you have convinced your boss to put Linux on her computer machine. She is a happy NT user, she loves Word and Excel and such. She also is a clever person and has decided to give Linux a try. So she wants to have Linux installed. Just a moment: She prefers to keep booting with her familiar loading menu, from where she can choose to boot NT or DOS. Her wishes are your wishes, so you decide not to use LILO to dual-boot her computer.

The MBR considered useful

The most important thing you must always remember is that many software products sit on your unique precious hard disk's Master Boot Record (MBR). So does NT without asking and so optionally does LILO if you want to. The machine's BIOS executes code stored on the active partition to initiate your preferred OS.

When NT is installed, the MBR is modified to load a program called NTLDR from the active partition's root directory. The original MBR is saved on a small file called BOOTSECT.DOS. After a NT installation, be careful never overwrite the MBR, because the NT will no longer boot. To fix this problem, a NT user needs the NT's Emergency Repair Disk (ERD).

With those things in mind, take note you must be careful to configure LILO *not* to install on MBR. Instead you will need to configure LILO on the root partition of Linux. That's safe for NT and Linux can live without the MBR.

NT loading process

Once the NTLDR program launchs the NT user watch the "OS Loader V4.xx" message. Then NTLDR shifts the processor to 386 mode and starts a very simple file system. After that, it reads the file BOOT.INI to find out if there are other operating systems and prompts the user with a menu. A typical BOOT.INI looks like this:

[boot loader]

[operating systems]
multi(0)disk(0)rdisk(0)partition(2)\WINNT="NT V4 is here"
multi(0)disk(0)rdisk(0)partition(2)\WINNT="NT V4 VGAMODE" /basevideo /sos
C:\="DOS is here"

The BOOT.INI file has two sections. The "boot loader section" specifies how long in seconds will be the menu on screen and the default menu choice. The "opearating systems section" specifies the different OSs the user can choose. We can read the machine boots NT (either in normal mode or in VGA diagnosing mode) and also can boot DOS. We can deduce from this example that DOS boots from the partition C: (first partition on first disk) and NT boots from the second partition. Typical installations have a C: partition formatted with DOS's FAT file system and NT on another partition formatted with its NTFS (NT File System).

If the user chooses to load NT, another program NTDETECT.COM runs to check the existent hardware. If everything was okay, the NT kernel is loaded and that's all we need to know.

Let's examine what happens if the user decide to choose other OS rather than NT. In this situation, NTLDR needs to know which is the boot sector required to load the non-NT OS. The appropiate boot sector image must exists on a small 512-byte file. For instance, to load DOS, NTLDR searches for a boot sector image file called BOOTSECT.DOS. This image was created by the NT installation.

So, what if I want to load Linux? It's quite simple, all we need is a boot sector image file, let's name it BOOTSECT.LIN (later we'll see how to obtain this file). You must put BOOTSECT.LIN on C: and edit BOOT.INI, the "operating systems section" now looking something like this:

[operating systems]
multi(0)disk(0)rdisk(0)partition(2)\WINNT="NT V4 is here"
multi(0)disk(0)rdisk(0)partition(2)\WINNT="NT V4 VGAMODE" /basevideo /sos
C:\="DOS is here"
C:\BOOTSECT.LIN="Now Linux is here" 

The BOOT.INI can be edited with any plain ASCII text editor. Normally this file has system-hidden-readonly attributes, so you must change them using the 'attrib' DOS command or within NT, from the file's property dialogbox.

The Linux side of the story

Now let's concentrate on the Linux shore. We need to install Linux, configure LILO and create the BOOTSECT.LIN file.

The first step is to have Linux installed. We all know how to do that: Choose appropiate partitions for Linux system, swap and user's stuff, run installation program, etc. Easy cake, first step is completed okay in less than 45 minutes.

Then we must configure LILO. We also know how to do that, but be careful *not* to install LILO on the MBR (unless you hate NT too much :-)) When configuring LILO, choose to install it on your Linux root partition. If you don't know how to configure LILO, spend some minutes reading the HOW-TOs or use some of the useful setup programs most modern Linux distributions have. My installation is S.u.S.E., so I use the 'yast' (Yet Another Setup Tool).

Once LILO is configured (let's asume the Linux root partition is /dev/hda3) we must use 'dd' to create the boot record image. Login as root and do the following:

# dd if=/dev/hda3 bs=512 count=1 of=/dosc/bootsect.lin 

Prior you have mounted the FAT C: partition as /dosc. Just in case you cannot access to this partition, for instance if it's formatted with NTFS, just write BOOTSECT.LIN to a DOS-formatted diskette or some partition where NT can read from. If you put BOOTSECT.LIN in a place othet than C:\ remember to modify the BOOT.INI file accordingly.

Now your boss can choose Linux from her NT Loader's menu. The NTLDR will load the BOOTSECT.INI and she'll see the LILO prompt. Then she'll plunge into her new Linux box. Finally, if you configured LILO to load Linux and also the DOS on C: when LILO prompts, your boss will reload from the active C: partition, again into NT Loader. The procedure described may be repeated if you wish to boot several Linuxes, you must just create appropiated boot sector image files for each of your Linuxes.

Copyright © 1999, Gustavo Larriera
Published in Issue 36 of Linux Gazette, January 1999