Solved

hdparm options lost at shutdown

Posted on 2003-12-03
37
475 Views
Last Modified: 2013-12-15
-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
Comment
Question by:Gnustome
  • 19
  • 16
  • +1
37 Comments
 
LVL 24

Expert Comment

by:shivsa
ID: 9872421
u add these options to a script and run that script during boot time.
u can that script  to /etc/inittab file.
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9872490
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
 

Author Comment

by:Gnustome
ID: 9873005
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
 
LVL 1

Expert Comment

by:PurpleTiger
ID: 9873578
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
 
LVL 2

Expert Comment

by:TheWeakestLink
ID: 9873861
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
 
LVL 24

Expert Comment

by:shivsa
ID: 9875229
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
 

Author Comment

by:Gnustome
ID: 9876326
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
 
LVL 24

Expert Comment

by:shivsa
ID: 9876367
thats perfect. make sure that file hdparm.txt is executable.
chmod +x /etc/init.d/hdparm.txt
and try out.
0
 

Author Comment

by:Gnustome
ID: 9876501
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
 
LVL 24

Expert Comment

by:shivsa
ID: 9876594
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
 

Author Comment

by:Gnustome
ID: 9876717
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
 
LVL 24

Expert Comment

by:shivsa
ID: 9876807
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
 

Author Comment

by:Gnustome
ID: 9876919
I tried the script, but it didn't work.
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9877000
what it did say.
script did not work alone or after reboot it did not run automatically ??
0
 

Author Comment

by:Gnustome
ID: 9877044
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
 
LVL 24

Expert Comment

by:shivsa
ID: 9877137
okie it means it will work alone.
then it should work at reboot time also.
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9877197
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
 

Author Comment

by:Gnustome
ID: 9877264
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 24

Expert Comment

by:shivsa
ID: 9877360
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
 

Author Comment

by:Gnustome
ID: 9877477
I changed the priority to 81, then executed:
/etc/rc3.d/S81hdparm

That worked, but it didn't work when I rebooted.
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9877638
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
 

Author Comment

by:Gnustome
ID: 9877943
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
 

Author Comment

by:Gnustome
ID: 9877985
I am running Debian 2.4.18 and that may be different from other distros.
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9878009
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
 
LVL 24

Expert Comment

by:shivsa
ID: 9878089
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
 
LVL 24

Expert Comment

by:shivsa
ID: 9878110
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
 

Author Comment

by:Gnustome
ID: 9879279
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
 
LVL 24

Accepted Solution

by:
shivsa earned 500 total points
ID: 9879383
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
 

Author Comment

by:Gnustome
ID: 9880427
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
 
LVL 24

Expert Comment

by:shivsa
ID: 9880469
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
 

Author Comment

by:Gnustome
ID: 9881971
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
 
LVL 24

Expert Comment

by:shivsa
ID: 9883045
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
 

Author Comment

by:Gnustome
ID: 9883141
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
 
LVL 24

Expert Comment

by:shivsa
ID: 9883366
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
 
LVL 24

Expert Comment

by:shivsa
ID: 9887225
Dear  Gnustome,

whats up with this, did it work correctly this time.
0
 

Author Comment

by:Gnustome
ID: 9890621
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
 

Author Comment

by:Gnustome
ID: 9895013
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now