8. Booting the OS

Q: Can Linux Boot from MS-DOS?
Q: How Can Linux Boot from OS/2's Boot Manager?
Q: How Do I Set the Boot-Time Configuration?
Q: How Do I Get LILO to Boot the Kernel Image?
Q: Can I Remove LILO So the System Boots DOS Again?
Q: Why Does the System Check the Ext2fs Partitions Each Reboot?
Q: How Do I Make Sure the System Boots after Re-Installing the Operating System?
Q: How To Make a Rescue Floppy

Q: Can Linux Boot from MS-DOS?

A: If LILO doesn't work, and if the machine has MS-DOS or Microsoft Windows, you may be left with a computer that won't boot. This can also happen on an upgrade to your Linux distribution. Re-installing LILO is the last thing that the installation does.

It is vitally important when installing or upgrading Linux on a dual boot machine, to have a MS-DOS or Windows rescue disk nearby so you can FDISK -MBR. Then you can go about using LOADLIN.EXE instead of LILO.

This config.sys file is one possible way to invoke LOADLIN.EXE and boot MS-DOS or Linux.

 [menu] menuitem=DOS, Dos Boot menuitem=LINUX, Linux Boot

[LINUX] shell=c: edhatloadlin.exe c: edhatautobootvmlinuz vga=5 root=/dev

[DOS] STACKS = 0,0 rem all the other DOS drivers get loaded here.

This creates a menu where you can directly jump to LOADLIN.EXE before all of the MS-DOS drivers get loaded.

The paths and options are peculiar to one machine and should be intuitively obvious to the most casual observer. See the LOADLIN.EXE docs for options. They are the same as LILO, and options are just passed to the kernel, anyhow.

[Jim Harvey]

Q: How Can Linux Boot from OS/2's Boot Manager?

A: #Create a partition using OS/2's FDISK.EXE (Not Linux's fdisk).

  1. Format the partition under OS/2, either with FAT or HPFS. This is so that OS/2 knows about the partition being formatted. (This step is not necessary with OS/2 Warp 3.0.)

  2. Add the partition to the Boot Manager.

  3. Boot Linux, and create a file system on the partition using mkfs -t ext2 or mke2fs. At this point you may, if you like, use Linux's fdisk to change the code of the new partition to type 83 (Linux Native)this may help some automated installation scripts find the right partition to use.

  4. Install Linux on the partition.

  5. Install LILO on the Linux partition NOT on the master boot record of the hard drive. This installs LILO as a second-stage boot loader on the Linux partition itself, to start up the kernel specified in the LILO configuration file. To do this, you should put

     boot = /dev/hda2 

    (where /dev/hda2 is the partition you want to boot from) in your /etc/lilo/config or /etc/lilo.config file.

  6. Make sure that it is the Boot Manager partition that is marked active, so that you can use Boot Manager to choose what to boot.

There is a set of HOWTO's on the subject of multi-boot systems at the LDP Home Page, http://tldp.org.

Q: How Do I Set the Boot-Time Configuration?

A: You can configure Linux at the lilo: prompt either by typing the kernel arguments at the BOOT lilo: prompt, or by adding an append= directive to the /etc/lilo.conf file; for example, at the LILO prompt (example only):

BOOT lilo: parport=0x3bc,7
parport=0x3bc,none serial=0x3f8,4 serial=0x2f8,3 

Example statement for /etc/lilo.conf:


append="parport=0x3bc,none serial=0x3f8,4 serial=0x2f8,3"

If you modify the /etc/lilo.conf file, be sure to run the lilo command to install the new configuration.

Configuration notes for specific hardware devices are in the documentation of the kernel source distribution, /usr/src/linux/Documentation in most distributions.

Refer to the lilo and /etc/lilo.conf manual pages, as well as the LDP BootPrompt-HowTo, see Where Is the Documentation?, and the documentation in /usr/doc/lilo.

Q: How Do I Get LILO to Boot the Kernel Image?

A: From kernel versions 1.1.80 on, the compressed kernel image, which is what LILO needs to find, is in arch/i386/boot/zImage, or arch/i386/boot/bzImage when it is built, and is normally stored in the /boot/ directory. The /etc/lilo.conf file should refer to the vmlinuz symbolic link, not the actual kernel image.

This was changed to make it easier to build kernel versions for several different processors from one source tree.

Q: Can I Remove LILO So the System Boots DOS Again?

A: The lilo program (not the complete LILO package), uses the command line option -u to uninstall the LILO boot loader. You have to supply the device name of the device you installed LILO on, for example:

 lilo -u /dev/hda

This rewrites the original, pre-LILO master boot record back to the first hard drive, from the boot record saved in /boot/boot.0300. If you installed LILO to a partition as a secondary boot loader, for example, /dev/hda1, lilo re-installs the original boot sector from the save file /boot/boot.0301. Refer to the lilo manual page for details. Thanks to Villy Kruse for reminding me to update this answer.

If you have an earlier version of LILO, you will have to use the DOS (MS-DOS 5.0 or later, or OS/2) FDISK /MBR (which is not documented). This will overwrite the lilo boot loader with a standard MS-DOS Master Boot Record. If you have DR-DOS 6.0, go into FDISK.EXE in the normal way and then select the Re-write Master Boot Record option.

If you create a boot floppy during the Windows installation process, make sure that it contains the programs FDISK.EXE, FORMAT.COM, and SYS.COM, and use that to re-install MS-DOS on the hard disk.

If you don't have MS-DOS or DR-DOS, you need to have the boot sector that LILO saved when you first installed it. You did keep that file, didn't you? It's probably called boot.0301 or some such. Type:

 dd if=boot.0301 of=/dev/hda bs=445 count=1

(or /dev/sda if you're using a SCSI disk). This may also wipe out your partition table, so beware! If you're desperate, you could use

 dd if=/dev/zero of=/dev/hda bs=512 count=1

This will erase your partition table and boot sector completely: you can then reformat the disk using your favorite software. But this will render the contents of your disk inaccessible you'll lose it all unless you're an expert.

Note that the DOS MBR boots whichever (single!) partition is flagged as "active." You may need to use fdisk to set and clear the active flags on partitions appropriately.

Q: Why Does the System Check the Ext2fs Partitions Each Reboot?

Q: How Do I Make Sure the System Boots after Re-Installing the Operating System?

A: This should work whether you're re-installing Linux or some other, commercial, operating system:

  • Insert a blank, formatted floppy in drive A:

  • Save a copy of the boot hard drive's Master Boot Record to the floppy, by executing the command:

     #dd if=/dev/hda of=/dev/fd0 count=1

    dd is a standard program on Linux systems. A MS-Windows compatible version is available from ftp://ftp.gnu.org/, as well as many MS software archives.

  • Test that the floppy boots the system by rebooting with the floppy in the A: drive.

  • Then you should be able to install the other operating system (on a different hard drive and/or partition, if you don't want to uninstall Linux).

  • After installation, boot Linux again from the floppy, and re-install the MBR with the command: /sbin/lilo.

[Jacques Guy]

Q: How To Make a Rescue Floppy

A: Make a file system on it with bin, etc, lib and dev directorieseverything you need. Install a kernel on it and arrange to have LILO boot it from the floppy (see the LILO documentation, in lilo.u.*.ps).

If you build the kernel (or tell LILO to tell the kernel) to have a RAM disk the same size as the floppy the RAM disk will be loaded at boot time and mounted as root in place of the floppy.

See the Bootdisk HOWTO.