ALINK="#FF0000">

LINUX GAZETTE

[ Prev ][ Table of Contents ][ Front Page ][ Talkback ][ FAQ ][ Next ]

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


Booting Linux from the NT Boot Menu

By Pradeep Padala


Why an article on Linux in an NT boot menu? We have HOWTOs, don't we? The HOWTOs give step by step instructions, but unfortunately they don't provide everything we want. They are geared towards people who are new to Linux and are very good at explaining things to newbies. But when it comes to doing something out of the ordinary, we're stuck. This article is a meant to fill that void.

To start with one, day I got the crazy idea that it would be nice to have a single boot loader to boot everything from one manager instead of having both a LILO and an NT boot manager. So which manager should I choose? I chose NT boot manager because when we install LILO and boot NT from it, NT still presents its own boot menu and it's annoying enough to need to be asked two times to boot the right operating system . So I thought of removing LILO and using NT loader to present a nice menu for booting all the operating systems I have. Okay then, How do we do it? I searched through the HOWTOs. The mini HOWTO HOWTO NT OS Loader + Linux mini-HOWTO gives a good overview of the process. But unfortunately my brain couldn't grasp the concept. As a result, when I first followed the steps I got an unusable system. After 3 days of hard work and rebooting and fiddling with an unusable system 3 times, concepts began to become clear.

Here we Go.

NT Boot Loader

The NT boot loader loads the operating system image by reading the initialization file boot.ini. Have a look at it now. It contains something like:

		[boot loader]
		timeout=30
		default=multi(0)disk(0)rdisk(0)partition(1)\WINNT
		[operating systems]
		multi(0)disk(0)rdisk(0)partition(1)\WINNT="Windows NT Workstation Version 4.00"
		multi(0)disk(0)rdisk(0)partition(1)\WINNT="Windows NT Workstation Version 4.00 
		[VGA mode]" /basevideo /sos

this says to boot the operating system from the partition as mentioned. That is it takes the first 512 bytes of information which is required for booting the corresponding OS. So how do we boot Linux using this concept. Simple! we can have the first 512 bytes of Linux boot partition (the boot sector for Linux) in a file and give it to NT boot manager. We can modify the boot.ini file as follows:

		[boot loader]
		timeout=30
		default=multi(0)disk(0)rdisk(0)partition(1)\WINNT
		[operating systems]
		multi(0)disk(0)rdisk(0)partition(1)\WINNT="Windows NT Workstation Version 4.00"
		multi(0)disk(0)rdisk(0)partition(1)\WINNT="Windows NT Workstation Version
		4.00 [VGA mode]" /basevideo /sos
		C:\boot.lnx="Redhat Linux 6.2"

Where boot.lnx is the file which contains the required 512 bytes. But we have to get the 512 bytes. How do we do that? The HOWTO gives a good example of how to do it. Here we need the first 512 bytes of Linux boot partition which says to NT just to boot Linux. So we make a dummy lilo.conf file and pass it to LILO and tell it to install the boot sector for linux at the top of Linux partition. Then we peel the first 512 bytes from this and put it into a file and give it to NT. Then we install LILO in MBR and take care of loading WINNT as the default OS. We create the lilo.conf to write NT as default and install it.

Let's do it.

First let me explain my example environment. I loaded Red Hat out of the box with the default options during installation. It installs LILO in MBR and updates it according to the options given during installation regarding what other OSes (such as NT) you have. Here I have NT only. When I reboot after installation, LILO comes up with two options to boot--Linux and DOS. When I enter DOS, it goes into NT boot manager. What are we trying to make? We want to make LILO start the NT boot manger as default and in NT boot manager, we want to have an option to boot Linux.

What are we trying to make? We want to make LILO to start NT boot manger as default and in NT boot manager we want to have an option to boot Linux.

We start here. First boot into Linux. Make a dummy lilo.conf file like this: Copy lilo.conf to lilo.dummy and open lilo.dummy with vi. edit it to look some thing like this:

		# lilo.dummy file
		boot = /dev/hda3 	# Linux resides in /dev/hda3 in my machine.
		                        # replace it with the partition in which you installed linux
		timeout=0 		# Time out zero to avoid lilo waiting for us
		vga = normal
		read-only
		default=linux
		image = /boot/vmlinuz
		label = linux
		root = /dev/hda3

Then execute LILO with this dummy file as the argument with the command. This installs linux boot sector on /dev/hda3.

/sbin/lilo -C lilo.dummy
Peel off the first 512 bytes with this command.
dd if=/dev/hda3 of=boot.lnx bs=512 count=1

We copy the file boot.lnx to c drive. If c drive is mounted as /win/c we copy with the command

cp boot.lnx /win/c
or mount c drive and copy the file as
mount /dev/hda1 /win/c
cp boot.lnx /win/c

Then change the boot.ini file as indicated here.
		[boot loader]
		timeout=30
		default=multi(0)disk(0)rdisk(0)partition(1)\WINNT
		[operating systems]
		multi(0)disk(0)rdisk(0)partition(1)\WINNT="Windows NT Workstation Version 4.00"
		multi(0)disk(0)rdisk(0)partition(1)\WINNT="Windows NT Workstation Version
		4.00 [VGA mode]" /basevideo /sos
		C:\boot.lnx="Redhat Linux 6.2"

Installing LILO in MBR.

Just change the lilo.conf file to reflect winNT as the default OS with no delay in booting into it and tell LILO to install it in MBR.

		boot = /dev/hda                 # Install it in MBR
		timeout=0
		vga = normal
		read-only
		default=win                     # We need NT as default
		image = /boot/vmlinuz		# We can remove this entry with out any
						#problems as we will not be booting Linux from LILO
	 	label = linux
		root = /dev/hda3
		other = /dev/hda1
		label = win

install LILO again. Before rebooting, make sure that you have a rescue disk at hand. You can use the Red Hat installation disk as the rescue disk. See the Pitfalls section to find out how to use to for rescue. or You can make a boot disk with the command

mkbootdisk,

which you can use for rescue. See the Bootdisk-HOWTO for more details on how to make boot disk.

Then reboot and watch the magic.

Are you still unsatisfied? I know what is bothering you. You want LILO to be eliminated completely. Do this. Get a DOS floppy that has fdisk and boot the machine with the floppy. Then run "fdisk /mbr" to overwrite the master boot record. I don't know what happens with this option. I am still unsure about this and if any one knows what this option does, please write to me.

    Pitfalls:

  1. Remember every time you change your kernel or make any changes to lilo.conf, you have to follow the process again and make a new copy of boot.lnx and give it to NT.

  2. If you have done some thing wrong and you can't boot Linux, then boot with the rescue disk and install LILO again as follows:

    (You can use red hat installaion CD as the rescue disk. At the installation menu type rescue and enter)

    • boot with rescue disk
    • mount linux partition
      mount /dev/hda3 /mnt
    • change root
      chroot /mnt
    • change lilo.conf to some thing sane like
              boot = /dev/hda
              timeout=500
              prompt
              vga = normal
              read-only
              default=linux
              image = /boot/vmlinuz
                  label = linux
                  root = /dev/hda3
              other = /dev/hda1
                  label = win
           
    • install lilo
      /sbin/lilo
    • do a sync and unmount /dev/hda3
      sync
      umount /mnt
    • Reboot
      /sbin/reboot


Copyright © 2000, Pradeep Padala.
Copying license http://www.linuxgazette.net/copying.html
Published in Issue 61 of Linux Gazette, January 2001

[ Prev ][ Table of Contents ][ Front Page ][ Talkback ][ FAQ ][ Next ]