I found it. Do I get a prize?
03 Jun 2003So I was trying to set up a diskless boot system on FreeBSD at work last week for The Thing. I'd found this article on booting FreeBSD with PXE, and it was nearly all I needed...except that this was about installation, and what I needed was a working system.
So I started fooling with it and trying to figure out how to add things like individual swap files and configuration information -- The Thing is going to have up to ten or so computers booting disklessly -- and then I came across a passing reference to /etc/rc.diskless1 and /etc/rc.diskless2. Bless their pants, the good folks at FreeBSD had already come up with a way of doing all this, and pretty much all I had to do was read those two scripts and /usr/share/examples/diskless/clone_root.
I got the hang of it pretty quickly and (mostly -- I have a habit of not following each and every instruction every single time, which is why Automation Rox) got it working...sort of. Something was going wrong and I couldn't figure out what it was.
See, what happens is you create, on the server, /disklessroot, which has a copy of almost everything the diskless unit is meant to use for a filesystem. /var is a memory filesystem (MFS) populated on boot with canonical files (see /etc/mtree), and /tmp is a symlink to /var/tmp. /etc, in turn, is filled with files specified in /conf on the server: you can set a default, then add stuff specific to particular hosts specified by IP address. And if a file called disklessremount is around in the right place, /etc will be filled first with the base files you'd expect, then overlaid with the stuff in the default section, then the host-specific stuff.
Only that last part wasn't happening. Somehow it'd get to the part where it was meant to copy the base files, then all these errors would pop up. I was convinced I was doing something wrong, but I couldn't figure out what. So, single-user then sh -x /etc/rc.diskless1 2>&1 | less. (God, I love the -x flag for sh/bash. Lovelovelove.) I print out the scripts so I can follow along. I follow along.
And I found a bug!
At one point it checks to see if the diskless_remount file is around; if it is, it creates the MFS, then proceeds to fill it. It uses eval a couple times in its checks, which always throws me; I've never been clear on what eval is for. But I muddled through it, then realized there needed to be a second slash on one line. Without it the MFS creation subroutine doesn't get the proper arguments.
Okay, no big deal; it's not like I found a ticking time bomb in the centre of the earth and had to alert everyone within 24 hours. But I was happy I was able to recognise it. I was all prepared to send in a PR when I found this one. Welp, there goes fame and fortune. :-)
In other news, it looks like FreeBSD does not like USB keyboards; we've got we're using for The Thing, where the PS/2 socket is inaccessible, but FreeBSD immediately panics and dumps registers when it finds it or when we plug it in. I'm going to see about maybe getting a core dump from it using Michael Lucas' excellent instructions.
Add a comment:
Name and email required; email is not displayed.
Related Posts
QRP weekend 08 Oct 2018
Open Source Cubesat Workshop 2018 03 Oct 2018
mpd crash? try removing files in /var/lib/mpd/ 11 Aug 2018