Monday, June 2, 2008

How to stop a noisy hard disk with Linux

The hard disk I use to host my Windows is extremely noisy. Furthermore, since I use Ubuntu 99% of the time and nearly never access this hard drive during this time, keeping the disk spinning is absolutely useless.
The simplest way to stop the hard drive is to use sg3-utils.
To install it just use this command:
sudo apt-get install sg3-utils
Now, if you want to stop the hard drive /dev/sda, use this command:
sudo sg_start --stop /dev/sda
The disk will restart as soon as you will try to access it.

If you want your hard drive to stop every time you log onto your account, you can add the command to the list of software to start when you log in. However, to be able to do that, you will have to allow you to sudo sg_start without having to enter your password.
To do that if your user name is username then, edit /etc/sudoers and add the line:
username ALL=NOPASSWD:/usr/bin/sg_start
To edit /etc/sudoers you have to make it writable by root, then when you have edited it, do not forget to set it read only for root, and nothing for group and users. If you don't do that, or make an error in suoers file, sudo will no more work. So be carefull, and keep a root shell open while you test if sudo still work.

No comments: