Recently, 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: <!--more-->
- 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 bymake 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 inopenembedded/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 thepackages/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 filesnslu2-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.