CompactFlash' File system structure

The file system should look familiar to anyone who is at home with Linux/UNIX systems. Since embedded systems tend to get shut off accidentally, an effort has been made to keep essential files in filesystems mounted read-only. This goes for the root filesystem as well as the small FAT16 from which the System ACE chip reads the initial boot data. While these can be remounted for read-write, this should be avoided. Instead, a special partition has been set up for allowing write access. Files which are normally altered in the root filesystems have been replaced by symbolic links, as detailed below.

Users who have chosen a non-Sandisk CompactFlash should be advised that mounting a filesystem for write carries a significant chance of making it unmountable in the future, as repeated writes to system blocks may push a low-end flash device beyond its reliability.

The CompactFlash has been assigned three partitions:

  • Primary partition 1 (/dev/xsa1, 47MB). Configured as FAT16, and is intended to hold the xillybus.ace file, from which the System ACE chip configures the FPGA. Mounted read-only by default as /mnt/fat16 (or /rw/system/mnt/fat16, to be accurate).
  • Primary partition 2 (/dev/xsa2, 205MB). This ext2 partition is used as the root filesystem, and is mounted read-only by default.
  • Primary partition 3 (/dev/xsa3, 91MB). This ext2 partition is used for anything that needs to be written into the CompactFlash under normal operation. It’s mounted read-write by default at /rw.

The following files in the root filesystem are symbolic links:

  • /mnt to /rw/system/mnt — This allows creation of subdirectories on /mnt, and mounting /mnt/something. Unmounting is somewhat trickier, because the system knows the mount point by its full path. Accordingly, the full path must be used when unmounting, e.g. /rw/system/mnt/something. Or the name of the device file, when applicable.
  • .ash_history to /rw/system/.ash_history
  • /etc/httpd.conf to /rw/system/httpd.conf
  • /etc/resolv.conf to /rw/system/resolv.conf — This allows the DHCP client to set up the DNS server list, despite the root file system being mounted read-only.

When necessary to write to the root partition, it can be remounted for read-write as follows:

# mount -o remount,rw /

Likewise with the FAT16 partition:

# mount -o remount,rw /dev/xsa3

It’s recommended to remount them back as read-only as soon as possible after finishing whatever was needed to be done with them. For example, to remount the root partition back to read-only, go

# mount -o remount,ro /

And the FAT16 partition:

# mount -o remount,ro /dev/xsa3

Shutting down the system

Before powering down the card, the Linux system should be shut down properly, or problems may occur on the next reboot. The command for doing this is “halt”:

# halt

This runs a small script, which attempts to remount all partitions on the CompactFlash as read-only before running shutting down. If some process in the system has a file open for write, this will fail. In this case, use “ps” to track down the process, and possibly kill it (or kill -9) so that the filesystem can be released.

Execution environment

The Linux distribution has the basic set of libraries for dynamic linking, so basic applications can run on the platform just like on any Linux machine.

Even so, the lightweight busybox suite supplies all UNIX command-line utilities. Please consult busybox’ command summary to get a summary of the commands and their usage. Note that the installed version of busybox is v1.17.1, so the web site may reflect newer version (with possibly unsupported utilities). Type “busybox” at command prompt on the platform to get a full list of commands.

Custom rc file

When booting up, the script checks for the existence of an executable file at /rw/system/userrc. If such file exists, it’s run at the last stage of the boot process. This file can be used to e.g. set up networking automatically.

The file is run “as is”. If it’s a script, it must have a #! (shebang) header. It can also be an executable binary. Either way, don’t forget to set the executable flag for it, or it will be ignored.

For example, to make the platform available on the LAN with a constant address, /rw/system/userrc should read:


ifconfig eth0 netmask

and made executable:

/ # chmod a+x /rw/system/userrc

Note that the platform can also get an address with DHCP.

Which bring us to the next recommended read: Getting around II: Networking.