Search the Catalog
Learning Debian GNU/Linux

Learning Debian GNU/Linux

By Bill McCarty
1st Edition September 1999
1-56592-705-2, Order Number: 7052
360 pages, $34.95 , Includes CD-ROM


Previous: D.3 The lilo Loader Appendix D
Managing the Boot Process
Next: D.5 Boot Parameters
 

D.4 The loadlin Loader

Another way of booting Linux is by using loadlin, an MS-DOS program that can load a Linux kernel. To load Linux, loadlin relies on MS-DOS rather than your system's BIOS; therefore, loadlin can load a kernel stored beyond cylinder 1023. More generally, it can load a kernel from any filesystem or location accessible to MS-DOS.

However, loadlin cannot be run from a DOS Prompt Window within Windows 3.x or 9x. You must start your system in MS-DOS mode in order for loadlin to work. By making the proper entries to your config.sys file, you can create a convenient boot menu that lets you boot MS-DOS, Windows, or Linux.

D.4.1 Installing loadlin

The loadlin program must have access to the file containing the Linux kernel you want to boot. The easiest way to get this file onto your Windows system is to boot Linux, make sure the Windows filesystem that corresponds to the Windows C: drive is mounted, and copy the kernel file. The following commands assume that your Windows filesystem is mounted as /mnt/c and that you want to store the kernel in the directory c:\linux.

mkdir /mnt/c/linux
cp /boot/vmlinuz /mnt/c/linux/vmlinuz

The loadlin program needs to know the identity of your Linux root partition. To learn the name of the root partition, issue the command:

mount

The command reports all the mounted devices:

/dev/hda2 on / type ext2 (rw)
none on /proc type proc (rw)
/dev/hda1 on /boot type ext2 (ro)
none on /dev/pts type devpts (rw,mode=0622)
/dev/hdc on /cdrom type iso9660 (ro)

The root partition is the partition mounted as /. Here, it's /dev/hda2. Make a note of the partition name. Then, boot your Microsoft Windows system and copy the file loadlin.exe from the /dosutils directory to a convenient location on your hard drive.

D.4.2 Using loadlin

To test loadlin, restart your Windows system in MS-DOS mode, by clicking on Start -> Shut Down, choosing Restart in MS-DOS Mode from the Shut Down Windows dialog box that appears, and clicking on OK. When the MS-DOS prompt appears, change to the directory containing loadlin and issue the command:

loadlin c:\linux\vmlinuz root=/dev/hd
xn ro

where /dev/hd xn is the root partition of your Linux system, which you earlier recorded. If your Linux files are stored in a directory other than \linux, you must adjust the command's first argument appropriately. Your Linux system should boot. If it does not, check your work and try again.

D.4.3 Configuring loadlin

Once you're satisfied that loadlin works with your system, you can configure your system to make using loadlin more convenient. Microsoft Windows supports a simple boot menu that will let you decide whether to boot Linux or Windows. To create such a boot menu, boot Microsoft Windows and use Notepad to add the following lines to the top of your config.sys file:

[menu] 
menuitem=Linux, Boot Linux
menuitem=Win95, Boot Windows 95 
menudefault=Linux, 15  

[linux]
shell=c:\linux\loadlin.exe @c:\linux\bootopts.txt

[win95] 

If you're using Windows 3.x or Windows 98 rather than Windows 95, change the file accordingly.

The config.sys file is located in the root directory of the C: drive. If your system has no config.sys file, create one using the lines given.

Now, add the following lines to the top of your autoexec.bat file:

goto %config%
:win95 

The autoexec.bat file is located in the root directory of the C: drive. If your system has no autoexec.bat file, create one using the lines given.

Finally, use Notepad to create the file bootopts.txt in the \linux directory. The file should have the contents similar to the following:

c:\linux\vmlinuz root=/dev/hd
xn ro

Be sure to substitute the name of your Linux root partition for the placeholder /dev/hd xn. You can specify additional options if you like. The next section introduces you to the most popular ones.

Now, when you boot your system, you'll see a convenient menu that lets you type a digit to choose which operating system you want to boot.

Another convenient way to use loadlin with Windows 95 (but not Windows 98) is to create a program shortcut that switches your system to MS-DOS mode and runs loadlin. Launch the dialog box for creating the shortcut by right clicking on the desktop and clicking on New -> Shortcut. The dialog lets you specify the contents of the autoexec.bat and config.sys files. The former should be empty and the latter should contain the line:

shell=c:\linux\loadlin.exe @c:\linux\bootopts.txt


Previous: D.3 The lilo Loader Learning Debian GNU/Linux Next: D.5 Boot Parameters
D.3 The lilo Loader Book Index D.5 Boot Parameters

Back to: Learning Debian GNU/Linux


oreilly.com Home | O'Reilly Bookstores | How to Order | O'Reilly Contacts
International | About O'Reilly | Affiliated Companies | Privacy Policy

© 2001, O'Reilly & Associates, Inc.