This first part is written for those who are doing most of their work in Windows 2000 but want the option to boot to Linux. If Linux is your primary O/S then you'd probably want to set LILO so that it can boot Windows 2000, which is covered towards the end of this article. (Actually, as you'll see, using LILO in the MBR is probably the easiest way to do this.)
Some of this information came from an article on the Windows2000faq.com site. That article can be viewed here.
I have simplified their procedure. My friend Dave, who prefers that I don't use his last name, gave me some additional help. I am assuming that you are either using both Windows98 and Windows 2000 or just Windows 2000. (Or, of course, NT4.0. These procedures will also work with Windows XP)
I keep Windows98 on my machine for a few reasons. For example, I have an HP scanner. With HP's typical generosity, they have no free downloads to update the drivers to Win2k--you have to purchase a CD. Many people keep Win98 on their machine either for similar reasons, or to run various applications that simply don't run well in 2k.
The first method given here is the simplest. It assumes that you either have both Win98 and 2k installed, or that you have 2k on a FAT32 partition. In either case, 2k's boot.ini file will be in the first partition of your hard drive.
So, step by step.
First install Linux. You will either be putting it in a new partition on the same hard drive or on its own drive. During installation, most distos will give you the choice of installing LILO in either the MBR (Master Boot Record) or the Linux boot partition. Choose the Linux boot partition. Also, when they give you the option of making a boot diskette, do it--it will be necessary to get back into Linux.
When installation is done, start Linux using the boot diskette that you created and log in as root.
Now, if your Win2k boot.ini file is on a FAT32 partition, do the following--if, however, it is on an NTFS partition, then see below. First, we'll make a directory to mount the Windows system partition.
Now, we mount the partition
mount -t vfat /dev/hda1 mswin
If this is NT4.0 rather than 2k, and/or the system partition is FAT rather than FAT32 the above command would be written
mount -t fat /dev/hda1 mswin
now, let's look at LILO to see where your Linux boot partition is residing.
cat /etc/lilo.conf | more
You will see an entry in there that will show you the Linux default boot partition, something like boot=/dev/hda5.
That's assuming that your bootable Linux partition is on hda5--it might say hda6 or whatever. Now, we're going to directly copy this boot entry to our C: drive
dd if=/dev/hda5 bs=512 count=1 of=mswin/bootsect.lnx
You should see something like
1+0 records in
1+0 records out
Now let's make sure that it went correctly.
We want to make sure that there is now a file in there called bootsect.lnx
Now, using any of the many text editors supplied with Linux, edit the mswin/boot.ini file. Add a line that reads:
You don't have to call it Linux of course, you can put anything you want inside the quotes. That is what will appear on your screen when you when the NT Boot Manager shows.
When you reboot you'll see an entry for Linux. If you select it you'll see a LILO: prompt and then, after a brief wait, it'll boot into Linux. (Or press enter to boot instantly)
If your boot.ini file resides on an NTFS partition (for example, if you are only, at present, running Windows 2000 on NTFS) the procedure is slightly different. Linux doesn't, at time of writing have full support for writing to a Win2k NTFS partition, so we'll have to use diskettes. If you read the above, most of this is a repeat, but if you skipped to this part, well, we're going step by step.
First install Linux and put Lilo in the first Linux boot partition rather than in the MBR--you should be given the choice during installation. (In RH and some others you have to choose custom installation to have this choice.) When asked if you want to make a boot diskette, do so. Also, choose, during setup, DOS connectivity (in RH's graphical install, there's a little DOS window icon.) After installation, boot into Linux from the boot diskette. Don't worry, you won't need it very long.
Next, look at LILO to see where the Linux boot partition is
cat /etc/lilo.conf | more
At the beginning of the file it will have a line showing the
boot partition, something like
Copy this boot sector file--we're going to use it shortly.
dd if=/dev/hda5 bs=512 count=1 of=bootsect.lnx
You should see something like
1+0 records in
1+0 records out
(Obviously, replace hda5 with whatever partition lilo.conf shows as being your Linux boot partition.)
Let's make sure we did this right
There should be a file listed called bootsect.lnx
Copy the file to a FAT formatted floppy disk.
mcopy bootsect.lnx a:
(If you didn't choose DOS connectivity during install, you might not have mcopy installed. In this case you'll get an error message. Not to worry. At least in RedHat, this is easily rectified. Put in the RH installation CD--you will be able to access it through a GUI. Go to the RedHat folder and look for RPMS. In RPMS look for a file called mtools, that will probably have a number after it. Click on that and the RPM package manager will install it. You can check that it's been installed by typing
rpm -q mtools
You should get something like mtools with numbers after it, giving the version.) So, now that that's out of the way, type the above command, given again below for your convenience.
mcopy bootsect.lnx a:
You can now shut down and boot up NT. (Don't forget to remove the floppy first.)
Copy the bootsect.lnx file to your system partition. From a command prompt
copy A:\bootsect.lnx C:\
Now, using notepad, edit boot.ini. (If you are new to Win2k, you might not know that to see boot.ini you have to go to My Computer/Tools/ Folder Options/View and uncheck the box that says Hide protected operating system files. When you uncheck it, they give you a warning message, but tell them yes, you do want to do it. Again, if you are new to 2k, and nervous about playing with its files, when we're done, you can go back and recheck it.)
Add a line that reads
When you reboot, Linux will be added to your choice of operating systems--if you select it, you'll see a LILO prompt.
For those who do most of their work in Linux and simply want to add NT to LILO's menu, there are various ways to do this. The reader should be grateful to Dave and I, as we got into experimenting and hosed various boxes.
If the first partition is Win9x or 2k on FAT or FAT32 just let LILO go into the MBR. The LILO menu will say dos. If you select it, it will take you right to the NT Boot Menu. However, if you don't have a Win98 installation, and your first partition is Win2k on an NTFS partition, the following method is the simplest. Let Linux put LILO in he MBR and then boot into it. Edit /etc/lilo.conf. (You might want to back it up first, in case you make a mistake.) At the end of the file add
Now, run LILO to update the changes. This is done by simply typing
If it doesn't seem like anything happened, then type
However, that shouldn't be necessary.
Another way to do this, if for example, you're installing on a new machine and aren't comfortable editing lilo.conf is to first install Win2k. During setup, choose to format the Win2k partition with FAT rather than NTFS. Then, install Linux, and as mentioned above, LILO will see the boot partition as dos and boot it for you.
Now, interestingly enough, if you do it this way, you can then use 2k's convert function to change the 2k partition to NTFS. While in 2k, at a command prompt type
Convert C: /FS:NTFS
You'll get a message saying something to the effect that it can't do it now, but will upon the next reboot. Reboot the system into 2k and it will convert the C: drive to NTFS.
LILO will still give you an entry for dos that will, if selected, go to the 2k boot menu. This seems, however, to be a roundabout way to do it.
I suppose, if you really felt like making it complicated, you could also start (again on a machine with no O/S on it) with a Win9x boot disk, make a small FAT32 partition, leave it empty, then install 2k. It will put the files used for booting on that small partition, then, if LILO is put in the MBR, it will see it as DOS and boot it. However, that one seems like a lot of unecessary work.
We tested all of the above (except for making the small FAT32 partition--again, that one just seems far too much work) on Win2k with a RedHat 7.x distro. It should work, however, with any distro and should also work on Windows NT4.0
There is one more scenario. Suppose that you installed LILO in the first Linux partition, then after reading this article, slap yourself and say "Gee, I shoulda put it in the MBR." Not to worry. Brian L. Johnson, a moderator of the yahoogroups linux mailing list points out that it's quite simple.
First, boot into Linux--either use your boot disk or perhaps you've already gone through the steps above, to boot to it through Win2k's boot manager. Log in as root and using your favorite text editor, open up /etc/lilo.conf
Add the line mentioned above, to enable LILO to boot the NT partition
There will also be a line in there saying something like
It might say hda5, or whatever--at any rate, it refers to whichever partition is your first Linux partition. Change this to read boot=/dev/hda
Then run LILO to update it.
(As mentioned above if nothing happens, then type /sbin/lilo instead).
(Recently, going on a distro binge, I installed Corel, letting it do its standard install. It somewhat rudely put its LILO in the MBR, taking over from the RH one that I always use. This too was easily fixed--first, I had to get into RH again, which was done by simply adding it to the Corel LILO (how to add a second Linux distro to an existing LILO is explained below). Then, once I could boot back into RH, as it already had the boot=/dev/hda line, all I had to do was simply rerun it by typing
at a command prompt. This restored the RH LILO so that it was what I saw upon booting up.)
Upon reboot, you should be presented with a LILO prompt offering you the option of booting to NT. If you still have the Linux entry in your NT boot manager, you can either leave it, to give yourself a second chance to boot into Linux (recommended for the wishy-washy) or go into NT and remove that line from your boot.ini file.
One other thing--this one actually took a little digging and experimentation to get it to work. Suppose you have two distros of Linux on your machine and want them both to be booted by LILO. A look at the mini howto didn't cover this. I saw, searching on deja, a few different possibilities--this is the one that I found to be the simplest.
I'll use my setup as an example. I decided to add Slackware to my machine. I was already running RH and using its LILO to boot Win2k and itself. I added Slackware to a new partition, hda6. During installation, I didn't make the partition bootable, however, when it asked where did I want to install its (Slackware's) LILO, I put it in the Slackware partition. So, now I had RH, with its LILO in the MBR and Slackware with its LILO in hda6. Then, I added the following to my RH /etc/lilo.conf
image=/boot/vmlinuz label=Slack read-only root=/dev/hda6
Then of course, run LILO to update it
This enabled me to boot Slackware upon startup. I also set the Slackware /etc/lilo.conf timeout to 0. If you don't put the 2nd distro's LILO in that distro's partition, when you run the lilo on the other distro, you'll get a fatal error.
As a bonus, here's a link to RH's method of using LILO to boot FreeBSD. This was helpful for me, as BSD was the last reason I was still using BootMagic.
Recently, I've come to like GRUB even better than LILO. For a quick tutorial on it, check out the GRUB page I've made. Comments are welcome. As for questions, I'll help if I can, but I'm not an expert. For either simply email me.