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 is intended to be inserted into an embedded system for which it is being created.
Installing Onto the Local Machine
Before LILO can be used to boot a system, it must be installed onto 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 onto the local system's Master Boot Record, using the default configuration file (
/etc/lilo.conf), is to type:
This method works well for systems where only a small change is required to the default configuration, but is not often what is desired on an embedded system. Many times, an alternate file will be used to store the new configuration so that a breaking change to a known-good configuration file will not leave the system without a usable configuration file. If a configuration file in an alternate location needs to be used, it will have to be specified like this:
-C (capital C) switch tells
lilo to use the configuration file specified after the switch when installing itself.
| LILO will need to be reinstalled whenever a new kernel is installed on the machine.
When the config file is correct, run LILO the same way you did in the section above this note.
Installing LILO Onto a Removable Drive
The last method shown above is not what is needed when the embedded machine's root drive is not in the running embedded system. With a Compact Flash disk, for instance, containing the Linux filesystem and mounted on a desktop Linux development machine, a few hoops need to be jumped through in order to install the bootloader onto the Compact Flash card. This method is usually necessary when there isn't already a bootable disk for the 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 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 possibly malicious code, follow these directions.
Mount the drive.
Insert the flash card into the development system's card reader.
Find out where the device node for the card was created (assuming the development machine uses
udev) by using
Since the device node
sdb1was created for the flash card (in this example), that device needs to be mounted somewhere accessible. In this example, the
/mnt/cfcarddirectory is used:
Bind mount the device nodes into the filesystem so that LILO will be able to communicate with the flash card:
chrootinto the filesystem:
lilowith the appropriate LILO configuration file. Be sure to double check to ensure that the configuration file is correct, because a mistake here could render the desktop system unbootable.
Note that the warning here is normal, because LILO is being installed inside a chroot which doesn't have a mounted
Exit the chroot and unmount the device:
It is now safe to remove the flash card and put it into the embedded machine.
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 14.04 LTS, and have documented it here. On other systems, such as Debian, a workaround may not be needed. For a system which automounts, see below.
Insert the flash card into the development machine's 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
/mnt/cfcarddirectory, if it does not exist:
Find out the device name of the card by looking for the location 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
From the output of this command, we can see that the
/media/EMAC_OEmountpoint was mounted onto the
/dev/sdb1device. Therefore, this is the device needed for the next step.
Now, switch to the root user account (if not already running as root) and mount the device on the directory from step 3, without unmounting it first:
Bind mount the host system's
/devdirectory to the cfcard's
/devdirectory. This will provide the device node file that will be needed for LILO to be able to talk to the flash card.
Now, use the
chrootcommand to make the directory where the card is mounted the effective root directory for this terminal session:
Now that the shell is effectively running inside the filesystem on the flash card, LILO can be run 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,
/dev/sdb1) so that you don't overwrite the bootloader on your desktop (see Configuring LILO for more information).
WARNING! If you overwrite the bootloader on your desktop, it will render your desktop system unbootable! Make sure to double check this if you value the ability to boot your desktop.
When you are sure you're using the right device node, run LILO to install the bootloader:
The warning, in this case, is normal. It appears because this is a fake "running system," which means the virtual files in the
/proc/filesystem aren't mounted and able to provide information; hence, the non-existence of the
Now, you need to umount the device:
Retrieve the file browser that was 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 the embedded machine.