Make your own free website on Tripod.com

Booting Linux with the NT Loader

Version 0.2, 13-jan-99

Gustavo Larriera <glarrier@ei.edu.uy>

Abstract

This article gives a not-very-technical description of the NT Loader and how it can be used to boot Linux. The procedure described should be used when the user prefer for some reason, not to use the LILO (Linux Loader) to do the task.


Introduction

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 and other material 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 process. 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 an IT professional, the main objective is to have the job well done.

In many real-life situations we must tackle with an 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 hardisk's MBR (Master Boot Record) contains a partition table and executable instructions. The partition table has 4 entries, one for each possible primary partition. The partition table defines their locations on disk. The MBR's code searchs for the first partition marked active (i.e. bootable) and then reads the first sector -named "boot sector"- from that partition into memory. Control is then transferred to the executable code stored and the boot procedure actually starts.

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 each of the active partitions' boot records, to initiate your preferred OS.

When NT is installed, the MBR is modified to load a program called NTLDR from the boot sector which was created on the active NT partition's root directory. The original boot sector was saved on a small file called BOOTSECT.DOS by the NT setup.

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]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(2)\WINNT

[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 "operating systems section" specifies the different OSs the user can choose, up to a max of 10. From the above example, we can deduce that machine boots NT (either in normal mode or in VGA diagnosing mode) and also boots DOS. We can also 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) but it is not a requirement. In fact, an NT installation may not have FAT partitions at all. However, it is a good practice to have a FAT partition and to use it as a common area to exchange files between Linux and NT.

From the NT Loader menu, when 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 for now.

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 the boot sector image file called BOOTSECT.DOS created by the NT setup. This is as an image of the previous boot sector which was before NT came to town.

So, what if I want to also 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 any NTFS or FAT partition NT can access during the boot phase. Then, edit BOOT.INI so that the "operating systems section" now looks 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 properties 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 and mark it active. If you don't know how to configure LILO, spend some minutes reading the HOWTOs 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 active 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 a partition as /dosc. Just in case you cannot access to this partition due to its filesystem (most Linux cannot write to a NTFS partition), 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. If you put BOOTSECT.LIN on a FAT partition, note the drive letter assigned to it during the boot phase, not from within NT because the partition may have other letter assigned that is not the same that the boot process knows during its initial phase.

Final words

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 happily into her new Linux box. In the future, you will have to repeat the procedure described if LILO configuration changes (for instance, after kernel recompiling).

Annotated Reference

The following documents, in no special order were all considered when preparing this article.

Aknowledgements

Many thanks to all people who sended their emails and personal experiences. Please let me mention a few of them. Dale Massey and AlphaBrav both pointed out that installing LILO on the MBR has no major effects on the NT installation. Earl Robinson noted the tedious procedure to be repeated whenever the LILO config changes, for instance after kernel recompiling. From Michal Jaegerman's email I decided to include the annotated reference section.

Feedback

Any comments, tips, suggestions, corrections or other feedback are always welcome and they surely would help to improve this document.

Some legalese

COPYLEFT PERMISSION NOTICE: Permission is granted to copy and distribute modified versions of this document, provided that this copyleft permission notice is included exactly as in the original, and that the entire resulting derived work is distributed under the terms of this copyleft permission notice.

The author is not responsible of any harm infringed to hardware and/or software when appling the procedures described in this document. All trademarks mentioned are property of their respective owners.

Gustavo Larriera <glarrier @ ei.edu.uy>