How to install NetBSD on Compact Flash (for the Soekris 4501)

This was tested on NetBSD 3.99.16, however the instructions should apply to older (and newer) versions as well. I have attempted to flag steps where you may run into version incompatabilities with “Version Note”.

There are a number of devices that will allow you to read your CF card on a NetBSD machine, the device I chose was the mediaGear Keychain Compact Flash Reader.

A snippet of your dmesg output should appear as follows:

  [...]
  umass0 at uhub1 port 1 configuration 1 interface 0
  umass0: mediaGear Compact Flash Keychain, rev 1.10/1.00, addr 2
  umass0: using SCSI over Bulk-Only
  scsibus0 at umass0: 2 targets, 1 lun per target
  sd0 at scsibus0 target 0 lun 0: <MG, CF-Key, 1.00> disk removable
  sd0: fabricating a geometry
  sd0: 244 MB, 244 cyl, 64 head, 32 sec, 512 bytes/sect x 500400 sectors
  [...]

Run the following commands:

  # cd /root
  # mkdir cfimage
  # dd if=/dev/zero of=netbsd.img bs=512 count=500400
  # vnconfig vnd0 netbsd.img
  # fdisk -ua0 vnd0
  # disklabel -e -I vnd0
  # newfs /dev/rvnd0a
  # mount /dev/vnd0a /root/cfimage
  # cd /root/cfimage && mtree -Udef /etc/mtree/NetBSD.dist
  # tar xzpf i386/binary/sets/base.tgz
  # tar xzpf i386/binary/sets/kern-GENERIC.tgz
  # cp i386/binary/sets/etc.tgz /root/cfimage/root

  # chroot /root/cfimage /bin/sh

You are in the chroot environment, continue with

Version Note: Older versions of etcupdate do not accept a tgz file an argument, you will need to extract the contents prior to running it.

  # etcupdate -s /root/etc.tgz
  # rm /root/etc.tgz
  # touch /etc/mail/local-host-names

 
Add a non-root user and his group.

  # groupadd jdoe
  # useradd -g jdoe -G wheel -k /etc/skel -s /bin/csh -m jdoe

 
Note: included in wheel group to allow user to run su.

Other files you will likely need to modify are…

  /etc/fstab
  /etc/ifconfig.sip0
  /etc/localtime
  /etc/mygate
  /etc/mygate6
  /etc/myname
  /etc/rc.conf
  /etc/resolv.conf
  /etc/ttys

 
To exit your chroot environment simply

  # exit

 
Now you will need to make the CF bootable. First we begin by copying the secodary bootstrap, followed be installing the primary.
Note: You can’t install the primary bootstrap on a mounted device, do not forget the umount step
Note #2: The baud rate you pass to installboot should match what you’ve configured in the Soekris bios.
Note #3: If you chose to use a different filesystem for primary bootstrap partition, /usr/mdec/bootxx_ffsv1 sould be changed to reflect that.

  # cp /usr/mdec/boot .
  # cd ~ && umount /root/cfimage
  # installboot -v -o console=com0,speed=19200 /dev/rvnd0a /usr/mdec/bootxx_ffsv1

We end by unconfiguring the vnode disk and writing it to CF.

  # vnconfig -u vnd0
  # dd if=netbsd.img of=/dev/sd0d bs=1m
This entry was posted in NetBSD, Papers, System Administration. Bookmark the permalink.

5 Responses to How to install NetBSD on Compact Flash (for the Soekris 4501)

  1. So, if you have an existing running NetBSD/i386 machine that can give you RW access to a CF card, which is pretty much true for any machine with USB so far as I can see, then why not just use “sysinst” to install to the CF card?

    That’s what I did — it works perfectly!

    (The only pain is that you’ll have to run sysinst from your build.sh $DESTDIR, which might be an even worse pain if your build host isn’t running the same release as what you’ve built to install on the CF card…. As part of the fix for this issue I used to patch the install to copy sysinst to the installed system, and perhaps it should always be installed in /sbin.)

  2. from says:

    you can install primary bootstrap on mounted device.
    you simply prefix the device name with “r” to indicate the raw device, e.g. /dev/rsd0a

    also, i don’t understand why you are using 3 steps: dd, vnconfig and newfs (not to mention the chroot step) when all this could be done in one step with makefs. maybe i’m missing something obvious.

    the disklabel can be generated from your dmesg output and resulting img size with some simple CHS maths, then saved to a proto file and applied non-interactively. there’s no need to go through the awkward and slow “disklabel -I” process.

  3. Pingback: ScannerPrincess » Blog Archive » NetBSD on an alix2d2

  4. David says:

    Hello,

    For the fdisk / disklabel command, we just must add a 44BSD partition and NetBSD type ? I followed a OpenBSD tutorial which says many thing like sectors/cylinders, cylinders, total sectors. Do we need to changes them too ?

  5. Jeb says:

    newfs /dev/vnd0a <– You should use newfs /dev/rvnd0a instead or you may get an “open for write: Device busy” error message

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>