Archive for February, 2011

Diskless Debian GNU/kFreeBSD HOWTO

February 4, 2011

It was completely non-obvious; In some cases I had to figure it out by reading kFreeBSD source code; I write it down here so it’s not forgotten ;-)

This is a short guide on how to boot Debian GNU/kFreeBSD via network on a diskless machine, using GRUB as the bootloader.

  • Step 1: Configure your DHCP/TFTP environment to load GRUB from network. See the PXE GRUB documentation for details.
  • Step 2: Rebuild kfreebsd-8 package with BOOTP and BOOTP_NFSROOT options, as described in upstream handbook. They need to be added to the debian/arch/*/*.config file for your architecture. This kernel can still be used for normal, disk-based boot, but it will issue DHCP requests to attempt network boot every time you start it.
  • Step 3: Put your kFreeBSD in TFTP directory and configure GRUB to load it. This requires only one command in grub.cfg. My setup:

    set timeout=1
    set default=0

    menuentry “Debian GNU/kFreeBSD” {
    echo Loading kFreeBSD …
    kfreebsd /beastie/boot/kfreebsd-8.1-1-amd64.gz
    echo Booting …
    boot
    }

  • Step 4: Build a directory tree with your GNU/kFreeBSD userland, and export it via NFS. I copied it from an existing Debian GNU/kFreeBSD install, but I suppose debootstrap could do the job as well.
  • Step 5: kFreeBSD mounts root NFS in readonly mode initially, and Debian userland turns out to be very unhappy with that. If you want things to work you’ll need to either setup tmpfs in a few places (e.g. /tmp) or adjust fstab so that / is remounted as writable by the INIT scripts. Example fstab line:

    192.168.1.3:/srv/netboot/beastie / nfs rw 0 0

    This, however, will only work if mount_nfs(8) is in your system. And (well, too bad) it hasn’t been packaged yet. So you can copy it from a FreeBSD base tarball, along with its dependencies (/lib/libc.so.7, /libexec and /etc/netconfig).

  • Step 6: Finally the system boots, but you’ll soon notice that file locks don’t work. This breaks some daemons (rsyslog), dpkg, apt and possibly a lot other things. Actual (i.e. non-local) file locking on NFS requires a running lock daemon, both on client and on server. However, since FreeBSD lockd isn’t packaged either, and you probably don’t need global locks anyway, I suggest you disable it with “nolockd” mount option.
    The tricky part is that as explained in mount_nfs manpage, nolockd will only be honored when performing the initial mount, and it will be silently ignored if used while updating the mount options. So fstab is not an option.
    The only way I could find of telling the kernel to use arbitrary options when mounting / is by sending them via DHCP. Use the following options in your dhcpd.conf:

    option option-130 code 130 = text;
    option option-130 “nolockd”;

  • Et voilĂ . A Debian GNU/kFreeBSD system running completely in diskless mode. Enjoy!