lunedì 3 dicembre 2012

Don't let Ubuntu kill your laptop HDD!

A simple question: which "life style" make your (laptop) hard disk last longer?
  1. keep it running all of its life. No matter if you need to read it or not
  2. turn it off (well.. spindown) as soon as possible. Turn it on again as needed
If you have choose 2) well.. be prepared. You are silently killing your HDD!
Spinup, in fact, is quite expensive for and harddrive and, by design, it has been tested only for a limited number of spindown-up sequence.
So, if you don't need to strictly preserve your laptop battery, please leave it turned on!

Why Ubuntu can be a HDD serial killer?
Because, by design, it spins down your drive quite often. Open a terminal and try the following command line

 sudo smartctl -a /dev/sda | grep -i "Start_Stop_Count\|Load_Cycle_Count\|Power_On_Hours"
  4 Start_Stop_Count        0x0012   097   097   000    Old_age   Always       -       5238
  9 Power_On_Hours          0x0012   099   099   000    Old_age   Always       -       719
193 Load_Cycle_Count        0x0012   095   095   000    Old_age   Always       -       55359


As you can see, in my 1-year old laptop, I got nearly 720 hours of work but 5238 (!!!) power sequence and 55359 load cycle.
It's like I've turned on (or put in standby) my laptop 15 times at day, each day (even Christmas) for the last year!

How to change this?
I've found this solution, which is also useful for manage your battery consciously
  • install laptop-mode tools
sudo apt-get install laptop-mode-tools
  • edit /etc/laptop-mode/laptop-mode.conf with your preferred application ad look for BATT_HD_POWERMGMT settings. If it's 1 be prepared for early disk death!
  • change to a reasonable value (like 100, 254 is the highest while 255 disable power management at all). man hdparm  at -B switch will help you in understanding this value
  • save the file and type
sudo service laptop-mode reload

This will apply the changes.
Just to be sure, type

sudo hdparm -B /dev/sda

To check the value applied.

Long life to your laptop's HDD!