NSLU2-Linux USB harddrive spindown

NSLU2; source: nslu2-linux yahoo groupRecently, I bought a Linksys NSLU2 network attached storage device and installed Linux on it. I have it boot over a 64 MB USB flash stick that I had to spare and I connected a ext3-formatted USB harddrive to it. It works flawlessly with Samba, serving the USB drive to all of my client OSes.

However, as I only need the USB harddrive maybe twice a day, I did not want it to run all 24/7. The main reason is, of course, that it wastes electricity, and additionally running all the time might have an unnecessary impact on the longevity of my drive. Especially because it is used only now and then.

Almost all the pages I found about this on the net mentioned that currently (and maybe forever) it is impossible to have a spindown time for USB harddrives, due to the SCSI driver emulation in the Linux kernel.

Today, however, I found an interesting thread in the nslu2-linux mailinglist. Robert Demski has provided a kernel patch as well as a binary package for the OpenEmbedded system (which is the base for the OpenSlug distro).

I managed to patch my openslug image accordingly and now USB spindown with scsi-idle works flawlessly for me with a Kernel 2.6.15-2. Once it is patched in the main images, you are good to go; If you want to build your own flash image right now, instead, here we go:

  • To add scsi-idle spindown functionality to the OpenSlug, we have to set up a cross-compile environment for the NSLU2 as shown on the NSLU2 Development Homepage as well as the Master Makefile documentation.
  • Unfortunately, the whole process is very, very poorly documented so that it is pretty hard to find out how to patch the kernel and simply have the flash image rebuilt. But once you get it, it’s not that complicated anymore.
  • So after we got all required packages, we run make setup followed by make build-openslug-image.
  • Then we have to apply kernel-patch-scsi-idle.patch provided in the file section of the nslu2-linux yahoo group (member access only…). We find the kernel files in openembedded/packages/linux/nslu2-kernel/$version. The patch must be copied in here.
  • Now add the patch file name to the BitBake file for your kernel version: nslu2-kernel_$version.bb, located in the packages/linux directory.
  • In order to have the kernel rebuilt, we have to remove some files from the stamps directory. This dir contains dummy files that indicate if a specific step was already taken by the make process. We remove the files nslu2-kernel-$version.do_*, so that the whole kernel package will be patched and rebuilt.
  • Then run a make build-openslug-image again out of the cross-compile environment’s base directory. It should tell you that it compiled the kernel package again and it built a new flash image.
  • You will find the flash image(s) in openslug/tmp/deploy/. Please make sure you fetch the right (newest) one as there are most likely at least two images in there.
  • With that image you can reflash your NSLU2.

Afterwards, you want to install the scsi-idle package also provided in the executables section of the nslu2-linux group. Afterwards, you can configure the idle timeouts in /etc/default/scsi-idle and start the corresponding daemon. It should spin down (and up) your hard drive as intended!

P.S.: The kernel patch will be included in the main OpenSlug images soon.
Update: I also sent in a patch for the OpenEmbedded source tree in order to have the scsi-idle package available in the main tree shortly.



Categories: OSU OSL Crosspost, Tech Talk

12 Responses to “NSLU2-Linux USB harddrive spindown”

  1. Hi, I’m a newbie in Linux but own 3 NSLU2 and after reading your article, tried to setup one of my NSLU2 to Openslug 2.7 with the development environment. All is fine until the ‘make build-openslug-image’ where I keep getting: make: °°°No rule to make target `build-openslug-image’. Stop.
    Would it be possible to have some clue on how to solve this issue or get your image ? Did you try to apply this for unslung 5.5 beta too? My two other slugs are unslung only.
    Thanks
    Brandon

  2. Are you sure you downloaded the master makefile at all?

    And are you in the right directory?

  3. isnt it possible to become the final image file with all this included ? im not so strong in compiling linux :)

  4. I guess it should be available in a release, soon :) Unfortunately I cannot just upload the image file as it would make license problems because it contains the Intel ethernet drivers.

  5. this NSLUG drives me crazy, such a good box with tons of features but no auto spindown for usb disks, what a drawback. Fred, can i contact you somehow via email ?

  6. How soon is it going to be available?
    What about unslung?
    Thanks

  7. Ante, I just wrote a message to the nslu2 mailing list in order to find that out.

  8. [...] Today I was connecting a second USB harddrive to my NSLU2. [...]

  9. [...] As you all know (or not, whatever), I am sharing files between all of my computers using a Linksys NSLU2, running OpenSlug. [...]

  10. What disk enclosure are you using? Since this doesn’t work with all enclosures, it would be interesting to know.

  11. I agree, that’s a question of luck, unfortunately. I have one no-name enclosure that works with the usb spindown, another one that does not. I also have one that works too and it’s a Maxtor USB drive that already came in an enclosure. Maybe that is your safest bet if you want to make sure that you get one that works.

  12. [...] you got the last one!)… It has 1GB, that’ll make for a great new root drive for my Slug (which currently runs on 512M). By the way, why can OS X’s Disk Util.app format an [...]