NSLU2-Linux
view · edit · print · history

The Problem

If you have a Maxtor OneTouch and want to set the spin-down on idle timeout, you can use a tool provided by Maxtor on the CD that comes with the drive. This tool runs only on Windows so ideally do this before connecting it for the first time to your NSLU2. But, if you formated your drive with the NSLU2, you can't chose your drive with that tool.

The Maxtor utility v4.0.4.0 discovers my already formated OneTouch III without any problem. Setting the spindown time via energy options works as expected.

The Maxtor utility v4.1.0.12 will also change spindown time on my ext3fs OneTouch III. However, in testing I tried to wait for it to spin down with the drive plugged into the SLUG (running Debian Etch from a keychain disk) while the SLUG was powered off. This just didn't work. Solution: Boot up the slug, once booted, wait for the established spindown time - the drive spins down fine with the SLUG booted.

Even after you set the master discs spin-down the drive will not spin down because of regular accesses to /dev and /var. Instructions below describe how you can place /dev and /var on a ramdisc.

The Solution

Attach your disk to a Linux box and use fdisk to set the partition type to Windows (I set the first partiton to 0x0C). Now attach your drive to Windows-box or reboot to Windows. The partition will now automatically be assigned a drive letter (like H:) and you can select the drive from within the Maxtor utility and change the spin-down timeout. Afterwards back into Linux to restore the partition type back to a type the NSLU2 supports (probaby 0x83).

I suggest doing this before storing your only copy of your Britney CDs because something could go wrong; Windows may decide to write disk signatures and other useful information all over your most vital data. Although this has been tested and is reasonably safe, there are no guarantees. Backup your important data.

If (like me) you don't run Linux at home then download Knoppix, a LiveCD distribution. Burn a CD with it on, then boot from the CD and you'll have access to Linux for the period of time you need. Remove the CD, and you reboot back to Windows.

Another solution

Attach your disk to a XP box and run PartitionMagic. Create a small (I did 15MB) NTFS partition. Now XP will recognize the disk and you can change the spindown time.

One Modification to "The Solution"

Instead of changing the conf (sda1) or data (sda2) partitions, change the swap partition (sda3). This way if Windows messes it up, you haven't lost any data. Just make a note of the partition type before you make the change and set it back when you are done.

Still another solution

Attach the (ext3 formatted) disk to your Windows PC, install Ext2fsd, and use the included MOUNT.EXE to mount the drive. It will then have a drive letter, and you'll be able to read its contents. Then run the Maxtor OneTouch II utility and set the spin down time as you wish. Then put the drive back on the NSLU2. Having Ext2fsd installed will allow you to read the disk directly on your PC whenever necessary!

JamesCC October 2005 - This seemed the safest option, however I had considerable hassles with this, but got there in the end! Here are some suggestions...

  • Make sure you have the latest Maxtor drivers/utility (go to http://www.maxtor.com and click on software downloads).
  • I have a old Maxtor OneTouch drive and the original Maxtor driver really messed up my USB devices. This is how I fixed it (ONLY DO IF NECESSARY. NO GUARANTEES WITH THE FOLLOWING. TRY AT YOUR OWN RISK). Under WinXP (SP2) I deleted all the items under "Universal Serial Bus Controllers" in the device manager (a little trial and error is necessary as they need to deleted in the right order). OBVIOUSLY DON'T DO THIS IF YOU HAVE A USB KEYBOARD, as the USB devices will stop working (mouse can be an issue too, but you can usually get around it by using the keyboard)!!!! Upon rebooting XP will reinstall the USB controllers, and the necessary drivers for the USB items connected (usually without you needing the disks). Everything worked great after that.
  • Install ext2fsd as mentioned above (I got an error message when installing, but that didn't seem to matter). Disable writing (it is not reliable and could mess up your disk).
  • Shutdown and start the PC with the NSLU2 drive attached (and powered!) - i.e. don't connect after windows starts.
  • experiment with ext2fsd mount command in a dos box (you need to guess the magic disk number) - just start from 0 and work up you'll find the ext drive eventually (you'll notice it can mount NTFS, FAT as well as EXT2/3). You do not need to unmount a drive letter before trying another mount command (in fact it is a bit bugging in that it won't let you unmount unless you have successfully mounted). Check the mounted drive when you are successful (especially try a sub directory) - the ext2fsd driver seems a little sensitive, so if necessary give your PC a reboot, and try again.
  • Once your mounted drive looks good. Run the Maxtor OneTouch utility if you want to set the Spin Down Time.

A solution when using unslung firmware 4.x or 5.x

With unslung firmwares 4.x or 5.x, the complete root filing system is located on a disk partition. The One Touch drive will never spin down because linux will regularly access log files located in /var. One possible fix for this is to move the /var folder tree to a ramdisk (or possibly to a flash ram stick).

Instructions to create and move /var to a ramdisk -

Using a unix style text editor, copy the following script section into a new file called rc.bootbin, you need to locate this file in the /unslung folder located on the disk drive rootfs. chmod the file with permissions 755.

 
#!/bin/sh
# /unslung/rc.bootbin
# Tested with unslung firmware 4.20 and 5.5
# Script section to create ramdisk for /var

/bin/echo "Creating ramfs for /var:"
/bin/mount -t ramfs ramfs /mnt/tmpmnt -o maxsize=256
/bin/cp -rp /var/* /mnt/tmpmnt/
/bin/mkdir -p /var.state
/bin/mount -o bind /var /var.state
/bin/mount -o bind /mnt/tmpmnt /var
/bin/umount /mnt/tmpmnt

# Return and continue execution of system rc.
return 1
# [EOF]

Re-boot your slug

Use cat /proc/mounts to check that /var is running in a ram disk.

RobHam June 2005

Additional Note on the above:

The above worked for me, with 5.5 Beta, but only when I had repeated the ramfs process for the /dev dir. Repeat the main section of script and replace var with dev. I reduced the maxsize down to 128 for the /dev ram disk. After inactivity the disk spun down in time with the setting entered using the Maxtor utility.

Nigel Gerdes Aug 2005

Another Additional Note on the above:

Unslung 5.5. I also needed the ramfs process for the /dev dir. It is also worth pointing out that you need to mount the HDD /dev/sda1 with noatime. This prevents writes (modification to access time) during reads (common issue is when a crontab is being read by crond - every hour if using the linksys fix for the clock). The reads can be cached (and so the disk is not read), but the writes (for the access time) get done immediately taking the drive out of standby.

Note that the hourly linksys fix for the clock is easily changed to update only once per day at midnight by changing the relevant line in the /etc/crontab file to :-

0 0 * * * root /usr/sbin/hwclock -s &>/dev/null

Then re-boot your slug.

Script to re-mount your discs with noatime. Using a unix style text editor, copy the following script section into a new file called rc.local, you need to locate this file in the /unslung/ folder. Remember to chmod the file with permissions 755, and while you are at it, it is worth checking you've typed it in correctly :-

 
#!/bin/sh
# /unslung/rc.local
# A diversion script to remount the drive(s) without access
# times being recorded (the update of access times can
# prevent drives sleeping)

# Usually it is enough just to do /sda1 as this is the usually
# the one that holds the system.
/bin/echo "Remounting /dev/sda1 with noatime"
/bin/mount -o remount,rw,noatime /dev/sda1
#/bin/echo  "Remounting /dev/sda2 with noatime"
#/bin/mount -o remount,rw,noatime /dev/sda2

# return 1
# EOF - include this line

This is very similar to what happens in /etc/rc.d/rc.1 when /.ext3flash exists. The main difference being that the swap is left as is. Re-boot your slug for the script to run. Then check that /dev/sda1 has the option noatime set, by typing mount.

JamesCC October 2005 - (modified for rc.local unslung diversion script)

Better /unslung/rc.bootbin with /dev and /var ramdisk and working syslog

(Andreas, Jan 2006)

 
#!/bin/sh
# /unslung/rc.bootbin
# Tested with unslung firmware 5.5
# create ramdisk for /var and /dev

/bin/echo "Creating ramfs for /dev:"
/bin/mount -t ramfs ramfs /mnt/tmpmnt
/bin/cp -rp /dev/* /mnt/tmpmnt/
/bin/mkdir -p /dev.state
/bin/mount -o bind /dev /dev.state
/bin/mount -o bind /mnt/tmpmnt /dev
/bin/umount /mnt/tmpmnt
/bin/echo "Creating ramfs for /var:"
/bin/mount -t ramfs ramfs /mnt/tmpmnt -o maxsize=256
/bin/cp -rp /var/* /mnt/tmpmnt/
/bin/mkdir -p /var.state
/bin/mount -o bind /var /var.state
/bin/mount -o bind /mnt/tmpmnt /var
/bin/umount /mnt/tmpmnt

# restart logging daemons
/bin/killall syslogd
/bin/killall klogd

# Return and continue execution of system rc.
return 1
# [EOF]

Do not forget you will also have to set 'noatime' for /dev/sda1, a script above describes how.

Note by Anguel Stankov: The rc.bootbin and rc.local scripts given above seem to make my WD MyBook 500GB spin down with Unslung 5.5 only. I cannot make spindown work with Unslung 6.8 or original Linksys firmware v23RA5. This spin-down problem is also reported in the "nslu2-general" newsgroup.

Note by Oli Wright: I too had this problem with a WD MyBook and Unlsung 6.8. It seems to be a process called 'onetouch_detect' that causes the problem. Killing it has made my WD MyBook spin down properly after 10 minutes. If you add the following to the middle of the /unslung/rc.local script then the offending process will be killed on startup.

 
# Kill the onetouch_detect processes so that the WD MyBook drive can spin down
/bin/killall onetouch_detect

Note by Alexander Lorz: The combination of the additional rc.local, rc.bootbin and a modified crontab worked fine for letting my MyBook 250 GB spin down on Unslung 6.8. The Downside of this solution is that I cannot power of the slug anymore by pressing the power switch. Reboot from the console works. If I remove or rename the new rc.local powering of the slug works fine again. Addendum: FIXED - just look at the old /etc/rc.d/rc.local and add the startup commands for the processes checking for reset and power-off and all the other stuff after the re-mount of the drives in your new /unslung/rc.local

Note by Mathis: Uncommenting the return 1 line in /unslung/rc.local also fixes the issues with halting. Not returning 1 from any /unslung/rc.* script causes the calling /etc/rc.d/rc.* script to abort.

Note by Markus: I'm using Unslung 6.8 and a WD Mybook 320 gb Essential Edition without a flash-stick and it will spin down after about 10 minutes of inactivity IF the two scripts rc.local and rc.bootbin are used as described above together with edits of the crontab. I figured out that my disk was not called sda1 but sdb1, a hint to new users when editing rc.local. In the crontab I removed the line about checking disk space and changed the watchdog and time set function to run once a week.

Note by Andreas Lundblad: I'm using Debian and a WD Mybook 320 gb Essential without a flash-stick. It will spin down after 10 minutes UNMOUNTED (out of the box). However after a clean Debian installation the system accessed the disk. (Logs said kjournald, sysklogd and pdflush). I resolved this by editing /etc/fstab and adding noatime on the sda lines and killing sysklogd and cron with rc-update -f remove sysklogd (and then for cron).

Note by Jean-Bernard: Hello with all! I have myself a disc "My book essential edition 2 - 500GB" connected on my NSLU2 (firmware unslung 6.10 beta mounted on /dev/sdb1) and I applied all the various modifications suggested well above, but the disc never spin-down! However I checked well, the folders /dev and /var are well mounted in ramdisk and the disc indicates to me well that it there not access during more than 10 '!!! But nothing made there, he don't want to spin-down…. The only means of putting it in spin-down is to stop the NSLU2. Would you have a hint to give me? Somebody has the same problem?

[Solved] After checking, the hard drive spindown well, the indicator remains lit but the disc is well stopped after 10 '. I applied all the modifications suggested by Markus. Thank you with you all! Thank you for help !!

The Non-Problem

I had no problem setting the spindown time with sdparm, see http://www.joachim-breitner.de/blog/archives/130-Silencing-my-Slug.html

Default Spindown 1 hour Just checked my new One-Touch III - factory default appears to be 1hr to spindown. So it's highly likely that there is no need to mess with the Maxtor at all, all that is needed is to eliminate dynamic access to the disk as shown in scripts above.

Solution for kernel 2.4 and upwards

Add to /etc/fstab the line

 tmpfs           /var/run        tmpfs   defaults,size=512k      0       0

and modify all lines which mount a partition on your MaxtorOneTouch to contain the noatime parameter like the following line:

 /dev/sda1       /               ext3    defaults,noatime,errors=remount-ro 0       1

Beside that you have to change the exim4 settings in /etc/default/exim4. Either you must set a higher value for QUEUEINTERVAL (default = 30 minutes) to prevent exim from starting the disk every half hour, or you simply can stop the exim4 server if you don't need it.

Additionally you can shorten the time after which the drive spins down using sdparm in the following way:

 sdparm --set=SCT=3600 /dev/sda

This will set the time till spin down (SCT = Standby ConditionTimer) to 6 minutes (= 3600 tenth of a second).