Wait for USB

Having installed Debian GNU/Linux 5.0 (“lenny”) on a PC Engines Alix 2D3 system I ran into problems with the external USB disk drive not being mounted at boot-up.

Mounting local filesystems…mount: special device UUID=… does not exist

These error messages were coming when /etc/rcS.d/S35mountall.sh was attempting to mount all the local filesystems from /etc/fstab. In my case the USB subsystem had not yet initialised and so the entries in /dev had not been created yet.

I could simply wait until booting has finished and mount the partitions manually, or add them to /etc/rc.local, but I was after a more elegant solution.

The answer is to introduce a deliberate pause into the boot sequence to allow the USB subsystem to initialise before the mounts are started.

# Script to force boot sequence to wait for USB disk detection
# Copy to /etc/init.d/waitforusb
# ln -s /etc/init.d/waitforusb /etc/rcS.d/S25waitforusb
# Disk drive mount we're waiting on
# Max time to wait (in seconds)
case "$1" in
  echo "Waiting for USB disk drive $usbdrive"
  for (( i = 0; i <= $maxwait; i++ ))
    [ -b $usbdrive ] && exit 0
    echo -n "."
    sleep 1
  exit 1

Copy this startup file to /etc/init.d and then create a symbolic link in /etc/rcS.d just before the filesystem checks:

ln -s /etc/init.d/waitforusb /etc/rcS.d/S25waitforusb

The script will check for the disk drive entries in /dev every second and allow boot execution to continue when it’s there. There is a safety timeout which allows execution to continue regardless after 30 seconds.

Squeezebox Server on a budget

Looking for an inexpensive, quiet and low-power Squeezebox Server?

The O2 Joggler is a rebadged version of a OpenPeak OpenFrame 7″ touch-screen device. It has an Intel Atom Z520 CPU running at 1.3Ghz, 512Mb of RAM and 1GB of internal flash storage. You can also run it as a fully functioning Squeezebox Server!

Here’s how:

  • First check that your Joggler is running the latest 26635.S3 (Jun 25 2010) software, if it’s not then update
  • You will need telnet access, so download this Joggler telnet hack
  • Unpack the Zip archive to the root of a USB stick formatted in FAT16 or FAT32
  • Unplug the Joggler, insert the USB stick, then power on again and wait!
  • When the Joggler reboots it will have telnet enabled 🙂
  • Telnet to the IP address of your Joggler and login with the username ‘letmein’
  • Download Logitech’s Squeezebox Server v7.5.1 and save to your PC desktop

Now use these commands to download and install flipflip’s Squeezebox server wrapper:

cd /media
mkdir /media/ssods4 /opt
ln -s /media/ssods4 /opt/ssods4
cd /opt/ssods4
wget http://oinkzwurgl.org/downloads/ssods/ssods-4.9.1-i686.tar.gz
tar -xzvpf ssods-4.9.1-i686.tar.gz
echo "ssods:*:1000:1000:ssods:/opt/ssods4:" >> /etc/passwd
echo "ssods:*:1000:" >> /etc/group
LC_ALL= /opt/ssods4/etc/init.d/rc.ssods start

Assuming all the above has gone ok, you can now open a browser and finish the Squeezebox server installation:

  • Open a web browser on your PC and enter the URL of your Joggler, e.g.
  • Follow the instructions in SSOXX to upload the squeezeboxserver-7.5.1.tgz file you downloaded earlier and then install the SqueezeCenter tar ball
  • When it’s finished you should see Success messages like the screenshot below
  • Now just click on ‘Start SqueezeboxServer’ to fire it up

If you are going to use your Joggler as a dedicated Squeezebox Server then you might want to make the following tweaks to ensure that it all starts up automatically and unnecessary processes are disabled:

  • Edit  /etc/init.d/boot.d/S99boot.hacks and add the line ‘LC_ALL= /opt/ssods4/etc/init.d/rc.ssods start’ in the starthacks() function, just after the telnetd line should be fine (my S99boot.hacks additions are at the end of this post)
  • Go into the SSOXX settings tab and make sure that autostart is enabled
  • Stop the X11 server and O2 GUI from loading by commenting out the following two lines from the end of /etc/init.d/rcS
cd /openpeak/tango
./run &
  • Disable automatic software updating to ensure that all your good work is not undone in the future:
echo " localhost applog.openpeak.net o2.openpeak.com o2.openpeak.co.uk" > /etc/hosts

I want to keep my Joggler in a cupboard and forget all about it, so I have no use for the display.
To save power I switch the screen off entirely, to do this I use Starter’s driver patches:

cd /media
wget http://get.intanet.com/dl/brightness.sh
wget http://get.intanet.com/dl/bp
./brightness.sh allowscreenoff 1
./brightness.sh negativevalues 1

Add the following line to /etc/init.d/boot.d/S99boot.hacks:

/bin/echo "-3">/proc/blctrl"

If you want to mount a Samba/CIFS share (like a NAS mount) you will need to download the cifs.ko kernel module and add that to the startup file.

The starthacks() function in my /etc/init.d/boot.d/S99boot.hacks startup file now looks like this:

  # enable telnet
  # load CIFS kernel module
  /sbin/insmod /media/cifs.ko
  /bin/sleep 2
  # mount network share
  /bin/mount -t cifs // /mnt/music -o user=music,password=secret
  /bin/sleep 2
  # disable screen
  /bin/echo "-3">/proc/blctrl
  # start SSOXX and Squeezebox Server
  LC_ALL= /opt/ssods4/etc/init.d/rc.ssods start

Reboot your Joggler for the display driver patches to load.

Prevent SSH session timeout

When using mobile broadband I found that a SSH shell session to a remote server would terminate unless I used it every few minutes. To overcome this use the ServerAliveInterval option to send a regular keepalive message to the remote server, which should be enough for the ISP firewalls to maintain the TCP session indefinitely.

Either add the SSH option via the command line, e.g.

$ ssh -o ServerAliveInterval=60 user@host

Or add the following line to ~/.ssh/config:

ServerAliveInterval 60  # Send a keepalive every 60 seconds

Configure HomePlug devices from Mac OS and Linux

If like me you have a need to configure HomePlug Powerline devices but don’t have a Windoze PC, I found a simple tool written by Manuel Kasper that compiles on most BSDs and Mac OS X and allows you to set the network encryption key without running any Windoze software.

The program is called plconfig and it communicates with most Intellon chipset based PowerPacket bridges.

Downloads: plconfig version 0.2 for BSD or Linux

MSI K9MM-V & Fedora instabilities

I have finally given up on the apalling MSI K9MM-V motherboard and Fedora 8. While tweaking BIOS and kernel options resulted in a modicum of stability, it was only briefly sustained and kernel panics frequently resurfaced during reboots.

So farewell to the K9MM-V and a welcome hello to the Gigabyte GA-MA69VM-S2. This is a more costly board but having used Gigabyte boards successfully in the past I am happy to pay a little extra for a reliable platform.

I opted for a straight board switch and connected up the same trusty Seagate Barracuda IDE drives in a RAID1 mirror configuration. The mobo swap was relatively straightforward (apart from the processor being stuck fast to the heatsink on the old board), but unfortunately no matter what combination of boot options I used the Fedora kernel just would not detect my disk drives.

After much head scratching I finally realised that the ata drivers were missing from the initrd image and so I needed to rebuild. So for those in the same bind, here’s what to do:

Boot from the Fedora install DVD into rescue mode (your partitions will be mounted under /mnt/sysimage)

chroot /mnt/sysimage

Edit /etc/modprobe.conf and add the line “options libata atapi_enabled=1”

rm -f /etc/sysconfig/hwconf


mkinitrd -f /boot/initrd-$(uname -r).img $(uname -r)

To check the contents of your new image:

gzip -cd initrd-$(uname -r).img | cpio -id