setting hdparm every boot?

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

paulb100

Thread Starter
Joined
Mar 17, 2005
Messages
1,894
can anyone help me set hdparm to run at every boot on ubuntu?

im a complete noob so simple instructions please, my laptop hard-drive is going crazy with the linux "parking heads" issue - i have a fix to try but i need it to run at boot - its the hdparm -B 254 /dev/sda thingy but it resets every boot

im on ubuntu 64-bit


thanks
 
Joined
Jun 11, 2004
Messages
3,888
hdparm is a Bash command and needs the kernel available first. I wouldn't have thought you can set it a boot time.

After Ubuntu has been booted up you can always issue it as a script which should give the same result.
 
Joined
Sep 12, 2003
Messages
20,583
can anyone help me set hdparm to run at every boot on ubuntu?

im a complete noob so simple instructions please, my laptop hard-drive is going crazy with the linux "parking heads" issue - i have a fix to try but i need it to run at boot - its the hdparm -B 254 /dev/sda thingy but it resets every boot

im on ubuntu 64-bit


thanks
Hi paulb100,

You need to be root to edit the file /etc/rc.local file which should already have executable permission.

I would first save the original file by renaming it to rc.local.original, and then cp -p rc.local.original rc.local and then edit the rc.local file, followed by reboot (if you have an installed Ubuntu 10.10 system (Maverick Meerkat). If it does not work on reboot, then revert the change by simply issuing the command: in /etc: mv rc.local.original rc.local, and then reboot.

For example,
$ sudo -i
# cd /etc
# cp -p rc.local rc.local.original
# vi rc.local (edit the rc.local file)
(insert the hdparm command before the exit 0 command)
:wq (to exit vi)
# shutdown -h now (to reboot immediately)

-- Tom
 

paulb100

Thread Starter
Joined
Mar 17, 2005
Messages
1,894
thanks Tom .but... quote "m a complete noob so simple instructions please," hehe
i dunno how to do anything of wot you mention - i think its a script i need to run as soon as ubuntu is loaded

this is the code to be run in terminal to fix my problem...
sudo hdparm -B 254 /dev/sda
i need this to run everytime ubuntu is loaded... this is because linux programmers have not incorporated any hard-drive power management settings like windows does, so in linux i get excessive head parking which i can hear and also wrecks my drive....why laptop hard-drive manufacturers do this i do not know

so how do i
A) create the script with the above code in? (i know in windows it would be a .BAT file)
and
B) where do I put the file for it too be executed every boot?

thanks
 
Joined
Sep 12, 2003
Messages
20,583
Hi paulb100,

In Ubuntu, execute the following commands (assume you are the default ubuntu user with the prompt: [email protected]:~$ where the '#' character is the root user's prompt you will see after the sudo command) Note: each line is followed by <Enter> which means press the Enter key on your keyboard except for the <Esc> line which means press the Escape key on your keyboard labeled "Esc" - i.e. it is not followied by <Enter> key press. Also, the 'i' command given below to enter the "insert" mode of the vi editor is not followed by <Enter> as there is no need for it.

[email protected]:~$ sudo -i<Enter>
# cd /etc<Enter>
# cp -p rc.local rc.local.original<Enter>
# vi rc.local<Enter>
:13<Enter>
i
hdparm -B 254 /dev/sda
<Esc>
:wq<Enter>
# shutdown -h now<Enter>

Note: There is no need to press the Enter key, i.e. <Enter>, after the hdparm command has been typed on line 13. Also, I used line 13 which is a blank line in my default /etc/rc.local file just before the exit 0 command in that file. The /etc/rc.local file in your system should be the same.

Here is what happens with each command line above:
sudo -i - will put you into root account
cd /etc - changes the current directory to the /etc directory
cp -p rc.local rc.local.original - saves the original rc.local file to its identical twin file named rc.local.original
vi rc.local - will launch the vi editor to edit the rc.local file in the /etc directory
:13 - will position you to the 13th line in the file, i.e. the line before the exit 0 command in the file
i - will put the vi editor into "insert" mode so that the following line can be inserted DO NOT PRESS ENTER
hdparm -B 254 /dev/sda - type only the characters you see and no others
<Esc> - this means press the Escape character on your keyboard which commands the vi editor to leave the "insert" mode
:wq - writes the rc.local file and quits the vi editor leaving you back at the root account's prompt, i.e. the "#" character
shutdown -h now - reboots your computer immediately

When your system is rebooted, if your hdparm command does what you wanted it to do, then you should be all set.

-- Tom
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top