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…
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 (
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.
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!
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…
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.
I’m running my NSLU2 as a file server, torrent client and kaid server. With 6 torrents running, it runs out of memory, and starts killing processes willy-nilly. Took me a while to figure out this was why my script to auto-start a new torrent was being “Terminated.” Not sure how it works out which processes to kill, or if there’s a way to reduce memory use. Then I came across a HOWTO: Add Additional Swap Space. Should fix stuff a bit. Just a note: it takes ages for the file to be created, apparently.
Kissing A Fool • George Michael • Ladies & Gentlemen : The Best Of George Michael ★★
ps x o %mem 0 command, I can see that each
enhanced-ctorrent process grabs about 5 meg, while the 10 or so
kaid processes each use up 2.1Mb. Since I haven’t started using
kaid yet, maybe I should stop it auto-starting…
I’ve written a bit of code that works to automatically start any number of torrents placed into a specific directory. The way it’s set up at the moment is that it will only start the next one on the list, and you need to call it iteratively to start all of them. That’s mainly because on my NSLU2 I get some CPU usage issues if I start more than one at a time. Just have this script called every 5 mins or so in a crontab, and it will start every .torrent added to the source directory.
*/5 * * * * root /path/to/script/autoTorrent.py I could make a resident version, that uses a
time.sleep() to call the main function every 5 minutes. Then this could be added to the
1 #! /usr/bin/env python 2 3 import os, time 4 5 # Any .torrent file placed in $base/source will be downloaded. 6 # When it's complete, it will be moved from $base/work to $base/target 7 8 base_dir = "/home/user/torrent" 9 source_dir = os.path.join(base_dir,"source") 10 target_dir = os.path.join(base_dir,"target") 11 work_dir = os.path.join(base_dir,"work") 12 13 torrent_cmd = "enhanced-ctorrent" 14 torrent_args = "-S localhost:2780 >/dev/null &" 15 16 def getTorrents(path): 17 os.chdir(path) 18 data = os.popen("ls -1 *.torrent").read() 19 torrents = data.split("\n")[:-1] 20 for i in range(len(torrents)): 21 torrents[i] = os.path.join(path, torrents[i]) 22 return torrents 23 24 def getNewTorrents(path, oldTorrents): 25 allTorrents = getTorrents(path) 26 newTorrents =  27 for each in allTorrents: 28 if each not in oldTorrents: 29 newTorrents.append(each) 30 return newTorrents 31 32 def startTorrent(torrent): 33 os.chdir(work_dir) 34 cmd = " ".join((torrent_cmd, os.path.join(source_dir,torrent), torrent_args)) 35 os.system(cmd) 36 #print cmd 37 38 def getRunningTorrents(): 39 # do'h, ps on nslu2 is broken. Had to install procps. 40 cmd = "ps axwwo command | grep enhanced" 41 data = os.popen(cmd).readlines() 42 runningTorrents =  43 for each in data: 44 if each.split() == "enhanced-ctorrent": 45 runningTorrents.append(each.split()) 46 return runningTorrents 47 48 def startIdleTorrents(): 49 torrents = getNewTorrents(source_dir, getRunningTorrents()) 50 51 # since we get some CPU usage issues on starting several torrents at the same time, 52 # just start the first torrent in the list. Then we can rely on the idea we'll 53 # be called by a cron-job or something to start the next. 54 55 startTorrent(torrents) 56 57 if __name__ == "__main__": 58 startIdleTorrents()
I’ve started using BitTorrent, or rather a couple of different clients, since I got ADSL, but what I really want is a fire-and-forget client for the NSLU2. This is what should happen.
- Monitor a certain directory. If a .torrent file is added to this directory, add it to the queue.
- When a torrent is complete, move the file(s) to a completed directory. Send an email, or something. Perhaps add an item to an RSS feed. Remove the .torrent from the download queue, but keep it seeded.
- When neither of the other computers is turned on, download the next .torrent in the queue.
- If the download total of the running torrents is less than 80% of the available, start the next .torrent in the queue.
- If more than one .torrent is running and bandwidth use is greater than 90%, then stop the lowest in the queue that is running.
- Have a nice web interface that allows for changing the queue order.
There is a torrent ipkg for nslu2, which I’ve downloaded, but I may write my own. It’s show day tomorrow, so that might be a good start.
It’s really cool that people are still working on the Firmware upgrades for the NSLU2, and I went to upgrade the firmware today to try to get MySQL working properly. The file is 6.5 MB, and my download keeps failing at 3 MB. And I can’t resume, as I can’t find the actual address - they’ve done a pretty good job of making that hard to find. Annoying…
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!