Spin down the hard drive when idle
First of all, you should think hard about whether your setup actually allows you to spin down the hard drive. As the box to the right points out, ext3 writes regularly to disk, preventing a useful spindown. There are other programs known to write regularly on disk, such as ntp, exim and various logging daemons. Some workarounds have been posted on various places around the web, detailing how to prevent each of these from doing these regular disk writes. However, they have not (especially as regards the ext3 filesystem) been well tested on the LinkStation, and may cause problems.
Furthermore, you should note that a spindown must be done only for a long period if it is not to damage the disk, since the spin down/up cycle causes considerable wear. Desktop drives are not built for too many spin downs/ups. Laptop drives, are designed to some 500,000 spin downs/ups in compared to the sub 40,000 of a desktop drive. According to one estimate, if a disk spins up/down every 10 minutes, it will break within one year.
Nevertheless, below is documentation on how to install two different tools (not to be intalled both at the same time), meant to allow spindown.
1. Install the Noflush daemon. Noflushd will automatically spin down the LinkStation hard drive after a defined period of inactivity. Use the command:
apt-get install noflushd
2. You will be prompted to enter a spin down time. The default timeout is 5 minutes (which is probably too low for most people).
3. You may modify /etc/default/noflushd if you wish to change the spin down time.
4. An alternate method for spinning down the hard drive is documented at Articles/DebianHdparm.
Laptop Mode Tools
This might not be a good idea, I may be crazy, but...
Using laptop-mode-tools i have been able to keep my HDHG Linkstation hard drive spun down for hours. I wanted to do this as i want my linkstaion powered on all the time, but expect it will only be accessed every few days at the most. My desire to spindown is related mostly to noise, somewhat to wear, somewhat to power, and somewhat irrational.
Using Hdparm or NoFlushd did not work for me because of the ext3 filesystem, as I understand it. Other people seem to have been successful with hdparm which confuses me.
Firstly, using laptop mode to keep your harddrive from spinning up for extended periods (6hrs in my case) risks data loss as the disk writes are kept cached in RAM untill RAM is too full, or 6hrs, or spinup for read access. If power is interupted etc you lose any cached writes. I am not as concerned about this as i have a battery backup. I do, however, wonder what it is about the ext3 filesystem that accesses the drive so regulary, and what would be lost (other than my actual data) if the system crashed. If the ext3 filesystem loses 6hrs of it's housekeeping, what is it losing and how much damage will be done.
I believe if someone accesses my drive (visits my site) the drive will spin up to read data to send them, so any activity they have will be written during their visit. That is my theory. Only ext3 house keeping will remain unwritten for long periods.
I have changed the stock settings to 6hrs max without writing, 5MB max unwritten data. I am still evaluating if 5MB is too low for long spindowns, but i would like a write for sure for large amount of data (greater than 5MB).
If this 'solution' isn't totally stupid i will post details. If it is totally stupid please let me know. If there is a better solution also please let me know...
From what i have read at http://www.xs4all.nl/~bsamwel/laptop_mode/index.html and its referenced article laptop-mode is built into the 2.6 kernel. If you "ls /proc/sys/vm" you will see 'laptop_mode' already there. If you "cat /proc/sys/vm/laptop_mode" it should be "0" as it is turned off. Once installed and configured this value changed to "2" for me.
Laptop-mode-tools can be installed "apt-get install laptop-mode-tools" (v1.05 stable, 1.31 unstable - i have installed 1.31 installed from the above website)
Once installed you must edit "/etc/laptop-mode/laptop-mode.conf" . The conf file is very well documented and verbose. The list of settings is quite long, here are listed ones I changed (comments are mine) :
- these to ensure the linkstation is always in 'laptop-mode'. I am not sure if the LID_CLOSED is necessary
- these to set a max 6hrs of storing unwritten writes before forcing a write
- I am not sure if this one was necessary
- laptop-mode will set the hfparm settings
LM_AC_HD_IDLE_TIMEOUT_SECONDS=5 LM_BATT_HD_IDLE_TIMEOUT_SECONDS=5 NOLM_HD_IDLE_TIMEOUT_SECONDS=5
- if unrwritten pages exceeds this percent of memory a write will be triggered
- I tried 10 but it did not seem to sleep long enough from me. More experimenting needed
You may need to reboot, i did. Execute "cat /proc/sys/vm/laptop_mode" to ensure you are in laptop mode. Wait patiently for your drive to sleep - mine takes a few minutes despite the 5 sec sleep setting, but then sleeps for hours. I am curious about what people with more linux knowledge think about this. It may be worth a wiki article, which i will definitely do, but after comment of mentioned knowledgable people.