Difference between revisions of "Installing LILO"

From wiki.emacinc.com
Jump to: navigation, search
 
(17 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{todo|Complete (12.16.13-03:15->MD+);(12.16.13-12:50->MD);(12.16.13-13:40->MD);(12.16.13-13:45->MW+);(12.16.13-18:20->KY+)|Mike Dean|project=oe 4,oe 5,md,Complete,mw,ky}}
+
{{todo|Complete (12.16.13-03:15->MD+);(12.16.13-12:50->MD);(12.16.13-13:40->MD);(12.16.13-13:45->MW+);(12.16.13-18:20->KY+);(03.06.14-15:40->BS-);(04.11.14-16:40->BS+)(11.12.14->MD+)(11.10.2015-12:05->MD+);(11.13.2015-15:50->MD+);(11.16.2015-12:38->KY+);(11.16.2015-13:10->MG+)|Mike Dean|project=oe 4,oe 5,md,mw,ky,bs,MG,Complete}}
 +
 
 +
{{#seo:
 +
|title=Installing LILO
 +
|titlemode=append
 +
|keywords=LILO Linux USB,Automounter
 +
|description=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.
 +
}}
 +
==Installing LILO==
  
==Introduction==
+
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.
  
LILO needs to be installed or reinstalled any time any of the lilo.conf configuration options are changed or when a new kernel is to be used. See the [[Configuring LILO]] page for setting the options in lilo.conf. See below for installing a new kernel. Reference the sections below if lilo is to be installed on a running machine or from a Compact Flash card.
+
===Installing Onto the Local Machine===
  
==Installing a new Kernel==
+
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.
  
To install a new kernel onto an already running machine, use scopy to copy the new kernel to /boot. Then update the symbolic link, bzImage.
+
The easiest way to install LILO onto the local system's Master Boot Record, using the default configuration file (<code>/etc/lilo.conf</code>), is to type:
<syntaxhighlight lang=console>
 
developer@ldc:~$ scp /path/to/bzImage-VERSION_NEW.bin root@TARGET_IP:/boot
 
developer@ldc:~$ ssh root@TARGET_IP
 
root@oe:/# cd /boot
 
root@oe:/# rm bzImage
 
root@oe:/# ln -s bzImage-VERSION_NEW.bin bzImage
 
</syntaxhighlight>
 
  
Then review the lilo.conf and continue below with [[#Installing_Onto_the_Local_Machine | Installing Onto the Local Machine]]
+
{{cli|lilo|hostname=oe}}
  
To install a new kernel into an image on a mounted Compact Flash card, copy the kernel to the /boot directory of the mounted root filesystem. Then chroot and update the symbolic link. Follow the steps below [[#Installing_LILO_Onto_a_Removable Drive | Installing LILO Onto a Removable Drive]]
+
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:
 
 
==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 kernel is changed.
 
The easiest way to install LILO onto the system's Master Boot Record, using the default configuration file (<code>/etc/lilo.conf</code>), is run lilo on the target device:
 
 
 
  root@oe:/# lilo
 
 
 
This method works well when the default configuration can be used. Many times, an alternate configuration will be used 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 to lilo with the -C option:
 
 
   
 
   
root@oe:/# lilo -C /etc/alternate_lilo_configuration_file.conf
+
{{cli|lilo -C /etc/alternate_lilo_configuration_file.conf|hostname=oe}}
  
 
The <code>-C</code> (capital C) switch tells <code>lilo</code> to use the configuration file specified after the switch when installing itself.
 
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==
+
{{ note | LILO will need to be reinstalled whenever a new kernel is installed on the machine.
 +
<br />
 +
The configuration file used to install LILO the last time (most likely, the default config file, <code>/etc/lilo.conf</code>, can be used to reinstall LILO to use the new kernel.  If the kernel name changed, the configuration file will need to be modified to suit before reinstalling LILO.  See [[Configuring LILO]] for more information on how to do this.
 +
<br /><br />
 +
When the config file is correct, run LILO the same way you did in the section above this note.}}
  
The method shown above is used on a running embedded system. Additional steps are required when the root filesystem is on a Compact Flash card inserted into a Linux PC. This method is usually necessary when there isn't already a bootable disk for the embedded machine.
+
===Installing LILO Onto a Removable Drive===
<cl>
 
1. Determine the device node of the Compact Flash card by using <code>dmesg</code>.
 
  
developer@ldc:~/# dmesg | tail -n 15
+
The last method shown above is not what is needed when the embedded machine's root drive is not in the running embedded systemWith 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 cardThis method is usually necessary when there isn't already a bootable disk for the embedded machine.
...
 
  [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
 
  
  * The device node <code>sdb</code> was created for the flash card with one partition <code>sdb1</code>(in this example). Also note that <code>sdb</code> reports a size of 4.00 GB which corresponds to the size of the card inserted.
+
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:
  
* Determine if the card was automatically mounted to the desktop's filesystem. Problems have been identified when running lilo on an automounted device. The best way to avoid problems later in the process is to unmount and manually remount the device.
+
====Installing from a System with No Automounter or a Non-Interfering Automounter====
  
<syntaxhighlight lang="console">
+
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.
developer@ldc:~$ mount | grep sdb1
 
/dev/sdb1 on /media/EMAC-OE type ext3 (rw,nosuid,nodev,uhelper=udisks)
 
</syntaxhighlight>
 
  
  * If there is no output from this command, continue with step 3. Otherwise follow the next step to unmount the device.
+
<cl>1. Mount the drive.
 +
i. 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 <code>udev</code>) by using <code>dmesg</code>.
 +
{{clo|indent=1}}
 +
{{clio|dmesg | tail -n 15|hostname=debian|username=user}}
 +
...<br />
 +
[126468.154762] sd 6:0:0:0: [sdb] 7831152 512-byte logical blocks: (4.00 GB/3.73 GiB)<br />
 +
[126468.182196]  sdb: sdb1<br />
 +
[126468.688061] kjournald starting.  Commit interval 5 seconds<br />
 +
[126468.691223] EXT3-fs (sdb1): using internal journal<br />
 +
[126468.691225] EXT3-fs (sdb1): recovery complete<br />
 +
[126468.694526] EXT3-fs (sdb1): mounted filesystem with ordered data mode<br />
 +
[173828.541718] sdb: detected capacity change from 4009549824 to 0<br />
 +
[179577.977554] sd 6:0:0:0: [sdb] 7831152 512-byte logical blocks: (4.00 GB/3.73 GiB)<br />
 +
[179577.994839]  sdb: sdb1<br />
 +
[179578.376157] kjournald starting.  Commit interval 5 seconds<br />
 +
[179578.381428] EXT3-fs (sdb1): using internal journal<br />
 +
[179578.381433] EXT3-fs (sdb1): recovery complete<br />
 +
[179578.384661] EXT3-fs (sdb1): mounted filesystem with ordered data mode<br />
 +
{{clos}}
 +
* Since the device node <code>sdb1</code> was created for the flash card (in this example), that device needs to be mounted somewhere accessible. In this example, the <code>/mnt/cfcard</code> directory is used:
 +
{{clo|indent=1}}
 +
{{clio|sudo su|hostname=debian|username=user}}
 +
[sudo] password for user:<br />
 +
{{clio|mkdir -p /mnt/cfcard|hostname=debian}}
 +
{{clio|mount /dev/sdb1 /mnt/cfcard|hostname=debian}}
 +
{{clio||hostname=debian}}
 +
{{clos}}
 +
* Bind mount the device nodes into the filesystem so that LILO will be able to communicate with the flash card:
 +
{{clo}}
 +
{{clio|cd /mnt/cfcard|hostname=debian}}
 +
{{clio|mount --bind /dev dev/|pwd=/mnt/cfcard|hostname=debian}}
 +
{{clio| |pwd=/mnt/cfcard|hostname=debian}}
 +
{{clos}}
  
  developer@ldc:~/# umount /dev/sdb1
+
* <code>chroot</code> into the filesystem:
 +
{{clo}}
 +
{{clio|chroot .|pwd=/mnt/cfcard|hostname=debian}}
 +
{{clio||hostname=debian}}
 +
{{clos}}
  
* Now mount the card so that it's contents can be accessible to the desktop. First create a mount point (directory) if one does not exist, then issue the <code>mount</code> command.
+
* 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 the desktop system unbootable.
 +
{{clo}}
 +
{{clio|lilo -C /etc/lilo.conf.boot|hostname=debian}}
 +
Warning: '/proc/partitions' does not exist, disk scan bypassed<br />
 +
Added emac-oe *<br />
 +
One warning was issued.<br />
 +
{{clio||hostname=debian}}
 +
{{clos}}
 +
Note that the warning here is normal, because LILO is being installed inside a chroot which doesn't have a mounted <code>/proc</code> virtual filesystem.
 +
* Exit the chroot and unmount the device:
 +
{{clo}}
 +
{{clio|exit|hostname=debian}}
 +
{{clio|cd ..|pwd=/mnt/cfcard|hostname=debian}}
 +
{{clio|umount cfcard/dev|pwd=/mnt|hostname=debian}}
 +
{{clio|umount cfcard|pwd=/mnt|hostname=debian}}
 +
{{clos}}
  
<syntaxhighlight lang="console">
+
* It is now safe to remove the flash card and put it into the embedded machine.
developer@ldc:~/# sudo su
+
</cl>
[sudo] password for user:
 
root@ldc:~/# mkdir -p /mnt/cfcard
 
root@ldc:~/# mount /dev/sdb1 /mnt/cfcard
 
root@ldc:~/#
 
</syntaxhighlight>
 
  
* Bind mount the device nodes into the filesystem so that LILO will be able to communicate with the flash card:
+
====Workaround for the Ubuntu Automounter (and Possibly Others)====
root@ldc:~/# cd /mnt/cfcard
 
root@ldc:/mnt/cfcard# mount --bind /dev dev/
 
root@ldc:/mnt/cfcard#
 
  
* If a new kernel is to be installed, copy it not to the /boot directory on the CF card.
+
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.
<syntaxhighlight lang="console">
 
root@ldc:/mnt/cfcard# cp /path/to/bzImage-VERSION_NEW.bin /mnt/cfcard/boot/
 
</syntaxhighlight>
 
  
* <code>chroot</code> into the filesystem on the Compact Flash card:
+
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 neededFor a system which automounts, see below.
root@ldc:/mnt/cfcard# chroot .
 
  bash-3.2#
 
  
* Update the symbolic link to point to the new kernel if a new kernel is to be used.
+
<cl>1. 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.
  bash-3.2# cd /boot
+
* Keep the file browser window open, and stash it away for later use.
  bash-3.2# rm bzImage
+
* Open a terminal and create a <code>/mnt/cfcard</code> directory, if it does not exist:
bash-3.2# ln -s bzImage-VERSION_NEW.bin bzImage
+
{{cli|sudo mkdir /mnt/cfcard|username=user|hostname=ubuntu}}
 +
* 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 <code>df</code> command:
 +
{{clo}}
 +
{{clio|df -hT | grep EMAC|username=user|hostname=ubuntu}}
 +
Filesystem                      Type      Size  Used Avail Use% Mounted on<br />
 +
/dev/sdb1                      ext3      3.7G  223M 3.3G  7% /media/EMAC_OE<br />
 +
{{clos}}
 +
* 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 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:
 +
{{clo}}
 +
{{clio|sudo su|username=user|hostname=ubuntu}}
  
* Inspect the configuration file that will be used when running lilo e.g. lilo.conf.boot. Make sure that the <code>root=/dev/xxx</code> and <code>disk=/dev/xxx</code> lines point to the correct device node that the Compact Flash card is mounted on (in this example, <code>/dev/sdb</code>). If these lines point to the desktop hard drive, the system bootloader will be overwritten and cause the desktop to be unbootable See [[Configuring LILO]] for more information.  
+
[sudo] password for user:
 +
{{clio|mount /dev/sdb1 /mnt/cfcard|hostname=ubuntu}}
 +
{{clio||hostname=ubuntu}}
 +
{{clos}}
 +
* 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.
  
* Run <code>lilo</code> with the appropriate LILO configuration file.
+
{{clo}}
 +
{{clio|cd /mnt/cfcard|hostname=ubuntu}}
 +
{{clio|mount --bind /dev dev/|pwd=/mnt/cfcard|hostname=ubuntu}}
 +
{{clio||pwd=/mnt/cfcard|hostname=ubuntu}}
 +
{{clos}}
  
<syntaxhighlight lang=console>
+
* Now, use the <code>chroot</code> command to make the directory where the card is mounted the effective root directory for this terminal session:
bash-3.2#  lilo -C /etc/lilo.conf.boot
+
{{clo}}
Warning: '/proc/partitions' does not exist, disk scan bypassed
+
{{clio|chroot .|pwd=/mnt/cfcard|hostname=ubuntu}}
Added emac-oe *
+
{{clio||pwd=/mnt/cfcard|hostname=ubuntu}}
One warning was issued.
+
{{clos}}
bash-3.2#
 
</syntaxhighlight>
 
  
  * Note that the warning here is normal, because LILO is being installed inside a chroot which doesn't have a mounted <code>/proc</code> virtual filesystem.
+
* 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, <code>/dev/sdb1</code>) 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:
 +
{{clop}}
 +
{{cliop|lilo -C /etc/lilo.conf.boot|hostname=ubuntu}}
 +
Warning: '/proc/partitions' does not exist, disk scan bypassed
 +
Added emac-oe *
 +
One warning was issued.
 +
{{cliop||hostname=ubuntu}}
 +
{{closp}}
 +
The warning, in this case, is normal.  It appears because this is 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:
 +
{{clo}}
 +
{{clio|exit|hostname=ubuntu}}
 +
{{clio|cd ..|pwd=/mnt/cfcard|hostname=ubuntu}}
 +
{{clio|umount cfcard/dev|pwd=/mnt|hostname=ubuntu}}
 +
{{clio|umount cfcard|pwd=/mnt|hostname=ubuntu}}
 +
{{clio|exit|pwd=/mnt|hostname=ubuntu}}
 +
{{clio||hostname=ubuntu}}
 +
{{clos}}
  
* Exit the chroot and unmount 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.
 
bash-3.2#  exit
 
root@ldc:/mnt/cfcard# cd ..
 
root@ldc:/mnt# umount cfcard/dev/
 
root@ldc:/mnt# umount cfcard/
 
  
* It is now safe to remove the flash card and put it into the embedded machine.
+
* It is now safe to eject the card and put it into the embedded machine.
 
</cl>
 
</cl>
  
Line 124: Line 170:
  
 
* [[Configuring LILO]]
 
* [[Configuring LILO]]
 
==See Also==
 
 
[http://lilo.alioth.debian.org/olddoc/html/user_21-5.html Lilo User Guide]
 

Latest revision as of 14:10, 16 November 2015

TODO: {{#todo:Complete (12.16.13-03:15->MD+);(12.16.13-12:50->MD);(12.16.13-13:40->MD);(12.16.13-13:45->MW+);(12.16.13-18:20->KY+);(03.06.14-15:40->BS-);(04.11.14-16:40->BS+)(11.12.14->MD+)(11.10.2015-12:05->MD+);(11.13.2015-15:50->MD+);(11.16.2015-12:38->KY+);(11.16.2015-13:10->MG+)|Mike Dean|oe 4,oe 5,md,mw,ky,bs,MG,Complete}}

Installing LILO

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:

root@oe:~# lilo

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:

root@oe:~# lilo -C /etc/alternate_lilo_configuration_file.conf

The -C (capital C) switch tells lilo to use the configuration file specified after the switch when installing itself.



NOTE
LILO will need to be reinstalled whenever a new kernel is installed on the machine.


The configuration file used to install LILO the last time (most likely, the default config file, /etc/lilo.conf, can be used to reinstall LILO to use the new kernel. If the kernel name changed, the configuration file will need to be modified to suit before reinstalling LILO. See Configuring LILO for more information on how to do this.

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.

  1. Mount the drive.

    1. Insert the flash card into the development system's card reader.

    2. Find out where the device node for the card was created (assuming the development machine uses udev) by using dmesg.

    user@debian:~# dmesg

    ...
    [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

    • Since the device node sdb1 was created for the flash card (in this example), that device needs to be mounted somewhere accessible. In this example, the /mnt/cfcard directory is used:

    user@debian:~# sudo su

    [sudo] password for user:

    root@debian:~# mkdir -p /mnt/cfcard
    root@debian:~# mount /dev/sdb1 /mnt/cfcard
    root@debian:~#
  2. Bind mount the device nodes into the filesystem so that LILO will be able to communicate with the flash card:

    root@debian:~# cd /mnt/cfcard
    root@debian:/mnt/cfcard# mount --bind /dev dev/
    root@debian:/mnt/cfcard#
  3. chroot into the filesystem:

    root@debian:/mnt/cfcard# chroot .
    root@debian:~#
  4. Run lilo 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 the desktop system unbootable.

    root@debian:~# lilo -C /etc/lilo.conf.boot

    Warning: '/proc/partitions' does not exist, disk scan bypassed
    Added emac-oe *
    One warning was issued.

    root@debian:~#

    Note that the warning here is normal, because LILO is being installed inside a chroot which doesn't have a mounted /proc virtual filesystem.

  5. Exit the chroot and unmount the device:

    root@debian:~# exit
    root@debian:/mnt/cfcard# cd ..
    root@debian:/mnt# umount cfcard/dev
    root@debian:/mnt# umount cfcard
  6. 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.

  1. 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.

  2. Keep the file browser window open, and stash it away for later use.

  3. Open a terminal and create a /mnt/cfcard directory, if it does not exist:

    user@ubuntu:~# sudo mkdir /mnt/cfcard
  4. 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 df command:

    user@ubuntu:~# df -hT

    Filesystem Type Size Used Avail Use% Mounted on
    /dev/sdb1 ext3 3.7G 223M 3.3G 7% /media/EMAC_OE

  5. From the output of this command, we can see that the /media/EMAC_OE mountpoint was mounted onto the /dev/sdb1 device. Therefore, this is the device needed for the next step.

  6. 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:

    user@ubuntu:~# sudo su

    [sudo] password for user:

    root@ubuntu:~# mount /dev/sdb1 /mnt/cfcard
    root@ubuntu:~#
  7. Bind mount the host system's /dev directory to the cfcard's /dev directory. This will provide the device node file that will be needed for LILO to be able to talk to the flash card.

    root@ubuntu:~# cd /mnt/cfcard
    root@ubuntu:/mnt/cfcard# mount --bind /dev dev/
    root@ubuntu:/mnt/cfcard#
  8. Now, use the chroot command to make the directory where the card is mounted the effective root directory for this terminal session:

    root@ubuntu:/mnt/cfcard# chroot .
    root@ubuntu:/mnt/cfcard#
  9. 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.


  10. When you are sure you're using the right device node, run LILO to install the bootloader:

    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:~#

    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 /proc/partitions file.

  11. Now, you need to umount the device:

    root@ubuntu:~# exit
    root@ubuntu:/mnt/cfcard# cd ..
    root@ubuntu:/mnt# umount cfcard/dev
    root@ubuntu:/mnt# umount cfcard
    root@ubuntu:/mnt# exit
    root@ubuntu:~#
  12. 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.

  13. It is now safe to eject the card and put it into the embedded machine.

Next Steps