I am a user of Voyage Linux, a lightweight Debian flavour designed for integrated and low-powered computers. I use it with an ALIX 3D3 board which uses a Compact Flash card for it’s main storage. One of Voyage’s features that makes it ideal is that it operates with a read-only filesystem (a good idea if using a CF card). This introduces some interesting challenges; what about logs? what about home directories and command history?
Well Voyage attempts to resolve the first of these questions by mounting ⁄var⁄log as a tmpfs volume, which works ok but obviously useless if you restart or the box crashes. By default, home directories are stored on the main disk which makes them read-only; so no bash history and no meta files from applications such as vim or ssh. I also noticed sudo was outputting some warnings whenever I sudo’d and refused to remember that I had recently authenticated. Fixing these things are not very difficult, but I hope this helps someone out who has similar issues. Here is what I did.
First of all…
As Voyage mounts the root file system as read-only, it need to be remounted as writable in order to modify the system. Luckily there is a helpful script provided, so I just:
Now home directories
The obvious solution here is to mount an external drive (I used a USB pen drive, though I plan to use a NAS eventually). First I mounted the USB drive and made copies of my users’ home directories. Then I added the following line to ⁄etc⁄fstab
⁄dev⁄sda1 ⁄home ext2 defaults,noatime,rw 0 0
I then unmounted the pen drive and tested the config:
umount ⁄dev⁄sda1 mount -a df
The first command will unmount, the second will trigger parsing the ⁄etc⁄fstab file and report any errors and the last lists all mounted volumes which included this line:
⁄dev⁄sda1 3851656 73928 3582072 3% ⁄home
After a quick check that users could still read ⁄ write to their home directories I was good to go…. except for one thing. I use SSH keys, which shouldn’t be left on a USB pen drive. So I put them somewhere appropriate on the main disk and made symlinks back to them from ~⁄.ssh/id_rsa.
Next to fix the logs
Using the same USB volume I created a .log directory. I used the dot to prevent confusion with user home directories. I then copied all log files to it and created a symlink:
cp -r ⁄var⁄log⁄* ⁄home⁄.log ln -sf ⁄home⁄.log ⁄var⁄log
Whenever I sudo’d I was getting this mesage:
sudo: Can't open ⁄var⁄lib⁄sudo⁄user⁄0: Read-only file system
Sudo keeps information about a users authenticated state. I don’t really need this if I reboot, so I simply created a 1M tmpfs volume mounted on /var/lib/sudo by adding this line in the ⁄etc⁄fstab file:
tmpfs ⁄var⁄lib⁄sudo tmpfs defaults,size=1M,mode=0700 0 0
Note the mode setting, this is important or sudo will keep complaining. Testing the mount again gave me this line:
tmpfs 1024 0 1024 0% ⁄var⁄lib⁄sudo
After this sudo worked normally.
Now that I had these things in place and everything running smoothly, there was just one bit of tidying required:
That remounted the root file system as read-only again and I was done.