I’ve been playing around with OpenBSD 3.7 and my WRAP. I wanted to do a normal, full install and not a stripped down version. If you are looking for this, check out OpenSoekris or Flashdist. This writing should also apply to Soekris boxes with CF cards.
I had some problems installing OpenBSD on my 512MB CompactFlash card because the
BIOS of the
WRAP detected other hard drive geometries than the
BIOS of two PCs that I used for installation.
In order to install OpenBSD on the CompactFlash card I plugged the card with a card reader to a PC and booted the OpenBSD installation media. I choose to install on the sd0 disk (da0 on FreeBSD). So far so good. Now comes the tricky part. I had to edit the drive settings in disklabel with the “e” command in order to set the cylinders/heads/sectors to the numbers that the WRAP BIOS saw. You have only to do this if the geometry that the WRAP reports is different from the geometry that the PC reports. After this hurdle, the rest is easy.
When prompted if one want to redirect to serial console or com0 enter yes and choose a baud rate of 38400. The installed will then insert these lines in /etc/boot.config:
stty com0 38400
set tty com0
When you are finished with the installation you get a shell. Check that the boot.config settings are present:
# cat /mnt/etc/boot.config
If they are not present insert them:
# echo “stty com0 38400” > /mnt/etc/boot.config
Next you have to edit the fstab because the installer used sd0 as the CF device but the WRAP will use wd0:
# echo ”/dev/wd0a / ffs rw 1 1” > /mnt/etc/fstab
You one can halt the machine, get the CF card from the card reader and insert it into the WRAP. Before you boot the WRAP, connect to its serial console from another computer.
On OpenBSD do:
# tip -38400 tty00
On FreeBSD the device is sio0. When you boot the WRAP you should see the BIOS and boot screen over the serial console. Until I got the geometry problem solved I only saw an error stating: No O/S. In this case check the shown C/H/S values with those you use during install.
Hopefully OpenBSD will boot normally and from now we’ve got a “normal” OpenBSD PC.
But there are some issues left. CF cards are not made for many read-write cycles and a normal install will harm your CF card over time. So lets fix that. First one could mount the root filesystem noatime. This means than the inode is not updated on reads which will save write cycles.
# echo ”/dev/wd0a / ffs rw,noatime 1 1” > /etc/fstab
The best would be if one could mount root read-only but some directories like /tmp or /var have to be read-write. So will use a memory based filesystem for /tmp. This ensures that it is writable and that no read or write operations will touch the CF card for /tmp. Be sure to use ”>>” instead of ”>” or the content of /etc/fstab will be lost.
# echo “swap /tmp mfs rw,nodev,nosuid,noexec 0 0” >> /etc/fstab
This does not solve the problem with /var because /tmp holds only temporary data and /var contains some directories and files that should be present on boot or normal operation. The solution is to use a memory based filesystem but populate it with a copied /var directory on creation.
# mkdir /proto
# cp -rp /var /proto/var
# echo “swap /var mfs rw,-P=/proto/var,noexec,nosuid,nodev 0 0” >> /etc/fstab
The last thing left is /dev. Again we need a memory based filesystem populated with the content of the former /dev but we cannot just copy /dev. In /dev device nodes reside so we have to create them with the MAKEDEV script.
# mkdir /proto/dev
# cp /dev/MAKEDEV /proto/dev
# cd /proto/dev && ./MAKEDEV all
# echo “swap /dev mfs rw,-P=/proto/dev,-s=1200,-i=128,noexec,nosuid 0 0” >> /etc/fstab
Now the root filesystem can be mounted read-only. The resulting /etc/fstab should look like this:
# more /etc/fstab
/dev/wd0a / ffs ro 1 1
swap /tmp mfs rw,nodev,nosuid,noexec 0 0
swap /var mfs rw,-P=/proto/var,noexec,nosuid,nodev 0 0
swap /dev mfs rw,-P=/proto/dev,-s=1200,-i=128,noexec,nosuid 0 0
Reboot the WRAP. OpenBSD should now use the CF card only for reading and use memory for writing. Whenever you want to change something on the CF like for editing a file in /etc, just remount / read-write, make your change and remount / read-only.
Remind you that using memory based filesystem has the disadvantage that nothing survives a reboot. Make sure to log to a logging host over the network if you want to keep logs or other information.
Thanks to Derick Siddoway for help on some issues.
UPDATE:
Check out the follow-up article.