Booting with Loadlin
path › xlifecolumns20011210

Booting with Loadlin

Xlife column for December 10, 2001:
Summary:
Bootloaders are programs that allow you to choose which operating system to use at computer boot time. Find out how to use the "loadlin" bootloader on a dual Windows 98/Linux system.
  1. Why do we need bootloaders?
  2. How does Loadlin work?
  3. Setting up Loadlin
  4. Getting a kernel image
  5. The Loadlin configuration file
  6. Actually using Loadlin
  7. An even nicer way to use Loadlin
  8. I don't wanna use loadlin!

1 Why do we need bootloaders?

When you have several operating systems on the same computer you need to tell it which one to use. This is done usually at boot time, right after the computer's low level diagnostics and setup have ended. At that moment it is custom standard that control is passed to a small program located at the very beginning of the first hard-disk, called a bootloader.

This is just custom standard. You can tell your BIOS to check for a bootloader on the floppy-disk, on the CD-ROM or on another hard-disk. But in my setup I have two operating systems on the same hard-disk, so I need a bootloader that would allow me to choose between them.

The "regular" bootloader I had so far, the one installed by Windows, would load Windows from the first partition. I can go about this issue two ways:

  1. Use another bootloader (like LILO), one that knows there are more than one operating system installed and lets me choose. This approach has several faults:
    • the LILO version that ships with Red Hat 7.1 doesn't work when the Linux partitions are too far from the start of the disk.
    • even if it did work, there are all kinds of software that will attempt to mess with it, ranging from antivirus software to Windows itself; once one of them overwrites the boot sector (the bootloader's holder) I have to bring out that trusty floppy-disk I made at install (if I still have it), boot Linux with it and restore LILO; it's a lot of pain.
  2. Don't use a bootloader. Well, not a regular one. What I do is boot into MS-DOS instead of Windows (Windows 9x won't have any problem with that) and run a program called loadlin.exe which will load Linux according to my instructions. Basicly, it does the same thing as LILO but it goes about it a different way.

2 How does Loadlin work?

First of all, you need to know what a kernel image is: it's a file which contains the core of the Linux operating system, the kernel, in packed form so it takes up less space. This kernel is basicly a program which LILO or loadlin load into memory and pass all control to it.

What I have to do is tell loadlin a few important things:

  • Which file contains a valid kernel image.
  • Which is the main Linux partition.
  • All kinds of additional setup information.

What LILO does is first hook up to the main Linux partition, look into the /boot directory and get the kernel image it finds there. Loadlin, on the other side, needs a kernel image first of all. So I'll need a kernel image.

3 Setting up Loadlin

I choose to put Loadlin in C:\loadlin. You can find loadlin.exe on the first Red Hat CD, in the dosutils directory. There's also a tarball there (a Tar/GZip archive) called lodlin16.tgz, which contains more, like documentation and examples. WinZip knows tarballs.

I pass info to Loadlin through a configuration file, let's say C:\loadlin\linux.par. So what we've got so far is Loadlin itself and a configuration file. We really need a kernel image now.

4 Getting a kernel image

You don't just need a kernel image, you need the right kernel image. Once the image loads and takes over, it will load drivers (or "modules"); if they're not appropriate some things (hardware or applications) won't work properly or even at all. Remember this in the future.

If you have a Linux boot floppy disk, check it out. There's a file called vmlinuz on it. That's the kernel image. Copy it into C:\loadlin and give it a suggestive name (I call it 242-2.z, because it contains kernel version 2.4.2-2, and "z" because it was compressed with GZip).

5 The Loadlin configuration file

Here's what I have in mine:

c:\loadlin\242-2.z  # the kernel image; must be on the first line
-v                  # be verbose; I wanna see what goes on
root=/dev/hda6      # which is the main Linux partition
ro                  # mount the main Linux partition read-only
console=tty1        # output messages to the first console
vga=normal          # regular VGA text mode
mem=128M            # I have 128 MB of RAM
idebus=66           # the mainboard can take 66 bus transfer
ide0=ata66          # ide0 (the hard-disk) knows ATA66/100
hdc=ide-scsi        # hdc (the CD-writer) uses the ide-scsi interface

Actually, you can do without most of these options, except the kernel image location and the root option. I let the others in just so I can explain them and, again, you'll end up smarter thant the average newbie.

That read-only stuff is not what it seems, the partition must be read-only in the beginning so it can be checked for errors; if everything's fine the kernel will make it read-write later during the startup process.

Linux has "consoles"; by using Alt+F1 through 6 you can switch between separate screens. The console option tells the kernel which console to write it's messages to. Also, the vga option sets up a VGA mode.

I don't really need to tell Linux how much RAM I've got. It can detect it just fine. However, in some rare cases it doesn't, so this is a way to patch things up. I got this option there back when I bought some new RAM and I wanted to make sure it works the first time.

The idebus and ide0 options are a trick I use to switch my hard-drive into "high gear" and get top performance out of it.

Finally, with the hdc option I tell the kernel that my CD-writer unit will be using the ide-scsi interface. No, it's not SCSI, it's just an IDE drive, but this interface (emulated by the kernel) is better that plain IDE, and I need it in order to actually use the writer for writing.

6 Actually using Loadlin

You run Loadlin like this:

C:\loadlin> loadlin.exe @linux.par

Next thing you know, you're in Linux.

7 An even nicer way to use Loadlin

It would be really nice though if, upon computer start, I'd get a nice little menu allowing me to choose between Linux and Windows. OK, we can do that by using the startup menu facility of config.sys. Check out this config.sys:

[menu]
menuitem=win,win
menuitem=linux,linux
menudefault=linux,10

[win]

[linux]
shell=C:\LOADLIN\LOADLIN.EXE @C:\LOADLIN\LINUX.PAR

That's it, you're all set up. Every time the computer reboots you get a menu with two entries, win and linux. If you don't press a key for ten seconds linux gets chosen automatically.

8 I don't wanna use loadlin!

So don't. Use GRUB or a newer LILO.

< Back to the top | Read other columns | Choose what column I should write next! >