Installing OpenBSD on Compact Flash |
The Net4501 is a small x86 computer designed for use with FreeBSD/OpenBSD or similar. It has a PXE BIOS to facilitate diskless booting. There are three 10/100 ethernet ports and a serial port. The serial port is the console. It has a Compact Flash slot for 'disk', and a laptop style 3.3V PCI slot for expansion.
Using a Compact Flash PCMCIA adapter and a Compact Flash card, you can use a laptop to perfom the OpenBSD install onto the CF card. This can then be plugged into the Net4501.
As my old laptop didn't handle the PCMCIA/CF properly I borrowed a laptop for the install. Doing the install doesn't touch the laptop disk, so it's safe to use other peoples gear for this part.
A minimal OpenBSD 3.7 install will fit on a 128MB CF card, but only just. A 256MB card gives plenty of room, so that's the minimum I'd recommend.
Put the CF card in a PCMCIA adapter. Insert into the laptop. Boot from the OpenBSD install CD. Follow the instructions to install onto wd1 from the CD. Tell it to use the whole disk for BSD. On 128MB CF cards I use 1 partition, no swap. There's just enough room. On larger CF cards I have a small swap partition to keep OpenBSD happy. The install is pretty much as per normal OpenBSD. On a small system I use bsd, etc37.tgz, base37.tgz only. Don't configure the network, the laptop's network card (if any) isn't relevant or required. To use the serial console, when prompted by the installer, select com0 for console.
On some CF cards installboot fails because the bios couldn't figure out the geometry of the CF 'disk'. The geometry is displayed by the BSD boot message. Run installboot manually if required. This is normally only needed with older CF cards.
You can get to a shell when the install finishes, or by booting from CD and selecting 'Shell' instead of 'Install'.
To find the geometry of the CF, run 'dmesg
'. The bit you're after
is the number of heads and sectors of the CF.
Mount the CF with 'mount /dev/wd1a /mnt
',
cd to /mnt,
run installboot e.g. '/usr/mdec/installboot -v -s 32 -h 4 /mnt/boot /usr/mdec/biosboot wd1
'
There is some other cleanup work to be done.
You'll need to fix fstab so it mounts wd0 instead of wd1, otherwise when you boot up it won't mount the root partition.
cd /mnt/etc ed fstab 1s/wd1/wd0/ w q
At this stage you should have a ready to go Compact Flash. Halt the laptop, remove the CF, plug it in to the net4501, apply power.
As OpenBSD is a general purpose OS, there are a few things you might want to do to make things more suitable for running on CF. CF doesn't have unlimited write cycles, so you want to avoid continuous write activity. To this end I normally configure syslog to log to a log server rather than locally.
From a posting to the Soekris tech mailing list by Jim Razmus I got the basic idea. I've fleshed it out a little.
For a pxe boot server all you need to do is create /tftpboot on your server and put pxeboot and bsd.rd in it. Create a directory /tftpboot/etc and create a boot.conf file.
set tty com0 stty com0 9600 bsd.rd
Edit /etc/inetd.conf and uncomment the
entries for tftp and ftp. You only need the IPv4 versions. pkill -HUP inetd
to make the changes effective.
You'll also need dhcpd. You must configure it to use your server as a boot server, e.g. with my server at 192.168.2.2 a minimal /etc/dhcpd.conf would have:
subnet 192.168.2.0 netmask 255.255.255.0 { filename "pxeboot"; next-server 192.168.2.2; range 192.168.2.32 192.168.2.127; }
Also check /etc/rc.conf.local to ensure dhdcp starts using the interface you want to use. Start dhcpd.
At this point if you boot the Soekris and interrupt the boot so you can enter commands to the combios, you can get it to attempt a pxe boot with the command 'boot f0'.
If this works you'll get to the bsd boot prompt.
At this point you should get the normal install process. Use the ftp install. If you're using a user login with ftp, use the full pathname when the installer asks for the path to the install files.
/dev/wd0a root 32M /dev/wd0b swap 4M (just to stop the installer whining) /dev/wd0d var 5M /dev/wd0e usr Whatever is left
/dev/wd0a / ffs rw,noatime 0 1 /dev/wd0e /usr ffs rw,nodev,noatime 1 2 swap /tmp mfs rw,noexec,nosuid,nodev,-s=1024 0 0 swap /var mfs rw,noexec,nosuid,nodev,noauto,-P=/dev/wd0d 0 0
A 128M CF is just a little small for a base OpenBSD install. You'll need a 256M CF if you want to avoid playing games to get things installed.
The fstab sets up a root partition with noatime, which reduces disk writes. It creates a memory file system for /tmp. The final trick with /var creates a memory file system, then initialises it with the /var the installer created.
The end result is a system that works pretty much like a normal OpenBSD system but that has a minimum of disk writes, preserving your compact flash.
One annoying feature of the var in RAM trick is that you can't use dhcp to configure the interfaces. Can't write to /var/db/dhclient.leases.sis0 during the boot process.
Philip Plane philip@xinqu.net