How to netboot and install NetBSD/sparc

Preface

I've got a Sun SparcStation IPX which I want to install NetBSD on. This old machine has neither a cdrom nor an USB connector (USB was invented several years after these machines hit the market). You could hook up an external SCSI cdrom or a tape drive, but I have neither of them. Thus netbooting the installer remains the only choice. The steps described below work out for NetBSD 7.1.1, 6.0.1, 5.2, 4.0.1, and 3.1.1. My IPX has quite an old OpenBootProm (OBP, the "bios" of Sparc machines) which boots neither 4.0.1, 5.2, 6.0.1, nor 7.1.1 from disk - unless you use the second stage bootloader from NetBSD 3.1.1. Netbooting these releases works fine, though..
The installer of NetBSD (sysinst) has an option to update an already installed system. This howto describes the steps which are neccessary to netboot the installer. Following these steps you should also be able to update your system.

Requirements

Screenshot

Here's my IPX running NetBSD 7.1.1:

Steps

  1. If you downloaded the iso, mount it:
    $ sudo mount -t iso9660 -o ro,loop /path/to/NetBSD-7.1.1-sparc.iso /mnt
  2. Create a directory that will serve as tftp area:
    $ sudo mkdir /tftproot
  3. Copy boot.net to /tftproot/:
    $ sudo cp -iv /mnt/sparc/installation/netboot/boot.net /tftproot/
  4. Check whether your Sparc box has a SUN4M or a SUN4C based architecture. For this, you might visit http://www.netbsd.org/ports/sparc/. For instance, an IPX is a SUN4C while a JavaStation is a SUN4M
  5. Calculate the hexadecimal representation of your Sun's ip address, e.g. my IPX uses 192.168.0.22 which is C0A80016 in hex. You can use this command:
    printf %02X%02X%02X%02X 192 168 0 22
  6. In /tftproot, create a symlink like this:
    $ sudo ln -s boot.net C0A80016.SUN4C
    Of course you should replace that hex ip address and architecture to match yours.
  7. Start rarpd manually as there isn't an RC script for this on Gentoo:
    $ sudo rarpd -e -v -b /tftproot eth0
    Depending on your bootserver's hardware, you might replace eth0 by the appropriate interface
  8. Start atftpd:
    $ sudo /etc/init.d/atftp start
  9. Edit /etc/dhcp/dhcpd.conf. At the bare minimum it should contain something like this:
    subnet 192.168.0.0 netmask 255.255.255.0 {
      range 192.168.0.100 192.168.0.110;
    }
    host ipx {
      hardware ethernet 08:00:20:C0:FF:EE;
      fixed-address 192.168.0.22;
      next-server 192.168.0.10;
      option root-path "/data/netbsd";
    }
    
  10. Start dhcpd:
    $ sudo /etc/init.d/dhcpd start
  11. Create the directory that will serve as the netbooted kernel's root directory:
    $ mkdir /data/netbsd
  12. Copy netbsd-GENERIC.gz (the NetBSD kernel) to that directory:
    $ cp /mnt/sparc/binary/kernel/netbsd-GENERIC.gz /data/netbsd/
  13. Create a symlink called netbsd so that the network bootloader will pick up the kernel:
    $ ln -s /data/netbsd/netbsd-GENERIC.gz /data/netbsd/netbsd
  14. Extract the root filesystem (the --numeric-owner switch is important!):
    $ tar -C /data/netbsd --numeric-owner -xvzpSf /mnt/sparc/installation/netboot/rootfs.tgz
  15. Make the install sets available underneath the root directory:
    $ cp -aiv /mnt/sparc/binary/sets /data/netbsd/
  16. Export the root directory with NFS. Add to /etc/exports:
    /data/netbsd	192.168.0.22(rw,no_root_squash,no_subtree_check)
    
  17. Make sure NFS version 2 and UDP transport are enabled in /etc/nfs.conf:
    [nfsd]
    UDP=on
    vers2=on
    vers3=on
    
  18. Optionally, make nfsd log to syslog by extending the variable OPTS_RPC_NFSD in /etc/conf.d/nfs:
    OPTS_RPC_NFSD="-s -u 8"
    
  19. Start NFS:
    $ sudo /etc/init.d/nfs start
  20. Extract the second stage bootloader from NetBSD 3.1.1:
    $ tar -C /tmp -xzf /path/to/base.tgz ./usr/mdec/boot.388000
    
  21. Connect a keyboard and a monitor to your Sparc box, or use a serial connection
  22. After powering on, press Stop+A (Ctrl+A+F in minicom) to escape to the OBP prompt
  23. At the prompt, type boot net
  24. When the kernel and sysinst have been loaded, you can install NetBSD to disk
  25. During the installation, choose Local directory as source media to install from. As base directory enter /, whereas the set directory should be /sets.
  26. After installation, reboot and once again press Stop+A or Ctrl+A+F to enter the OBP. Then, type boot net as NetBSD 7.1.1 won't boot from disk due to an incompatibility between the second stage loader and the old version of the OBP
  27. Don't select (I)nstall/Upgrade, but start a (S)hell
  28. Mount the root disk you just installed NetBSD to, and chroot into it:
    # mount /dev/sd0a /targetroot
    # chroot /targetroot
    
  29. Rename the current second stage loader (/usr/mdec/boot is hardlinked to /usr/mdec/boot.388000):
    # cd /usr/mdec
    # mv boot boot.711
    # mv boot.388000 boot.388000.711
    
  30. Grap the second stage loader from NetBSD 3.1.1 you extracted on your bootserver:
    # scp user@bootserver:/tmp/usr/mdec/boot.388000 /usr/mdec/
    # ln /usr/mdec/boot.388000 /usr/mdec/boot
    
  31. Reinstall the bootloader chain:
    # cp -v /usr/mdec/boot /
    # installboot -v /dev/rsd0c /usr/mdec/bootxx /boot
    
  32. Leave the chroot environment, unmount the local disk, and reboot NetBSD 7.1.1 from disk:
    # exit
    # umount /targetroot
    # reboot
    

Generating the SSH host keys during first boot might take a long time on such old machines, though.