[buug] different runlevel with a headless box

Ian Zimmerman itz at madbat.mine.nu
Sun Oct 21 20:54:05 PDT 2007

Ian> Can anyone think of a way to do this?  I don't mean "how to create
Ian> a runlevel to make a box headless", rather how to have two
Ian> different runlevels on a box that is already headless and choose
Ian> between them when booting.  I am thinking along the lines of
Ian> attaching some sort of dongle (USB pen drive maybe), but how to
Ian> make grub (or later init) react to that?

Brian> I can't find it in the docs right now, but I seem to recall that
Brian> you can specify a desired runlevel to init with a single digit in
Brian> the kernel command line, eg:

Brian> title Foobar GNU/Linux, kernel x.y.z-foo (headless) kernel
Brian> /vmlinuz-x.y.z-foo root=/dev/<whatever> ro 2

Brian> title Foobar GNU/Linux, kernel x.y.z-foo (X11) kernel
Brian> /vmlinuz-x.y.z-foo root=/dev/<whatever> ro 5

Brian> Failing that, according to inittab(5) if there is no runlevel
Brian> marked initdefault, then init will prompt on the console for a
Brian> runlevel at boot time.

"headless" == "no console"

I finally followed this suggestion by Michael:

Michael> as part of "headless" runlevel initialization, check for a
Michael> console keyboard (e.g. USB keyboard or PS/2 or AT type
Michael> keyboard) - if one is found, change to the non-headless
Michael> runlevel (this can presumably be checked via an rc script)

except that instead of connecting (and checking for) a keyboard, I check
for an inserted floppy :-) Actually I don't have the floppy yet, I have
thrown out all of mine so a friend has to pinch one for me at her work
:-) But I am confident that it will work, I have tested the runlevel
switch case already.  And a floppy is more convenient than a pen drive
because this stupid Dell box doesn't have USB ports in front.

Background: the box is just a compile server for distcc(1), so like
servers it doesn't have a monitor or keyboard attached, but unlike
servers it's not up all the time.  When I back it up with
rdiff-backup(1) I don't want distcc or other services to run
(cron/anacron would be especially nasty), but I still need sshd, hence
the need for an intermediate runlevel.

This line is completely ham.

More information about the buug mailing list