• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 487
  • Last Modified:

hdparm options lost at shutdown

-W1 -k1 -K1 /dev/hdeI've recently tweaked hdparm to improve performance.  When using the browser, throughput has increased by an order of magnitude.  Unfortunately, I dual boot (sigh).  And when I find it necessary to go back into Windows XP, then boot into Debian Linux again, most of the hdparm options have reverted to off.

I executed:
hdparm -A1 -c3 -m16 -d1 -X69 -u1 -W1 -k1 -K1 /dev/hde

What do I have to do to get these options to stay turned on during a reboot cycle?
0
Gnustome
Asked:
Gnustome
  • 19
  • 16
  • +1
1 Solution
 
shivsaCommented:
u add these options to a script and run that script during boot time.
u can that script  to /etc/inittab file.
0
 
shivsaCommented:
write a little script with all these commands.

default runlevel must be 3.

1st: Create you script in /etc/init.d
2nd: then create a link to this file in the appropriate directory
(default runlevel beeing 3 make a symbolic link in /etc/rc3.d
that point to your script in /etc/init.d using the ln -s command)

3rd: to work you link should be named that way
SxxSciprtId
where S is S or K letter ( uppercase )
S mean Start and K mean Stop ( so if u want to stop the service to start when the system boot, you simply rename the link from SxxScriptId to KxxScriptId)
where xx is a number between 01 and 99.
this is the priority of the script, all script in the directory are executed ( except those beggining with a K ) following the order of the number 01 first and 99 last. ( two script can have the same priority)
and where ScriptId is a descriptive Id that you give to the link to remember what it does.

the file in the directory /etc/rcx.d
where x is 1 to 6
are services runed at startup by the system.
0
 
GnustomeAuthor Commented:
There are a few things I don't understand.  1) Why would I want to stop the script at boot, since I want hdparm to run at boot, 2) How do I create a link,  3) In naming the script itself, does a lower number indicate a higher priority, and 4) I assume I will use a text editor to write the script, but won't that attach an extension to the script name (SxxScriptId.yyy)?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
PurpleTigerCommented:
You could always add the hdparm line to your boot.local file.  This gets executed during the boot sequence.

If you do a:
 find / -name "boot.local"
as root, it should show you the location of this file - you can then add the line to the end

The reason I suggest doing a find is that (a) I can't remember where it is as I am not at my machine and (b) I don't know if it is in the same place in all dists :)

Hope this helps.
0
 
TheWeakestLinkCommented:
Look here :-

http://linux.oreillynet.com/lpt/a/linux/2000/06/29/hdparm.html

The last few lines before "In Conclusion", near the end of the page address precisely this issue.

Paul
0
 
shivsaCommented:
Dear GnuStome,
lets assume u create a flile in /etc/init.d with the name hdparm.txt.
chmod +x hdparm.txt

1. that was convention, some people want to stp their running script when they reboot.
in your case u will use S.
2. cd /etc/rc3.d ; ln -s /etc/init.d/hdparm.txt  S99hdparm

thats it u are done.
0
 
GnustomeAuthor Commented:
I may be slow, but it looks to me like I write the script called hdparm.txt and put it in /etc/init.d.  I then put a link called S99hdparm in /etc/rc3.d using cd /etc/rc3.d ; ln -s /etc/init.d/hdparm.txt S99hdparm
Is that correct?
0
 
shivsaCommented:
thats perfect. make sure that file hdparm.txt is executable.
chmod +x /etc/init.d/hdparm.txt
and try out.
0
 
GnustomeAuthor Commented:
I went ahead and created a script called hdparm.txt and put it into /etc/init.d.  I also created a link called S99hdparm, which now resides in /etc/rc3.d.  But in order to write to /etc/init.d I had to change the permissions using chmod 777 /etc/init.d.

I then executed:
cd /etc/init.d
chmod -x hdparm.txt

What other permissions changes should I make?  For example, I don't think init.d should be 777.
0
 
shivsaCommented:
one mistake u did
chmod -x hdparm.txt it should be chmod +x hdparm.txt

nothing else, everything else is default.
did u try running yout script standalone if that works.
if that works if u run that script alone then u are all set.
0
 
GnustomeAuthor Commented:
I changed -x to +x

When I try to run the script standalone I get the error message:
bash: command not found

And when I reboot most of the changes are lost.  But hdparm.txt is in init.d and S99hdparm is in rc3.d.
0
 
shivsaCommented:
problem is in your script.
do u need to use bash.
u can start your script with

---------------------------
#!/bin/sh
hdparm -A1 -c3 -m16 -d1 -X69 -u1 -W1 -k1 -K1 /dev/hde

-----------------------
try this simple script.
0
 
GnustomeAuthor Commented:
I tried the script, but it didn't work.
0
 
shivsaCommented:
what it did say.
script did not work alone or after reboot it did not run automatically ??
0
 
GnustomeAuthor Commented:
Standalone, it said
bash: hdparm.txt: command not found

Rebooting it did not run automatically.

But I did learn that if I ran it using ./hdparm.txt, it works.
0
 
shivsaCommented:
okie it means it will work alone.
then it should work at reboot time also.
0
 
shivsaCommented:
one check i would to see do u have directory
/etc/init.d
or /etc/rc.d/init.d

u can try this also
cp /etc/init.d/hdparm.txt /etc/rc.d/init.d/hdparm.txt
ln -s /etc/rc.d/init.d/hdparm.txt  /etc/rc3.d/S81hdparm
0
 
GnustomeAuthor Commented:
I have /etc/init.d

The script doesn't run at boottime.  It only works standalone if I put ./ in front of the command.
0
 
shivsaCommented:
could u  try changing priotity like.

ln -s /etc/init.d/hdparm.txt  /etc/rc3.d/S81hdparm

first try to run like this
/etc/rc3.d/S81hdparm

if it runs then try reboot.
0
 
GnustomeAuthor Commented:
I changed the priority to 81, then executed:
/etc/rc3.d/S81hdparm

That worked, but it didn't work when I rebooted.
0
 
shivsaCommented:
what run level u are running. it will run if u boot to default run level ie 3.
please halt/shutdown the system and then type boot and see if it works.
0
 
GnustomeAuthor Commented:
I'm using rc3.d.  Since I dual boot I have no way to type boot after shutdown.  All I can do to boot is to press Enter when Linux is highlighted.
0
 
GnustomeAuthor Commented:
I am running Debian 2.4.18 and that may be different from other distros.
0
 
shivsaCommented:
okie than u might try adding it to all run level.
ln -s /etc/init.d/hdparm.txt  /etc/rc1.d/S81hdparm
ln -s /etc/init.d/hdparm.txt  /etc/rc2.d/S81hdparm
ln -s /etc/init.d/hdparm.txt  /etc/rc6.d/S81hdparm

see if any of this work.
this is very easy i am missing something or debian has some different concept, but at last it is linux and this is generic stuff and should work.
0
 
shivsaCommented:
also try this too for debain(it did not know about debian before).

after creating script in /etc/init.d,
then use update-rc.d to fix the links for it.
do a update-rc.d --help to find out what the commands are, also there's man update-rc.d. there is also the rcconf package, which does this same process with update-rc.d (it's a script with update-rc.d
integrated as a main component).

0
 
shivsaCommented:
also in debain i think run level 5 is default so try this
too
ln -s /etc/init.d/hdparm.txt  /etc/rc5.d/S81hdparm
0
 
GnustomeAuthor Commented:
One of those run levels worked, but booting locked up.  So, I had to do a minimal install.  Now, to recover my backup image on /dev/hde7 I need to know what options to use in fstab.  Then I need to know how to place the running of hdparm last in the boot process.
0
 
shivsaCommented:
sorry about booting locked up.

may be it should have run at 99 level.(we changed it to 81 randomly, my bad).

fstab is filesystem file. i do not know what option u are asking could u be more specific.

it is debian and its default level is 5 so i think
ln -s /etc/init.d/hdparm.txt  /etc/rc5.d/S81hdparm  worked. u could change it to

ln -s /etc/init.d/hdparm.txt  /etc/rc5.d/S99hdparm to run in the end of boot process.
0
 
GnustomeAuthor Commented:
Regarding fstab, there are 6 columns: <file system> <mount point> <type>
<options> <dump> <pass>

For example, for /dev/fd0 the options are user,noauto.  I know that for mounting /dev/hde7 the rest of the line is /mnt/Linux.Backup vfat defaults,----0000 0 0

I can't remember what comes before the 4 zeroes.
0
 
shivsaCommented:
i do not think it matter since most of relavent option u know already so u can mount with
mount -t vfat /dev/hde7 /mnt/Linux.Backup

and u can have all the backup files.

fstab is used to mount all the partition during boot time automatically so even if u forget what was there, u can manully mount it once it comes up.

otherwise u can have fstab entry for this like
/dev/hde7 /mnt/Linux.Backup vfat defaults,auto,rw  0  0
0
 
GnustomeAuthor Commented:
I've recovered my backup image.  I've noticed that in /etc/rc5.d there are 3 links with priority 99.  In order to assure that hdparm is the lsat to run, should the other 3 be given a slightly higher priority?  If so, what is the best way to do that?
0
 
shivsaCommented:
Glad to hear u got your backup.

it is ok if u have 3 images with 99, mostly 99 is given to the script which are user generated.
so it is ok if they run together. they will last to run after all the system proceses and scripts.
0
 
GnustomeAuthor Commented:
I understand that all scripts with 99 will run together.  I am worried about another lockup if hdparm runs at the same time as another script.  The next closest priority is 89, so there is room for change, if necessary.  The scripts are gdm, xdm, and rmnologin.  I don't want another lockup.  Are you sure they will run together all right?
0
 
shivsaCommented:
yup these are last scripts to run with 99, if they are setup like this it means they do not higher priorities.
it is standard practice to run user scripts at 99 at boot time.

i am sure u wound see any more lockup.

even i think the script are loaded with alphabatical order so u may want to name the script ro S99zzhdparm.
ln -s /etc/init.d/hdparm.txt  /etc/rc5.d/S99zzhdparm.

and remove the other refenences from other run level and files which we created before.
0
 
shivsaCommented:
Dear  Gnustome,

whats up with this, did it work correctly this time.
0
 
GnustomeAuthor Commented:
I haven't tried it yet.  I have a lot going on right now, but I will try it in the next few days.  Thanks.
0
 
GnustomeAuthor Commented:
Shivsa, I am going to try the command again.  But I have a number crunching process running that I don't want to interupt.  When that is finished I am going to make a backup of the Linux partition to a CD-R and create a partimage boot CD.  I also have a Windows question that I'm working on, which also has to wait until the number crunching is done.  So, sit tight.  If the hdparm question works you will get most if not all of the 500 points.  I appreciate the help you've given me.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 19
  • 16
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now