Menu

Customize Firmware Log in to Edit

João Cardoso Francois Blackburn EZ

Introduction

Alt-F loads from flash, which makes difficult change it when something is not OK or is not suited to your needs. Generally you have to wait for a new version that fixes the problem.

On a normal disk-based linux distribution, you can just edit a file and it will survive reboots, as it resides on disk.

On Alt-F, by contrary, any change will be lost in the next reboot. The exception is a set of well defined files, the "Settings", that are saved in flash memory and loaded on the next reboot (or on demand), and that overrides the defaults.

There are two ways to change this:

Run automatically a script at boot time

Go to Services->User->user Configure and fill-in under "Script to execute on power-up" the full path of a executable shell script that resides on disk.
The script is executed when the filesystem where it resides is detected and mounted. For that reason it must be in the last detected filesystem, e.g., sdb4, sdb2, or sda4 or the changes might be undone if latter-on a new filesystem is detected.
If you have only one filesystem, e.g., sda2 or md0, then it has to reside on that filesystem.
The script must be set executable by using the command 'chmod +x /path/to/script'.
If you want to use an Alt-F package in your script (e.g. sshd), you need to wait it to be loaded. See code below or this post for more informations. You may need to redirect the current shell environment.

Example of a shell script, e.g. /mnt/md0/fixes.sh

----------8<----- respect spaces, #!/bin/sh must be the first line ---8<-----

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh

# redirect the current shell environment to fixes.log
exec >> /var/log/fixes.log 2>&1

# change how aggressively swap is used (the default value is 60)
# A swappiness of zero means that the disk will be avoided unless
# absolutely necessary (you run out of memory),
# a swappiness of 100 means that programs will be swapped to disk almost instantly.
echo 20 > /proc/sys/vm/swappiness

# turn off swap on the sdb disk (assumes that sdb1 is the sdb swap disk partition
# check first using 'cat /proc/swaps'
swapoff /dev/sdb1

# create ssh keys for the root user (contributed by John-Paul)
mkdir /root/.ssh
chmod 700 /root/.ssh
cp /mnt/sda2/authorized_keys /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys

# Waiting for Alt-F packages to be available (e.g. sshd)
echo -n "Waiting for Alt-F packages to be available:"
while ! aufs.sh -s >& /dev/null; do
    echo -n '.'
    sleep 1
done
echo OK
/usr/sbin/sshd

---------->8---------------

Make changes to Alt-F scripts survive reboots

This is an advanced topic that might cause more distress than benefice

When an Alt-F package is installed, a directory named Alt-F will be created on the root of the filesystem of your choice, e.g. /mnt/sda2/Alt-F, and a link to it will be created in the root, /Alt-F.
The package files will reside in that directory and will shadow any file in the normal root filesystem. I.e, if a file named /Alt-F/usr/sbin/loadsave_settings exists in that directory, it will shadow, i.e. override, the firmware distributed /usr/sbin/loadsave_settings file.

So you can fix or customize Alt-F by putting any file there.

BUT THERE ARE RULES ON HOWTO TO DO IT, OTHERWISE THE SYSTEM MIGHT CRASH.

  1. Start by installing an Alt-F package, the ipkg package will be enough.
  2. At the command line type 'aufs.sh -n' # mount aufs with fsnotify
  3. Add or change the file of your choice to the /Alt-F hierarchy
  4. At the command line type 'aufs.sh -r' # remount aufs with 'reval'

The new file will appear under the usual / (root) hierarchy, as if it belongs to the normal firmware, and if it has the same name as one of the firmware files, it will override it.

As an example, a bug has been reported for 0.1B5: the /usr/sbin/loadsave_settings file missed to save /etc/exports in flash. The issue is already fixed for 0.1B6, but users don't have to wait until it is release, they can fix the issue it right now:

  1. aufs.sh -n
  2. mkdir -p /Alt-F/usr/sbin
  3. cp /usr/sbin/loadsave_settings /Alt-F/usr/sbin/loadsave_settings
  4. edit /Alt-F/usr/sbin/loadsave_settings and fix the error
  5. aufs.sh -r

That's it! From now on, whenever the loadsave_settings script is executed the fixed on-disk version is used. Of course this only happens after the filesystem where the Alt-F directory exists is detected and mounted.

DON'T, BUT DON'T, add, remove or edit any file under /Alt-F (or under /mnt/sdxx/Alt-F) without executing first steps 1!

Mounting aufs with 'fsnotify' enables you to manipulates files in /Alt-F/ directly, but it has performance issues under normal work, so don't forget to remount with 'reval' as soon as your changes are made.

Problems

The existence of the /Alt-F directory has some undesirable and not obvious effects that turns me nuts from time to time -- removing this facility has been seriously considered more than once.

The most notorious problem is that new files created in a directory which is being shadowed in disk, will be created on disk. Changing files in the shadowed directory, depending on the way they are saved, might end-up moving them to disk. Deleting a shadowed file seems to delete it, but only marks it for deletion, and it might reappear latter after a reboot while aufs is not yet mounted.

Because of this and other behavior, all setting files are copied to disk when aufs is mounted and copied back to memory when aufs is unmounted.

Also, there might exist problems with disk spindown, because some server process update files while they run, and if the updated files are being shadowed the disk will be spin-up.

Hope this help more that create problems!

Don't send bug reports or fill any issues if you made changes to any system file this way!

See http://lwn.net/Articles/324291/, http://lwn.net/Articles/325369/, http://lwn.net/Articles/327738/ for further detail.