Remote controling computers, one step further

Problem: remote controling of a diskless, headless computer.

Background, context, limitations: I have a computer which I want to use as a sound recorder. It has no hard disk, but a network card and a sound card. I would like it to record sound with the sound card and save the sound data (the .wav file) on a nfs-server in my home network. It would be nice if I could plug in a keyboard and use it to start and stop recordings, and possibly get some more choices, as playing the previously recorded sound while recording the new one.

Plan: install less-disks on a server in the network, install a ssh-server in the less-disks installation, make the headless, diskless computer boot from the network (with etherboot-floppies), log in to the terminal set up sound (alsa and ecasound). Make some hacks in the boot scripts in order to mount the nfs-server for the sound-files and start ecasound at boot.

Optionally hack the installation to accept input to ecasound from the keyboard of the terminal. In one sense of the word remote-control, controling the terminal from the local keyboard is not remote-controling, but we can also define the keyboard as part of the system that we remotely control how it should (re)act.

Bonus points for never hooking up a monitor to the terminal :-) (As it happened, I had to hook up a monitor and a keyboard to get it to boot at all, since bios required that the user acknowledged some hardware changes (changed amount of RAM). But apart from that, that keyboard and monitor was not necessary).

Here follows a step by step instruction on how to do this with Sarge release of Debian. One might use this as a general manual on installing less-disks. While I love less-disks, it does not work out of the box and it is being deprecated by its main developer (Vagrant Cascadian), who is said to work on integrating LTSP 5.0 into Debian instead. Anyhow, here's my guide get less-disks up and running.

1. Install less-disks

# apt-get install less-disks less-disks-terminal
# lessdisks-install

Choosing the defaults at the debconf prompts.

2. Install ssh into the less-disks system.

# lessdisks-aptget install ssh

3. Configure NFS to export /var/lib/lessdisks

Add the following to /etc/exports

###### Start of snippet to add to /etc/exports ########

# this is the only entry needed for lessdisks
# change the ip address and lessdisks directory if needed

/var/lib/lessdisks 192.168.1.0/255.255.255.0(ro,no_root_squash,async)

###### End of snippet to add to /etc/exports ########

4. Configure the dhcp3-server.

# cp /usr/share/doc/lessdisks/examples/dhcpd.conf /etc/dhcp3/dhcpd.conf

I had to replace "192.168.1" with "192.168.0" in this file, because my home LAN has that address range.

Change the "filename" line to the following:

filename "/var/lib/lessdisks/boot/pxelinux.0"

Start the dhcp server.

# /etc/init.d/dhcp3-server start

5. Configure the tftp server (tftpd-hpa). (Install it if you haven't already).

Create a symbolic link to pxelinux.0, which is in provided by the syslinux package. (DOES THIS REALLY WORK? If not, then copy the real file instead)

# ln -s /usr/lib/syslinux/pxelinux.0 /var/lib/lessdisks/boot/
or
# mkdir /var/lib/lessdisks/boot/pxelinux.cfg
# cp /usr/share/doc/lessdisks-doc/pxe/default /var/lib/lessdisks/boot/pxelinux.cfg/
Make tftpd-hpa look for files in the right place. By default tftpd-hpa runs from inetd, so the file to change is /etc/inetd.conf
#tftp           dgram   udp     wait    root  /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot
tftp           dgram   udp     wait    root  /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/lessdisks/boot
Reload configuration of inetd.
# /etc/init.d/inetd reload

6. Hack the config file of pxe

The file /usr/share/doc/lessdisks-doc/pxe/default does not work out of the box. You have to add "ip=dhcp", remove no_root_squash and add nolock, see below.

        append rw root=/dev/nfs initrd=initrd.img ip=dhcp nfsroot=192.168.0.252:/var/lib/lessdisks:ro,nolock
#        append rw root=/dev/nfs initrd=initrd.img nfsroot=/var/lib/lessdisks:defaults,ro,no_root_squash

7. Add a root password

# lessdisks-chroot passwd

8. Add the needed nic-drivers to the initrd (only needed for some nics)

The terminal that I used as a testbed (my pxe-bootable laptop) had a natsemi nic, but the kernel module for natsemi was not included in the initrd by default. To add it (and remove some nic drivers that I know I don't have in any computer) edit:

/var/lib/lessdisks/etc/lessdisks/mkinitrd/initrd-netboot.conf

# network card modules requested
#nic_modules="ne 3c509 3c59x 8139cp 8139too dmfe e100 eepro100 eexpress epic100 hp100 ne2k-pci sis900 tlan de4x5 tulip via-rhine yellowfin forcedeth"
nic_modules="8139cp 8139too tulip via-rhine natsemi"

Rebuild the initrd.

# lessdisks-chroot -- dpkg-reconfigure kernel-image-2.4.27.3

Don't worry about the warning about the "need to reboot soon".

Fix /var/lib/lessdisks/etc/network/interfaces

there were two loopback entries. Remove one of them.

auto lo
iface lo inet loopback
auto lo
iface lo inet loopback

This should make the terminal boot and get into runlevel 2 (the default runlevel in Debian). Looking in the syslog of the server, you can see what IP the terminal got, and ssh into it. My terminal got 192.168.0.239 and I can log into it with:

$ ssh root@192.168.0.239

While ssh access makes it convenient to configure the box (e.g. to set the mixer settings and to see that hardware modules are loaded correctly), / is mounted read-only. Persistent changes is made with lessdisks-chroot, or for terminal specific settings with files in /var/lib/lessdisks/etc/lessdisks.

The system for customizing a terminal uses two steps:

1. map the terminal to a specific hostname by its mac-address 2. look for a file with the same name as the hostname in /var/lib/lessdisks/etc/lessdisks/terminals, if such a file is found parse it according to a some special rules. 3. do whatever the rules gives (e.g. load modules, run scripts).

comments powered by Disqus


Back to the index

Blog roll

R-bloggers, Debian Weekly
Valid XHTML 1.0 Strict [Valid RSS] Valid CSS! Emacs Muse Last modified: 2006-12-16