Baton is our little Mini-ITX-Computer which was originally intended to use for the laboratory Das Eingebettete Orchester. It only has a 1GB flash disk for its OS and programs. To protect the flash disk from crashing, we made it read-only. Therefore, Baton uses a unionfs for the root file system, making it writable, but like in Knoppix all changes are only made to the RAM.

This Howto describes how to install or remove packages on the read-only system. If you just want to change or add several new files, please read Baton - Change files . If you have to build packages from source files, please read that Important Note at the end first.

Backup files

Because you need to reboot to install new packages, you have to backup files which were added or changed on the unionfs if you want to use them again in the future. Please ensure to do that before continuing, because all changes on the system were only made to the RAM and are definitively lost after rebooting!

There are two ways to backup files. One is to make them static on the flash disk (only recommended for files which will be often used in the future) and the other is to save them on another drive.

Backup files to another disk

This is as easy as it seems. You just have to mount an external drive e.g. via USB as root and copy the files you need. Don't forget to unmount after doing so!

baton:~# mount /dev/sda1 /mnt/usb/ baton:~# cp -a <sources> /mnt/usb/<destination> baton:~# umount /mnt/usb/ baton:~#

The -a flag is optional. It's to ensure that files are copied recursively (for directories) without changing permissions and following links.

Write files to the flash disk

Read Baton - Change files to do so, but please do not write any files to the flash disk, if you will not use them in the future!

The Mirror

The whole OS is mirrored on an external hard disk with an USB interface. There are two mirrors, one small mirror which should exactly reflect the containment of the flash disk, and one big mirror which should have all files from the small system, but with additional tools etc.

There are different ways to get new packages to the flash disk. One easy way is described in the following.

Booting a mirror

You have to plug in the USB drive containing the mirrors and reboot the system. In the boot menu of grub select Debian GNU/Linux, kernel 2.6.xx, full, rw, USB. Then login as root.

In /mnt/system2 the small system and in /mnt/flash the system from the flash disk are already mounted. Attention! The flash is mounted read-write already! So don't do any unnecessary changes here!

Please note that for all important changes you want to make on the flash system it is recommended to apply these changes on the mirror systems, too!

Installing/Removing packages via apt-get/aptitude

The first is to make your changes to the system you have already booted. This can be done like for any other system, too. The second is to make your changes to the small system. Now, we have to change the root filesystem to /mnt/system2. This can be done by starting a little script:

baton:~# ~/chroot2small Copying network information ... Mounting /proc ... Mounting /dev ... Chroot to small system ... baton:/#

To remind you that you are in the chroot environment it is meaningful to type the next command.

baton:/# export PS1="(chroot) $PS1" (chroot) baton:/#

Now you can install or remove packages like in any other system again. To leave the chroot environment, simply type:

(chroot) baton:/# exit exit baton:~#

Try out new packages after a reboot before you write the changes to the flash disk! You will have to choose Debian GNU/Linux, kernel 2.6.xx, small, ro, USB in the grub boot menu then. The small system is an exact mirror of the flash disk and is booted read-only, too. If the new packages work reboot the big system again and apply the changes to the flash disk, like described in the following.

To make changes to the flash disk there are two simple ways. The first way is recommended, if you're not going to do too many changes. The second way should be done, if there are very many changes to be done.

The first way behaves like applying changes to the small system, just chroot to the flash system and apply your changes. Again there is a script which can chroot for you:

baton:~# ~/chroot2flash ...

The second way is to copy the whole mirror to the flash disk:

baton:~# cp -a /mnt/system2/* /mnt/flash/

Please ensure to use the -a option. Otherwise the flash system may not work!

Build and install packages from source files

If there are no Debian packages for your desires, you have to build the package from source files. In this case, please be sure to build the binaries and libraries only(!) on the big system. The sources and temporary files would waste too many ressources on the small system and on the flash disk there would be too many writing cycles, which sinks the lifespan of the flash chip drastically. This is incidentally the reason why the whole system is read-only!

So after building the package, copy the needed to libraries and binaries to the small mirror on /mnt/system2 and try them out first (reboot) before writing them to the flash disk on /mnt/flash!

After all you just have to reboot the flash system again.

--Lwi ? 22:37, 10 November 2006 (CET)