Diary of a geek

March 2005
Mon Tue Wed Thu Fri Sat Sun

Andrew Pollock


Other people's blogs


RSS feed

Contact me

JavaScript required

Monday, 07 March 2005

Adventures in resurrecting a laptop

When the hard drive in my VAIO died a few months ago, I figured it could still be put to use as a "server" of sorts with an NFS root filesystem. Yesterday, I spent some time trying to make that come about, with mixed success.

Because the VAIO PCG-F590 does not have an onboard Ethernet interface (what was Sony thinking?) I've had to rely on USB Ethernet adapters to get by, or a PCMCIA wireless card. As I wanted to use this laptop as the new under-bed Festival-powered weather-reading alarm clock (it has way better audio quality than my Ultra 5, which used to do the job), I didn't see the point in tying up a wireless card for something that was never going to move, so I went for the USB Ethernet adapter option.

I could have built a live CD, but the thought of constantly having to recreate and reburn a CD every time I forgot to install a package really didn't appeal to me, so the NFS root seemed much more practical. As the laptop was incapable of directly booting from a external Ethernet device, I created a bootable CD using the most excellent isolinux.

To get the kernel and initrd required for isolinux, I made a chroot (using debootstrap) on my NFS server. In this chroot, I added the initrd-netboot-tools package, which is part of the lessdisks suite of goodies, a project I'd never heard of until yesterday.

The beauty of using initrd-netboot-tools is I can still use a stock Debian kernel image, and with a bit of tweaking, the initrd does all the heavy lifting of acquiring a DHCP lease and mounting the NFS root. Very cool.

I had to do some slight hacking in the chroot that I was exporting so that the initrd was created correctly. The first problem I struck was there was a slight delay between loading the module for the USB Ethernet device and eth0 becoming available. I had to introduce a 2 second sleep before the DHCP request was made, otherwise it would declare that there was no Ethernet device, and not bother DHCPing at all. Here is an exact list of things I had to change in my chroot:

  • I added rtl8150, af_packet, nfs, ehci-hcd, uhci-hcd, pegasus (one per line) to /etc/mkinitrd/modules
  • I set ROOT= (i.e. nothing) in /etc/mkinitrd/mkinitrd.conf
  • I made sure /etc/fstab reflected the NFS mount for the root filesystem correctly
  • I added /bin/sleep to initrd_exe in /etc/lessdisks/mkinitrd/initrd-netboot.conf
  • I set nic_modules="rtl8150 pegasus" in /etc/lessdisks/mkinitrd/initrd-netboot.conf
  • I added /dev/urandom to initrd_files in /etc/lessdisks/mkinitrd/initrd-netboot.conf
  • I installed udhcpc in the chroot (but I think I could have alternatively installed a package that provided dhclient)
  • I hacked a "sleep 2" into the start of /etc/lessdisks/mkinitrd/install_scripts/70_dhcp

Once I'd done all of this, I installed a kernel-image package into the chroot (2.6.8-2 in my case) and then pilfered the vmlinuz and initrd.img for putting onto the CD.

The CD just had the kernel and initrd and isolinux.bin on it, ala:

`-- boot
    |-- initrd.img
    |-- isolinux
    |   |-- isolinux.bin
    |   `-- isolinux.cfg
    `-- vmlinuz

The isolinux.cfg is really basic (I need to change it so that I can actually pass some parameters at boot time):

DEFAULT /boot/vmlinuz
APPEND initrd=/boot/initrd.img rw root=/dev/nfs nfsroot= ip=dhcp hda=none nfs_opts=rw,sync,nolock

That's about it. Then I struck the problem with doing NFS over a USB Ethernet adapter, which I'm yet to resolve. I tested the whole process out on my current laptop (which has an onboard Ethernet) and it worked fine, so once I resolve the issues with NFS over a USB Ethernet adapter, I should have the VAIO working nicely as a diskless server under my bed reading the weather to me.


I received a suggestion from Uwe Klein via the Linux USB users mailing list to lower the rsize to 1000. This allowed the bootup to proceed slightly further, before it got bogged down again in a similiar manner. Andreas Metzler suggested I switch to NFS over TCP, which ended up being just the ticket, and laughably easy to do.

For the record, I also ended up adding /bin/hostname to the initrd_exe line of /etc/lessdisks/mkinitrd/initrd-netboot.conf and my final isolinux.cfg contained:

DEFAULT /boot/vmlinuz
APPEND initrd=/boot/initrd.img rw root=/dev/nfs nfsroot= ip=dhcp hda=none nfs_opts=rw,tcp,sync,nolock,rsize=8192,wsize=8192 vga=0x317

The talking weatherman returns!

[03:33] [tech] [permalink]