LinuxBasics.org

The community that helps people to run Linux

rss
Table of Contents

Booting

Introduction

Methods for Booting:

  1. Boot Manager - Usually GRUB, but some distros use LILO
  2. LiveCD or Rescue CD - when things get broken, you can usually boot with one of these. See Rescue about this.
  3. Ancient history (See archived booting page for a little more on these)
    • Floppy Disk - kernel put on a floppy. Rather old, because kernels are usually too big for a floppy currently
    • Loadlin - Old way of booting from Windows

How to set up booting

The process for booting is set up during installation. If you have Windows or other operating systems on your machine, the installer usually includes them as choices in the boot menu. If they are not included during the installation, you can edit the configuration file for either GRUB or LILO later.

Editing GRUB menu.lst

Example of stanzas in /boot/grub/menu.lst:

title           Ubuntu, kernel 2.6.20-16-386
root            (hd0,3)
kernel          /boot/vmlinuz-2.6.20-16-386 root=UUID=3db245ba-320f-4fd1-8671-188f2d36928c ro
initrd          /boot/initrd.img-2.6.20-16-386
quiet
savedefault
title           Windows
root            (hd0,0)
chainloader     +1

Short explanation of stanzas:

To add something that is missing, you need to make a similar stanza with the root, kernel, initrd.img etc. With GRUB all you need to do is edit /boot/grub/menu.lst to add the stanza. You do not need to update GRUB in the MBR.

You can change the order of the items listed in the menu by moving them in menu.lst. Normally the default to boot is the first one. You can change that default by changing the number in the line “default 0” near the top of menu.lst. Remember that GRUB starts with number 0; so if you want to boot the 2nd item in the list by default, change the “0” to “1” on that default line.

For more on GRUB see the GNU GRUB Manual 0.97

Using chainloader with GRUB for multi-booting

In the example menu.lst above, you will see that the Windows stanza is using “chainloader”. You can use this for Linux distros as well. Using chainloader, you will not have to find the exact kernel and initrd.img names.

When you install your second (or more) distro, just install the boot loader in the root partition rather than the MBR. (See Note below if did not elect to install grub in the root partition when you installed the second distro.) Then reboot into the distro that you used to install GRUB with. Edit the /boot/grub/menu.lst there and add a stanza for your new distro.

Lets suppose you installed Debian Etch in partition 9. You would add this stanza:

title        Debian Etch
chainloader    (hd0,8)+1

Then you can reboot and choose Debian Etch and you will see the boot loader for that appear. The nice thing is that now, whatever distro you put on partition 9 will boot when you select that title. Of course, if you change the distro on that partition, it would be good to change the title on your grub menu.lst.

The downside: you slow down your boot up sequence because you load 2 bootloaders, and you have to select twice (or let 2 default choices happen). You can speed it up by editing the config file for the second boot loader to have a shorter default waiting time.

Note: If you already have your second distro installed and did not install grub in the root partition, it is an easy thing to fix. Before you edit menu.lst to change to using the chainloader, boot to the second distro. Install grub (as root or using sudo) in the root partition with:

update-grub
grub-install /dev/hdxx

where hdxx is the root partition, for example /dev/sda6. Then reboot into your main distro and edit menu.lst to use chainloader for the second distro.

Editing LILO lilo.conf

Example of stanzas in /etc/lilo.conf:

       boot=/dev/hda
       default="windows" 
    
         image=/boot/vmlinuz-2.4.20
           initrd=/boot/initrd.img-2.4.20
           label=Linux
           root=/dev/hdb2
           read-only
        other=/dev/hda1
           label=windows
           table=/dev/hda

Short explanation of stanzas:

To add something that is missing, just add a stanza with the information about the kernel, initrd.img, root, and a label. With LILO you must run “/sbin/lilo” as root in order to have the changes take place.

You can change the default operating system to boot by changing the default to the label of choice.

For more on LILO see LILO mini-HOWTO by Miroslav Skoric.

What about inittab?

You will often read about /etc/inittab and that you can edit it to change default runlevel or what happens when you press Ctrl-Alt-Delete. Upstart (mentioned above) does not include /etc/inittab. Things are a little different if your system is using Upstart. Here are a couple of the FAQs from /usr/share/doc/upstart/README.Debian.gz.

  1. How do I change the default runlevel?
    • Edit the /etc/inittab file, if you installed edgy fresh you’ll need to create it. Locate, or write, the following line:
      id:N:initdefault:
      Where N is the default runlevel, change this to match.
  2. How do I change the behaviour of Control-Alt-Delete?
    • Edit the /etc/event.d/control-alt-delete file, the line beginning “exec” is what upstart will run when this key combination is pressed.
    • To not do anything, you can simply delete this file. After deleting the file, you need to “kill 1” to ensure that the job is removed from its memory.

What to do if you overwrite your MBR

The way this usually happens is when you reinstall Windows and it overwrites the MBR.

You will need to boot from a rescue disk or your installation cd. Some of them have a selection in the menu for system repair which usually has a section for reinstalling GRUB. If not, boot with the rescue disk/LiveCD and then using your actual partition rather than /dev/hda3 do:

sudo su -
mount /dev/hda3 /mnt
chroot /mnt
grub-install /dev/hda

Note: Use only ‘su -’ if your rescue disk doesn’t use sudo.

chroot causes you to use the partition rather than the LiveCD to run the commands. Running grub-install from the Rescue Disk or LiveCD alone will not work, but if you run it from the partition, it will use what is in /boot/grub and put grub back in the MBR where it belongs.

Comparison of GRUB and LILO

Boot loader showdown: Getting to know LILO and GRUB by Laurence Bonney at IBM DevelopmentWorks about GRUB and LILO, contrasting and comparing the two.

Grub Command Line

You can use the GRUB Command Line to find information that will allow you to boot when the selections in your GRUB menu are not working.


Copyright (c) by the authors.
Prior to editing, authors agreed to license their contributions by the terms of the GPL.
See our licensing page for details.


Linux® is a registered trademark of Linus Torvalds.


 
  tutorials/during/booting.txt · Last modified: 2008/07/20 21:08

LinuxBasics.org

Start Linux-Course Tutorials Linux Links Security Blog Forum E-mail List Search Online Chat

Site-Info

Help Get in Touch Making of LBo

Wiki-Control

Powered by

Linux Apache DokuWiki Mailman RUTE ht://Dig