Actually getting the system onto CompactFlash can be a bit difficult. Each brand of Compact Flash card may have a different disk geometry, and some cards are reported as not working at all. Many details are available on the soekris-tech mailing list.
The following steps are derived from the very helpful flashdist by Chris Cappuccio which is used by OpenSoekris to create a disk image. Those scripts automate the manual process described here. Flashing the Compact Flash card with a disk image will spread the writes out, one per sector, which may be beneficial to the lifetime of the flash.
CF cards emulate ATA disk drives and so emulate a certain drive geometry as well. Different size cards, ones from different vendors, and even an apparently identical card that was made in a different batch, may all have differing geometries. The easiest way to figure out the proper geometry is to install the Compact Flash card into the net4521 and see what it reports to disklabel.
For a SanDisk 128MB card:
# disklabel wd0 ... bytes/sector: 512 sectors/track: 32 tracks/cylinder: 8 sectors/cylinder: 256 cylinders: 978 total sectors: 250368 ...
These numbers will be used later when running fdisk, disklabel, and biosboot.
vnconfig allows a file containing a disk image to to be mounted as a virtual disk. The first step in creating a disk image is to create an empty file the exact size of the image. This file is created by using dd if=/dev/zero of=image bs=bytes/sector count=sectors:
# dd if=/dev/zero of=disk.image bs=512 count=250368
The image can then be mounted as a virtual disk
# vnconfig -c svnd0 disk.image
Once a disk image is created a BSD disklabel must be installed on the virtual disk. The disk setup process is well documented in OpenBSD's installation guide. Using disklabel two partitions will be created: a large parition for the root filesystem and a small, one block, swap partition which is necessary for the memory file system even though it isn't used as swap.
The first step is to modify the device parameters to match what was reported by disklabel on the net4521. New values are in blue:
# disklabel -E svnd0 ... > e Changing device parameters for /dev/rvnd0c: disk type: [SCSI] ESDI label name: [fictitious] net4521 sectors/track: [100] 32 tracks/cylinder: [1] 8 sectors/cylinder: [100] 256 number of cylinders: [2503] 978 total sectors: [250368] rpm: [3600] interleave: [1]
Next the root and swap partitions are created. Note that the first partition is placed after the first sector to leave room for the MBR:
> a a offset: [0] 32 size: [250336] 250335 FS type: [4.2BSD] > a b offset: [250367] size: [1] FS type: [swap] > p ... # size offset fstype [fsize bsize cpg] a: 250335 32 4.2BSD 1024 8192 16 # (Cyl. 0*- 977*) b: 1 250367 swap # (Cyl. 977*- 977) c: 250368 0 unused 0 0 # (Cyl. 0 - 977) > q Write new label?: [y] y
Next up is creating a filesystem on the disk image. This is accomplished using newfs -S bytes/sector -u sectors/track -z tracks/cylinder -q raw-device.
# newfs -S 512 -u 32 -z 8 -q /dev/rsvnd0a
Then the partition table is updated with fdisk -c cylinders -h heads -s sectors/track -f master-boot-record -e device:
# fdisk -c 978 -h 8 -s 32 -f /usr/mdec/mbr -e svnd0 fdisk: 1> reinit fdisk: 1> update fdisk: 1> print Disk: wd0 geometry: 978/8/32 [250368 Sectors] Offset: 0 Signature: 0xAA55 Starting Ending LBA Info: #: id C H S - C H S [ start: size ] ------------------------------------------------------------------------ 0: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused 1: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused 2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused *3: A6 0 1 1 - 977 7 32 [ 32: 250336 ] OpenBSD fdisk: 1> write fdisk: 1> quit
At last the new virtual disk can be mounted and OpenBSD can be installed! The second stage boot loader and kernel will be copied first, then the first stage boot loader will be installed followed by the rest of the system. The NET4521 kernel should be compiled and ready at this stage.
# mount /dev/svnd0a /mnt/net4521 # cp /usr/mdec/boot /mnt/net4521/ # cp /usr/src/sys/arch/i386/compile/NET4521/bsd /mnt/net4521/
Install the boot loaders using installboot stage-2-loader stage-1-loader device
# /usr/mdec/installboot /mnt/net4521/boot /usr/mdec/biosboot svnd0
Extract the OpenBSD system tar, umount the filesystem, and discard the virtual drive
# tar xpvf openbsd.tar -C /mnt/net4521 # umount /mnt/net4521 # vnconfig -u svnd0
The very last step in the process is flashing the newly created image onto the compact flash card. I used an ATA PCMCIA/PC Card adapter which simply allows to access the CF as a PCMCIA device. Using a USB or other adapter may not work. Assuming that the card shows up as wd1, dd is again used to place the image on the card:
# dd if=disk.image of=/dev/rwd1c bs=512
Thats it! Place the card back into the net4521 and the boot loader should load the new installation. The following dmesg is from my system:
OpenBSD 3.2-stable (NET4521) #0: Sat Jan 1 00:00:00 EST 2003 [email protected]:/usr/src/sys/arch/i386/compile/NET4521 cpu0: AMD Am486DX4 W/B or Am5x86 W/B 150 ("AuthenticAMD" 486-class) cpu0: FPU real mem = 66695168 (65132K) avail mem = 60063744 (58656K) using 839 buffers containing 3436544 bytes (3356K) of memory mainbus0 (root) bios0 at mainbus0: AT/286+(00) BIOS, date 20/21/13, BIOS32 rev. 0 @ 0xf00c0 pcibios0 at bios0: rev. 2.0 @ 0xf0000/0x10000 pcibios0: pcibios_get_intr_routing - function not supported pcibios0: PCI IRQ Routing information unavailable. pcibios0: PCI bus #2 is the last bus bios0: ROM list: 0xc8000/0xa000 pci0 at mainbus0 bus 0: configuration mode 1 (no bios) pchb0 at pci0 dev 0 function 0 "AMD ElanSC520 Host-PCI" rev 0x00 hifn0 at pci0 dev 16 function 0 "Hifn 7951" rev 0x01: 128KB sram, irq 10 cbb0 at pci0 dev 17 function 0 "Texas Instruments PCI1420 PCI-CardBus" rev 0x00: irq 11 cbb1 at pci0 dev 17 function 1 "Texas Instruments PCI1420 PCI-CardBus" rev 0x00: irq 11 sis0 at pci0 dev 18 function 0 "NS DP83815 10/100" rev 0x00: irq 5 address 00:00:00:00:00:01 nsphyter0 at sis0 phy 0: DP83815 10/100 integrated, rev. 1 sis1 at pci0 dev 19 function 0 "NS DP83815 10/100" rev 0x00: irq 9 address 00:00:00:00:00:02 nsphyter1 at sis1 phy 0: DP83815 10/100 integrated, rev. 1 cardslot0 at cbb0 slot 0 flags 0 cardbus0 at cardslot0: bus 1 device 0 cacheline 0x10, lattimer 0x3f pcmcia0 at cardslot0 cardslot1 at cbb1 slot 1 flags 0 cardbus1 at cardslot1: bus 2 device 0 cacheline 0x10, lattimer 0x3f pcmcia1 at cardslot1 isa0 at mainbus0 isadma0 at isa0 wdc0 at isa0 port 0x1f0/8 irq 14 wd0 at wdc0 channel 0 drive 0: <SanDisk SDCFB-128> wd0: 1-sector PIO, LBA, 122MB, 978 cyl, 8 head, 32 sec, 250368 sectors wd0(wdc0:0:0): using BIOS timings npx0 at isa0 port 0xf0/16: using exception 16 pccom0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo pccom0: console pccom1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo biomask 4800 netmask 4e20 ttymask 4e20 dkcsum: wd0 matched BIOS disk 80 root on wd0a rootdev=0x0 rrootdev=0x300 rawdev=0x302 wi0 at pcmcia1 function 0 "INTERSIL, HFA384x/IEEE, Version 01.02" port 0xa000/64 wi0: PRISM 2.5 ISL3873, Firmware 1.1.0 (primary), 1.4.9 (station), address 00:00:00:00:00:02