Difference between revisions of "LILO Overview"

From wiki.emacinc.com
Jump to: navigation, search
m (Additional Abilities of LILO: Fixed grammatical error.)
 
(12 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{todo|In Progress(11.27.13-01:00->MD+);(11.27.13-17:50->MD+)|Mike Dean|project=oe 4,oe 5,md,Review,ky}}
+
{{todo|SEOKWREV(11.27.13-01:00->MD+);(11.27.13-17:50->MD+);(12.16.13-02:30->MD+);(12.16.13-10:50->MW-);(12.16.13-12:30->MD+); (12.16.13-12:57->MW+);(12.16.13-18:30->KY+);(03.06.14-15:35->BS-);(04.11.14-16:30->BS+);(04.14.14-11:00->BS+)|Mike Dean|project=oe 4,oe 5,md,SEOKWREV,mw,ky,bs}}
  
 +
{{#seo:
 +
|title=LILO Overview
 +
|titlemode=append
 +
|keywords=LILO,LILO Bootloader
 +
|description=LILO is a bootloader which was created for Linux.  LILO was the default bootloader used for most desktop and server distributions for many years.
 +
}}
 
=The LInux LOader - LILO=
 
=The LInux LOader - LILO=
  
Line 45: Line 51:
 
==Additional Abilities of LILO==
 
==Additional Abilities of LILO==
  
In addition to the normal boot selection described above, LILO is also able to pass arguments to the Linux kernel for booting.  These arguments can be useful for enabling output of boot messages, configuring a video driver, and configuring a good number of other things which can accept kernel command line configuration options.
+
In addition to the normal boot selection described above, LILO is also able to pass arguments to the Linux kernel for booting.  These arguments can be useful for enabling output of boot messages, configuring a video driver, and configuring a number of other things which can accept kernel command line configuration options.
  
 
For example, the <code>console=ttyS0,115200</code> option can be passed to a kernel to enable boot message output to the serial console:
 
For example, the <code>console=ttyS0,115200</code> option can be passed to a kernel to enable boot message output to the serial console:
Line 77: Line 83:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Other arguments to the kernel are passed in a similar manner.  The available options to pass will depend on the specific configuration of the kernel which will be booted by LILO.
+
Other arguments to the kernel are passed in a similar manner.  The available options to pass will depend on the specific configuration of the kernel which will be booted by LILO. A page which contains many more kernel arguments can be found here: https://www.kernel.org/doc/Documentation/kernel-parameters.txt
  
==Installing LILO==
+
==Next Steps==
  
LILO can be installed onto a disk for use by the local machine, or it can be installed onto a removable storage device for use in booting on a different machine.  Both installation methods are discussed here.  Usually, the former method will be used to update the existing bootloader for new kernels, new kernel configurations, or new boot time options.  The latter method is generally used to initially set up a bootable storage device which will later be inserted into the embedded system for which it is being created.
+
Follow these guides for more information:
  
 
+
* [[Configuring LILO]]
===Installing Onto the Local Machine===
+
* [[Installing LILO]]
 
 
Before LILO can be used to boot a system, it must be installed on the boot device.  It must also be reinstalled any time the configuration is changed, or the new configuration will not take effect.  Fortunately, installing LILO is easy.
 
 
 
The easiest way to install LILO on the local system's Master Boot Record with the default configuration file (<code>/etc/lilo.conf</code>), is to type:
 
 
 
root@oe:/# lilo
 
 
 
Unfortunately, you may not want to install LILO this way.  This method works well for systems where only a small change is required to the default configuration, but is often not what you want on an embedded system.  Many times, you will want to use an alternate file to store your new configuration so that you don't make a breaking change to your known-good configuration file.  If you prefer to use a configuration file in an alternate location, you will need to type:
 
 
 
root@oe:/# lilo -C /etc/alternate_lilo_configuration_file.conf
 
 
 
The <code>-C</code> (capital C) switch tells <code>lilo</code> to use the configuration file specified after the switch when installing itself.
 
 
 
-----
 
===Installing LILO Onto a Removable Drive===
 
 
 
Unfortunately, the last method shown above is still not what you need to do when your embedded machine's root drive is not in the running embedded system.  If you have a Compact Flash disk, for instance, containing your Linux filesystem, and it is mounted on your desktop Linux development machine, you will need to jump through a few hoops to install the bootloader onto the Compact Flash card.  This method is usually necessary when you don't yet have a bootable disk for your embedded machine.
 
 
 
Two sets of directions for doing this are given here.  The first set of directions is generic, and will work for desktop Linux distributions which do not include an automounter or have an automounter which doesn't interfere with the process.  The second set of details a known workaround
 
The following steps will need to be performed to install LILO onto a removable drive:
 
 
 
====Installing from a System with No Automounter or a Non-Interfering Automounter====
 
 
 
For simpler systems without an automounter, or with an automounter that doesn't try to protect the user from possible malicious code, follow these directions.
 
 
 
<cl>
 
1. Mount the drive.
 
i. Insert the flash card into your card reader.
 
* Find out where the device node for the card was created (assuming you have <code>udev</code> on your system) by using <code>dmesg</code>.<syntaxhighlight lang="console">
 
user@ldc:~/# dmesg | tail -n 15
 
...
 
[126468.154762] sd 6:0:0:0: [sdb] 7831152 512-byte logical blocks: (4.00 GB/3.73 GiB)
 
[126468.182196] sdb: sdb1
 
[126468.688061] kjournald starting.  Commit interval 5 seconds
 
[126468.691223] EXT3-fs (sdb1): using internal journal
 
[126468.691225] EXT3-fs (sdb1): recovery complete
 
[126468.694526] EXT3-fs (sdb1): mounted filesystem with ordered data mode
 
[173828.541718] sdb: detected capacity change from 4009549824 to 0
 
[179577.977554] sd 6:0:0:0: [sdb] 7831152 512-byte logical blocks: (4.00 GB/3.73 GiB)
 
[179577.994839]  sdb: sdb1
 
[179578.376157] kjournald starting.  Commit interval 5 seconds
 
[179578.381428] EXT3-fs (sdb1): using internal journal
 
[179578.381433] EXT3-fs (sdb1): recovery complete
 
[179578.384661] EXT3-fs (sdb1): mounted filesystem with ordered data mode
 
</syntaxhighlight>
 
* Since the device node <code>sdb1</code> was created for the flash card (in this example), we need to mount that device somewhere where we can access it.  In this example, we'll use <code>/mnt/cfcard</code>: <syntaxhighlight lang="console">
 
user@ldc:~/# sudo su
 
[sudo] password for user:
 
root@ldc:~/# mkdir -p /mnt/cfcard
 
root@ldc:~/# mount /dev/sdb1 /mnt/cfcard
 
root@ldc:~/#
 
</syntaxhighlight>
 
 
 
* Copy device nodes into the filesystem:<syntaxhighlight lang="console">
 
root@ldc:~/# cd /mnt/cfcard
 
root@ldc:/mnt/cfcard# cp -a /dev/sdb* dev/
 
root@ldc:/mnt/cfcard#
 
</syntaxhighlight>
 
* <code>chroot</code> into the filesystem:<syntaxhighlight lang="console">
 
root@ldc:/mnt/cfcard# chroot .
 
root@ldc:/#
 
</syntaxhighlight>
 
* Run <code>lilo</code> with the appropriate LILO configuration file.  Be sure to double check to ensure that the configuration file is correct, because a mistake here could render your desktop system unbootable.<syntaxhighlight lang="console">
 
root@ldc:/# lilo -C /etc/lilo.conf.boot
 
Warning: '/proc/partitions' does not exist, disk scan bypassed
 
Added emac-oe *
 
One warning was issued.
 
root@ldc:/#
 
</syntaxhighlight>Note that the warning here is normal, because you're installing LILO inside a chroot which doesn't have a mount <code>/proc</code> virtual filesystem.
 
* Exit the chroot and unmount the device:<syntaxhighlight lang="console">
 
root@ldc:/# exit
 
root@ldc:/mnt/cfcard# cd ..
 
root@ldc:/mnt# umount cfcard
 
</syntaxhighlight>
 
* It is now safe to remove the flash card and put it into your embedded machine.
 
</cl>
 
 
 
====Workaround for the Ubuntu Automounter (and Possibly Others)====
 
 
 
On many Linux desktops, a memory card will be automounted when it is inserted.  While this is a nice convenience feature for most users, it comes at the expense of developers.  This automount feature can be a source of frustration for those who haven't already found a way around the issues it causes.
 
 
 
Fortunately, we at EMAC have already found a method which works reliably on our recommended Linux distribution, Ubuntu 12.04 LTS, and have documented it here. On other systems, such as Debian, a workaround may not be needed.  If your system does not automount, see below.
 
 
 
<cl>
 
1. Insert the flash card into your card reader, and wait for the file browser window to appear.  If a messagebox appears asking you to choose what to do, tell it to open a file browser for browsing the files on the card.
 
* Keep the file browser window open, and stash it away for later use.
 
* Open a terminal and create a <code>/mnt/cfcard</code> directory, if it does not exist:
 
user@ubuntu:/# mkdir /mnt/cfcard
 
* Find out the device name of the card by looking for where the card was mounted.  The file browser window will list the name of the card under Devices in the left pane.  Often times, the name will be EMAC_OE.  Look for this name in the output of the <code>df</code> command:<syntaxhighlight lang="console">
 
user@ubuntu:/# df -hT | grep EMAC
 
/dev/sdb1                      ext3      3.7G  223M  3.3G  7% /media/EMAC_OE
 
</syntaxhighlight>
 
* From the output of this command, we can see that the <code>/media/EMAC_OE</code> mountpoint was mounted onto the <code>/dev/sdb1</code> device.  Therefore, this is the device in which we're interested.
 
* Mount the device on the directory from step i, without unmounting it first:<syntaxhighlight lang="console">
 
user@ubuntu:/# mount /dev/sdb1 /mnt/cfcard
 
user@ubuntu:/#
 
</syntaxhighlight>
 
 
 
* Now, switch to the root user account (if you aren't already root) and bind mount the host system's <code>/dev</code> directory to the cfcard's <code>/dev</code> directory.  This will provide the device node file that will be needed for LILO to be able to talk to the flash card.  '''NOTE:''' ''If you use the method shown here to switch to the root user, use your user's password at the password prompt.<syntaxhighlight lang="console">
 
user@ubuntu:/# sudo su
 
[sudo] password for user:
 
root@ubuntu:/# cd /mnt/cfcard
 
root@ubuntu:/mnt/cfcard#
 
root@ubuntu:/mnt/cfcard# mount --bind /dev dev/
 
root@ubuntu:/mnt/cfcard#
 
</syntaxhighlight>
 
 
 
* Now, use the <code>chroot</code> command to make the directory where you mounted the card the effective root directory for your terminal session:<syntaxhighlight lang="console">
 
root@ubuntu:/mnt/cfcard# chroot .
 
root@ubuntu:/#
 
</syntaxhighlight>
 
 
 
* Now that you're effectively running inside the filesystem on the flash card, you are able to run LILO to install the bootloader.  First, be sure to double check to ensure that the configuration file you're using points to the correct device node (in this example, <code>/dev/sdb1</code>) so that you don't overwrite the bootloader on your desktop.  If you overwrite the bootloader on your desktop, '''it will render your desktop system unbootable!'''  So, make sure to double check first.
 
* When you are sure you're using the right device node, run LILO to install the bootloader:<syntaxhighlight lang="console">
 
root@ubuntu:/# lilo -C /etc/lilo.conf.boot
 
Warning: '/proc/partitions' does not exist, disk scan bypassed
 
Added emac-oe *
 
One warning was issued.
 
root@ubuntu:/#
 
</syntaxhighlight>The warning, in this case, is normal.  It appears because you're in a fake "running system," which means the virtual files in the <code>/proc/</code> filesystem aren't mounted and able to provide information; hence, the non-existence of the <code>/proc/partitions</code> file.
 
* Now, you need to umount the device:<syntaxhighlight lang="console">
 
root@ubuntu:/# exit
 
root@ubuntu:/mnt/cfcard# cd ..
 
root@ubuntu:/mnt# umount cfcard
 
root@ubuntu:/mnt# exit
 
user@ubuntu:/#
 
</syntaxhighlight>
 
 
 
* Retrieve the file browser you stashed away earlier, and unmount the automounted directory for the card by clicking on the eject symbol next to the name of the device in the left pane.
 
 
 
* It is now safe to eject the card and put it into your embedded machine.
 
</cl>
 
 
 
==Configuring LILO==
 
 
 
As with any software of moderate or better complexity, configuration is required for LILO to function as desired.  The configuration created by EMAC and shipped with a system will usually suffice.  However, sometimes enough customization is required that the bootloader itself will need to be reconfigured.  Even if custom configuration isn't required, some of this information is important for ensuring that you will not accidentally overwrite the bootloader on your desktop with a bootloader intended for an embedded machine.
 
 
 
This section describes the parts of the LILO bootloader configuration file, and provides guidance on how to work with it.  The previous sections describe how to install and use the bootloader after it has been configured.
 
 
 
===Sections of the LILO Configuration File===
 
 
 
The LILO configuration file is split into two sections: global and per-image.  The global section, as the name implies, specifies options that pertain to LILO itself and to all images specified in the file.  The per-image section specifies options that apply to a specific image, some of which may override the global options.
 
 
 
====Global Options====
 
 
 
The LILO configuration file needs the following options, at a minimum, configured for the global settings:
 
 
 
* <code>disk</code> This option specifies the disk to which the LILO bootloader needs to be written.  This should always point to the device node currently associated with the disk.  For example, when mounted on a desktop, this may be <code>/dev/sdc</code>, which is (usually) the third "SCSI" device connected to the system.  The first would be <code>/dev/sda</code>, the second <code>/dev/sdb</code>, etc.  Even though the device may not be a SCSI device, it may be mounted via a generic SCSI driver, which is why it can appear as a SCSI device.  If it were mounted through the IDE subsystem instead, its device node would appear like <code>/dev/hdc</code> instead.
 
* <code>map</code> This option specifies the location of the map file to use.  Usually, this will be <code>/boot/map</code>.
 
* <code>lba32</code> This option tells LILO to use 32-bit Logical Block Addresses instead of cylinder/head/sector addresses.  This is needed for any disk with more than 1024 cylinders.  Since the vast majority of modern drives have more than 1024 cylinders, this option should always be specified.
 
* <code>boot</code> This option specifies the device which contains the boot sector.  As with the <code>disk</code> option, this should always be the device node associated with the disk on the current system.  For example, <code>boot=/dev/sdc</code>
 
 
 
'''Additional useful options:'''
 
 
 
* <code>vga</code> This option specifies the video mode the device should use, for systems which have video.  The parameter to pass comes from the BSP (Board Support Profile) layer for the board.  If you are unsure what to set here, EMAC can provide assistance with this.
 
* <code>serial</code> This useful option specifies a serial device to which a console should be attached, as well as the configuration settings for the console.  For example, to use the <code>/dev/ttyS0</code> serial device (the default console port on many boards) as a serial console which communicates as 115,200 baud, 8 bits, with no stop bits: <code>serial=0,115200n8</code>
 
* <code>timeout</code> This specifies the amount of time to wait before timing out and continuing on with the boot process using the configured defaults.  This value is specified in deciseconds.  For example, to set this value to 4.3 seconds: <code>timeout=43</code>
 
* <code>read-only</code> This option tells LILO to mount the root filesystem as read-only.  This is usually desired, since the Linux kernel will remount the device as writeable (if it needs to) once the boot process has been handed over to it.
 
* <code>install</code> This option specifies the type of screen which will be seen when the bootloader starts.  Normally, this will be set to <code>text</code>, which presents the simple interface shown in the examples on this page.  The <code>menu</code> option provides a nicer way to select an image to boot, but is usually not desirable to have on an embedded machine.  The <code>bitmap</code> option provides a graphical boot screen which looks very nice on a desktop installation, but is usually only used on an embedded machine when the product calls for showing graphics as early in the boot process as possible; a logo is typically placed here in such a case.
 
 
 
====Per-Image Options====
 
 
 
The following options are needed to configure images to be available to boot with LILO:
 
 
 
* <code>image</code> This option specifies the location of the kernel to boot.  Commonly, this will be <code>/boot/bzImage</code> or <code>/boot/bzImage-custom-3.10.2</code>
 
* <code>root</code> This option specifies the root partition to mount for the image.  This is typically <code>/dev/hda1</code> or <code>/dev/sda1</code>
 
* <code>label</code> This option tells LILO by what name to call the image.  For instance, this is usually <code>label=emac-oe</code> for a standard EMAC image, but for a custom product under development, it might be <code>label=custom-image-test-v3</code>
 
 
 
====Working with LILO Configurations====
 
 
 
The above information tells you about the common options and how to set them.  Additional information can be found be reading through the manual page for <code>lilo.conf</code>.  This manpage is available on many sites online.
 
 
 
Actually using these options to create a configuration file is done most easily by copying the EMAC provided LILO configuration file, then modifying the copy.  It is a good practice to make sure you have a bootable flash card set aside in case you have difficulty getting your modified flash card back into a bootable state.
 

Latest revision as of 10:59, 14 April 2014

TODO: {{#todo:SEOKWREV(11.27.13-01:00->MD+);(11.27.13-17:50->MD+);(12.16.13-02:30->MD+);(12.16.13-10:50->MW-);(12.16.13-12:30->MD+); (12.16.13-12:57->MW+);(12.16.13-18:30->KY+);(03.06.14-15:35->BS-);(04.11.14-16:30->BS+);(04.14.14-11:00->BS+)|Mike Dean|oe 4,oe 5,md,SEOKWREV,mw,ky,bs}}

The LInux LOader - LILO

LILO is a bootloader which was created for Linux. LILO was the default bootloader used for most desktop and server distributions for many years. It is still used on x86 embedded systems because it provides everything an embedded system needs to boot into embedded Linux.

Using LILO

When LILO is installed on a drive or partition, LILO will provide a menu at boot time. This menu typically shows a list of available operating system kernels and/or operating systems from which a user may select. On embedded systems, this menu is typically streamlined down to a very simple interface.

When LILO is configured with a timeout, as it usually is, a user may simply wait for the duration of the timeout for LILO to boot the operating system and kernel which have been configured as the default for the system. If the user doesn't wish for the default to boot, the user may press any key other than the Enter key before the timeout duration has expired to access alternative options. If the user presses enter during the timeout delay, the timeout immediately expires and the boot process continues with the default configured OS and kernel. The default boot process starts as shown here:

LILO 22.8 boot:
Loading emac-oe................................................
BIOS data check successful

Pressing the TAB key will show a list of available OS configurations to boot. Usually, there will only be one available.

LILO 22.8 boot:
emac-oe
boot:

Typing the name of the OS configuration (the OS + kernel) will boot the system with that configuration.

LILO 22.8 boot:
emac-oe
boot: emac-oe
Loading emac-oe................................................
BIOS data check successful
EMAC OpenEmbedded Linux 4.0 (stable-2009)
Some code contained within Copyright 2008-2010 EMAC, Inc.

emac 2009-stable vortex86 ttyS0

vortex86 login:

Once the system has booted to the login prompt, the user may log into the system as usual. On EMAC products, the default password for the root account is emac_inc. Please see System Log In for more information regarding the login process.

Additional Abilities of LILO

In addition to the normal boot selection described above, LILO is also able to pass arguments to the Linux kernel for booting. These arguments can be useful for enabling output of boot messages, configuring a video driver, and configuring a number of other things which can accept kernel command line configuration options.

For example, the console=ttyS0,115200 option can be passed to a kernel to enable boot message output to the serial console:

LILO 22.8 boot:                                                                 
emac-oe                                                                         
boot: emac-oe console=ttyS0,115200                                              
Loading emac-oe................................................                 
BIOS data check successful                                                      
Linux version 2.6.30.10 (mdean@engineering0) (gcc version 4.2.4) #1 PREEMPT Fri Feb 1 18:38:41 CST 2013
KERNEL supported cpus:
  Intel GenuineIntel
  AMD AuthenticAMD
  NSC Geode by NSC
  Cyrix CyrixInstead
  Centaur CentaurHauls
  Transmeta GenuineTMx86
  Transmeta TransmetaCPU
  UMC UMC UMC UMC
CPU: vendor_id 'Vortex86 SoC' unknown, using generic init.
...
...
...
EMAC OpenEmbedded Linux 4.0 (stable-2009)
Some code contained within Copyright 2008-2010 EMAC, Inc.

emac 2009-stable vortex86 ttyS0

vortex86 login:

Other arguments to the kernel are passed in a similar manner. The available options to pass will depend on the specific configuration of the kernel which will be booted by LILO. A page which contains many more kernel arguments can be found here: https://www.kernel.org/doc/Documentation/kernel-parameters.txt

Next Steps

Follow these guides for more information: