NSLU2 Bootup

I noticed that for some reason some of the bits and pieces I had installed on my NSLU2 were not being restarted at boot time: notably dnsmasq, which is a Domain Name Server and DHCP server. I started using this just for fun, but found that after an NSLU2 reboot I wasn’t able to reconnect to the NSLU2. It turned out that for some reason the imac was being given a bizarre IP address, which wasn’t even on the same subnet as the NSLU2. In fact, IIRC, it wasn’t even a legal private domain IP address! Now, I have several things installed on the NSLU2: cron, inetd, portmap, appweb and dnsmasq. I had also installed mt-daapd at some stage. It turned out that mt-daapd was failing to load, and this was causing the script to bail out, without running the remainder of the items. I think. Moral of the story: ensure that you are only loading stuff you need, and that everything is running smoothly.

Cross Compilation NSLU2/MacOSX

So, I’ve built the toolchain - it’s about 69Mb raw, which zips to about 26Mb. Tarring and BZip2ing it reduces it to 18Mb. What I want to know is: is it only the stuff in bin/ that is used when cross-compiling? If so, this compresses to around 3.6Mb, which is small enough to post for others to use… Also, it’s possible to just copy the armv5b-softfloat-linux-* files (I used ln, so they are still in the original spot, but take up no extra room) to a place in your path. From what I’ve just read, the only thing really used is the compiler, but surely the linker is too. I have built a hello.c program, but cannot test it until I get my NSLU2.

NSLU2

I have a Google Alert for the string “NSLU2”. Just now, I had a new alert, and my NSLU2 category has just made it into the top 20… Yay!

NSLU2 MacOSX Toolchain

I’ve just paid for (and expect to receive in the next couple of days) a large (160Gb) USB Hard Drive, and in the next week or so I’ll also buy a Linksys NSLU2 NAS device, to share the HDD with all devices in my network. One of the reasons I decided on this route is the extreme hackability of the NSLU2 - it comes with a cut-down version of Linux with only SMB sharing turned on, but by flashing a new ROM it’s possible to set it up as a complete server. I aim to use it for mainly sharing files, but just for fun I’ll try and build python for it. I had a whole lot of experience building python for BeOS/PPC a few years back. It started to run into problems when building sockets and anything that used mmap(), and after about 2.2 I’m not sure I ever got it to work correctly again. Building the cross compilation toolchain to allow me to do this from MacOS X is quite complicated: you have to download about 60Mb of source code, and then build it. More details on this page. My notes on the topic follow: Make sure you reference the nslu2/bin directory in your path before the other location where the tools you installed are. Bash looks in the order they appear in the environment library list, so if expr is in two places, the first one it is found in is used, for example. The good news is, if the files have been downloaded, and the build fails, it is smart enough not to try and re-download them. Make sure you follow the instructions carefully - I did a make install instead of the cp src/expr $HOME/local/nslu2, and it failed dismally.

NSLU2 on MacOS X

The instructions for installing an NSLU2 are designed for using a Windows box - but it’s easy enough to set it up using any OS. Just use the web server built in, and use an address of 192.168.1.77 and username/password of admin/admin. Following the NSLU2-Linux instructions on unslinging is easy too, except I didn’t know what to do after unslinging and rebooting - ie I cannot telnet back into the box! What you need to do is change the password after connecting the disk but before rebooting: # passwd [enter new password twice] # cp /etc/passwd /share/hdd/conf/passwd # ln -sf /share/hdd/conf/passwd /etc/passwd Then you need to reboot (or maybe you don’t, I did just to test the password stuck!), re-enable telnet login, and you can begin to install packages.

NSLU2 OpenSlug Bootup Error

The other morning, my power went off. I almost slept through my wake-up time, but just made it to work on time. However, the power failure must have caused some sort of a problem with my NSLU2 server. For some reason, I was no longer able to connect to it in any way shape or form. Samba connections failed, and even SSH-ing in didn’t work, with any of the users I had set up. I finally figured out that it had something to do with not being able to boot off the disk properly. It was booting up, then beeping loudly three times (two different tones). Then, it was responding to pings, and accepting ssh connections, but not authenticating. So I connected using the root account and the default password, and it worked. And, true to form, the disks were recognised, but for some reason not mounted. I tried the turnup disk /dev/sda1 command, which doesn’t do anything destructive, but tells the machine to boot up from that device. It failed, with the following error:

turnup: /dev/sda1: partition does not seem to be a valid root partition The partition must contain a full operating system. To ensure that this is the case it is checked for the following, all of which must exist for the bootstrap to work: 1) A directory /mnt. 2) A command line interpreter program in /bin/sh. 3) The program chroot in /sbin or /usr/sbin. 4) The program init in /sbin, /etc or /bin. One or more of these items is missing. Mount /dev/sda1 on /mnt and examine its contents. You can use turnup disk nfs -i -f to copy this operating system onto the disk, but it may overwrite files on the disk.

Okay, that might help. A quick mount /dev/sda1 /mnt/sda1 showed that the partition was valid. But no /mnt directory inside there. Create one, then run the turnup disk /dev/sda1 command again. Then shutdown -r now. Upon reboot, only a single beep (which, IIRC, I put there!), and everything is normal. Phew!

NSLU2 busybox issues

I had a bit of an issue with my NSLU2 tonight. I wasn’t able to install coreutils. It was complaining that busybox-links was installed, and it was clashing. However, I didn’t have it installed, and no amount of ipkg remove busybox-links, or ipkg -force-overwrite install coreutils was working. Then I came across Slugging, which shows how to deal with this exact problem: remove the busybox _and _busybox-links stanzas from the file /usr/lib/ipkg/status. Thanks, z0mbi3. Even though I hate l33tsp33k.

NSLU2 and USB 2.0 Hubs

Having more than two USB drives with an NSLU2 is possible, if you are using a firmware other than the original Linksys rubbish. Some people report having gotten some hubs to work fine. I originally had both drives working using a spare 1.0 hub I had lying around, but it was dog slow. So I bought a 2.0 hub. This worked for the first couple of gigs it copied across from another disk, but then reported errors. It appeared the device just decided to unmount and remount in a different place. I went and bought another hub today, from a different shop. Same problems. I think they are actually the same hub in different packaging, but another 2.0 hub I have lying about fails worse - the drives don’t even mount to begin with. So I went for plan D. It seems that the USB controller chip used can drive up to 5 USB ports, so I cut a USB extension cable, and wired it onto the board in the correct locations. Didn’t work. Disconnecting made it work again. Finally, I was able to get it to work by not using the power connections on the other port, but the +5V and GND locations elsewhere on the board. This was the only way I was able to get the NSLU2 to still boot with the extra port connected. I may have been able to use unpowered ports. That might be cooler. I just thought that the PSU might not be +5V, in which case stuff could go badly wrong. Better check…

Preparing a Disk for OpenSlug

I got a new 250GB USB drive today, and plugged in a hub into my NSLU2, and connected this up. These are the commands I needed to execute to get it all set up (it was an NTFS formatted disk initially).

First of all, use dmesg to ensure the disk has been recognised and mounted. I had to change from my USB2.0 hub to a USB1.0 hub. I’ll get a new 2.0 hub in the next few days to try that out. Apparently some of them don’t work.

From dmesg, the hub has been recognised:

usb 2-1.1: new full speed USB device using ohci_hcd and address 3 usb 2-1.1: not running at top speed; connect to a high speed hub

The new disk has been mounted as an NTFS (dirty) disk:

NTFS volume version 3.1. NTFS-fs error (device sdc1): load_system_files(): $LogFile is not clean. Mounting read-only. Mount in Windows.

Things to note: * the device name in this case is /dev/sdc1. This is the third USB device in my chain. * /dev/sda(1,2,3) are the root, swap and user partitions on the boot disk, * /dev/sdb1 is the first 250GB drive I bought.

nslu2:~ root$ umount /media/sdc1/
nslu2:~ root$ fdisk /dev/sdc1/

Then you will need to delete the partition (d), and create a new one (n). (p): Primary partition, #1, accept default start and end blocks.

Then use (w) to write the partition out to disk.

nslu2:~ root$ reboot

Wait for the machine to reboot fully.

nslu2:~ root$ umount /media/sdc1/ 
nslu2:~ root$ mkfs.ext3 /dev/sdc1 mke2fs 1.38 (30-Jun-2005) ...

It takes a while to process. Worthwhile rebooting after this just to be sure.

All done.

Use veto wisely under samba

I reformatted my file server, and installed OpenSlug on it (much faster than LinkSys firmware, I’ve noticed), and when I was setting up the Samba shares, I thought I’d be a clever bastard, and outsmart the Finder. See, when you access a directory, or copy files using the Finder, and you are copying to a non-HFS disk, it creates a file ._Filename.ext that stores meta-data, the new version of the Resource Fork, for all of you old-school Mac heads. So, I thought, if I use: veto files = /._*/.DS_Store/ then I won’t have any problems with these files littering up the directory structure. But, this won’t work. It doesn’t allow for the creation of these files, which causes the Finder to choke: Removing the veto (I moved it into hide files, which should prevent other clients from seeing them) fixed the problem. For search engines, the text of the dialog box is:

You cannot copy some of these items to the destination because their names are too long or contain invalid characters for the destination. Do you want to skip copying these items and continue copying the other items?

It took me quite a while to figure out why this was happening…