Notizbl0g.

h4cking, ham radio, fire fighting and m0re

Fli4l on Alix 2D13 With Large CF Cards

This information is outdated. See [1]

If you have problems with installing fli4l on a large Compact Flash card the following information might be useful for you. I encountered the problem when I tried to install fli4l on a 2GB Compact Flash card.

The mkfli4l.sh script installed the syslinux bootloader in the Master Boot Record (MBR) of the CF card. The subsequent attempt to boot the CF card failed because the syslinux bootloader could not boot the linux system.

So I decided to give a smaller CF card a try. In my hardware collection I discovered a CF card with a capacity of 128MB. With this card the installation of fli4l suceeded without problems just like the 2GB card. But the syslinux bootloader could boot the system without problems.

But the 128MB card of course does not fit my storage requirements. So I was looking for a way to get the 2GB CF card working. The fli4l system is to be installed into a small partition with a capacity of about 64MB and the remaining space on the flash card should be used for a data partition to store data that should endure a reboot of the system.

The idea was to get GRUB boot the system. So I installed GRUB in the MBR and syslinux into the boot sector of the first partition where the fli4l system resides.

The following describes all the steps that I took for installing a working fli4l system on the 2GB card that I bought with my ALIX 2D13 mainboard.

Partitioning and creation of filesystems

First of all I partitioned the CF card to have a relativly small partition for the operating system itself. The fli4l operating system comes in a compressed archive which is decompressed during the boot process. When the system is booted the operating system works from a ramdisk in the main memory.

This is the partition layout on my 2 GB CF card to give an example (the CF card was partitioned with a second computer which named the device with the CF card as /dev/sdb; replace /dev/sdb with the according device name of your system). To work on the partition table of the CF card please make sure that the device is not mounted.

   # sudo fdisk -l /dev/sdb
   Disk /dev/sdb: 2004 MB, 2004516864 bytes
   62 heads, 62 sectors/track, 1018 cylinders
   Units = cylinders of 3844 * 512 = 1968128 bytes

   Device      Boot  Start     End     Blocks    Id   System
   /dev/sdb1     *       1      69     132587     6   FAT16
   /dev/sdb2            70    1018    1823978    83   Linux

   Command (m for help): q

The first partition is the small one for the operating system image with a FAT16 filesystem. This partition has to be marked as active to make it bootable. The data partition is the second one with a typical Linux filesystem. Because fli4l just has a modules for ext3 filesystems, this filesystem is the only choice. Please pull the CF card out of the reader after you finished this step and put it back in to cause the partition table to be re-read.

   # sudo mkdosfs /dev/sdb1
   # sudo mkfs.ext3 /dev/sdb2

The two commands above create filesystems as aforementioned on the two partitions of the CF card. At this point you can install the fli4l system as normal into the first partition.

Installation of the Fli4l Base System

I use the mkfli4l script with the following options:

   # ./mkfli4l.sh --build ./build --filesonly

This creates all needed files in the directory called build. Just copy over all the files in there to the first partition of the CF card in my case /media/disk. In the config/base.txt there are at least two options that you should set. The first one is for configuring fli4l for working from a harddisk and the second one enables some kernel features for the Alix board to properly reboot and not prduce errors on missing keyboards.

1
2
BOOT_TYPE='hd'
KERNEL_BOOT_OPTION='nokbd reboot=bios'

in config/base.txt to let fli4l boot of the CF card which is recognized as hard disk. To enable this feature just must also enable the hddrv packet with the config file config/hd.txt. The relevant parts from that file are shown below:

1
2
3
4
OPT_HDDRV='yes'
HDDRV_N='1'
HDDRV_1='ide-hd'
HDDRV_1_OPTION=''

This step forces you to create a file called hd.cfg in the boot partition of the CF card. Here the file is called /media/disk/hd.cfg and contains only one line. This line reads:

1
hd_boot='hda1'

That is all that needs to be done to install fli4l onto the CF card. After the installation of the fli4l operating system you can continue with this guide to get the bootloader working.

Installing syslinux loader

So the next step is the installation of syslinux into the boot section of the first partition.

   # sudo syslinux -s /dev/sdb1

This command has to be executed with sudo or with super user privileges. The option -s uses the “safe, slow and stupid” version of syslinux. After the installation of syslinux we can continue with the installation of GRUB into the MBR.

Installation of bootloader GRUB

For this to work the CF card device has to be mounted to enable GRUB to store some files needed for the GRUB loader itself. In this case the CF card is auto-mounted by my Ubuntu system on /media/disk. Again, please adjust the names for devices and paths according to your setup and double check to make sure that you do not overwrite thr MBR of your harddisk accidently.

You can then install GRUB into the (MBR) master boot sector of the CF card with the following command:

   # sudo grub-install --no-floppy --recheck --root-directory=/media/disk /dev/sdb

This command advises GRUB to recheck the device map file. Otherwise it would say that the device does not have any corresponding BIOS drive. The root directory for GRUB is configured with the –root-directory option. This tells GRUB to store its needed files to the path given. The path should point to the directory where the CF card is mounted. The last option names the device where GRUB should be installed to. This option should name the correct device under which the CF card is known to the operating system.

Configuring GRUB

After executing this command GRUB should be fully installed into the MBR of the CF card. You can then start to create a file that contains the menu structure of the bootloader which defines what operating systems you can choose to start. For this fli4l system the file is very simple because there is only one operating system to start. This file should be named menu.lst and be placed into GRUB’s root directory that was used with the last command. In this case the full path would be: /media/disk/boot/grub/menu.lst.

This is the menu.lst that I use for my fli4l system on the CF card in the Alix 2D13 moainboard:

1
2
3
4
5
6
7
8
9
default 0
timeout 0
hiddenmenu
serial --unit=0 --speed=38400
terminal serial
title default
root (hd0,0)
makeactive
chainloader +1

The default entry names the operating system to start if the user does not make any input during the display of the menu. The timeout is disabled in my case because it does not make much sense to have some time to choose if there is only one operating system available. Therefore the diplay of the menu is disabled as well using the command “hiddenmenu”.

The next two commands specify to use a serial tty device you can use as a serial console to have access to the system. I also enabled the serial console in the configuration of the fli4l system.

The last section describes the first entry of the bootmenu. To boot off the boot section of the first partition you need to make it active and then tell GRUB to chainload the bootloader found in this partition. Remember that we installed syslinux into the bootsection of the first partition.

If you have done all these steps correctly your system will be able to boot on large CF cards. After the BIOS gave over the contol to the bootloader you will see the messages of the boot process if you attach a terminal program to the serial device on the Alix board. By default the Alix TinyBIOS is also enabled to use the serial console with the parameters mentioned above.

References

[1] https://www.florian-wolters.de/blog/2015/11/24/update-on-fli4l-and-cf-cards/