Page 1 of 1

HDD tweak

Posted: Tue Dec 31, 2013 0:02
by nomko
Hi everybody


I want to try out this tweak foiund on this wiki:
Tune Hard Drive Performance

The hard drive is the slowest compenent of your computer. A little tuning goes a long way for performance.
vim /etc/conf.d/hdparm
Add the following at the bottom
hda_args="-a16 -c1 -k1 -u1 -S0"
cdrom0_args="-c1 -k1 -u1"
Start hdparm during boot
rc-update add hdparm boot
But the last command

Code: Select all

rc-update add hdparm boot
does not work. I get an error message in the temrinal saying this:
[email protected] ~ $ rc-update add hdparm boot
bash: rc-update: opdracht niet gevonden
It's Dutch and the last line translated means:
bash: rc-update: command not found

What should i do?
Thanks!

Re: HDD tweak

Posted: Wed Jan 01, 2014 15:28
by nomko
Just had a ,look in the wiki's and i see two "commands":

systemd
rc-update

If i change rc-update into systemd, will this command work:

Code: Select all

systemd add hdparm boot


Any help would be very much appreciated since i'm a first time Sabayon user here.

Re: HDD tweak

Posted: Wed Jan 01, 2014 17:41
by imaginasys
rc-update is for the old init sytem from system V, you seems to be using systemd.

In systemd, you must first enable the service (to make it start at boot) and then start it.
Here is the 2 commands you should be using instead of rc-update :

systemctl enable hdparm
systemctl start hdparm

for more details see man pages of systemctl.

for a graphic ui install "sys-apps/systemd-ui" and run it with "kdesudo systemadm&" (or gtk equivalent if you're on gnome).

I recommand you to read about systemd :
http://wiki.gentoo.org/wiki/Systemd
http://www.freedesktop.org/wiki/Software/systemd/

Good luck!

Bernard

Re: HDD tweak

Posted: Wed Jan 01, 2014 18:02
by nomko
imaginasys wrote:rc-update is for the old init sytem from system V, you seems to be using systemd.

In systemd, you must first enable the service (to make it start at boot) and then start it.
Here is the 2 commands you should be using instead of rc-update :

systemctl enable hdparm
systemctl start hdparm
This is what i get when using the first command:
[email protected] ~ $ systemctl enable hdparm
Failed to issue method call: Access denied
What does this mean?

imaginasys wrote: for more details see man pages of systemctl.

for a graphic ui install "sys-apps/systemd-ui" and run it with "kdesudo systemadm&" (or gtk equivalent if you're on gnome).

I recommand you to read about systemd :
http://wiki.gentoo.org/wiki/Systemd
http://www.freedesktop.org/wiki/Software/systemd/
I will read those wiki's! It's not that i don't want to learn, but Sabayon is very new to me and i have to forget most commands i used under Mint i find out now.
Thanks again!

Re: HDD tweak

Posted: Wed Jan 01, 2014 19:00
by Fitzcarraldo
nomko wrote:This is what i get when using the first command:
[email protected] ~ $ systemctl enable hdparm
Failed to issue method call: Access denied
What does this mean?
It means you have to be root user to do stuff like that!

Code: Select all

$ su
Password:  <--- Enter the root user's password here.
#
Notice the root user's prompt is a hash sign rather than a dollar sign.

Re: HDD tweak

Posted: Wed Jan 01, 2014 19:10
by nomko
ok, i'll give it a shot now!


And now i get this:
nomko-sabayon141 nomko # systemctl enable hdparm
Failed to issue method call: No such file or directory
nomko-sabayon141 nomko #
What goes wrong here? Thanks again!

Re: HDD tweak

Posted: Wed Jan 01, 2014 22:10
by imaginasys
It's because you don't have any systemd service for hdparm.

To see all service (as root) try : # systemctl -t service -a

If you don't see hdparm anywhere then it doesn't exist.
In fact hdparm service is created but for the old init system V.
There is a script file : /etc/init.d/hdparm
Installed by hdparm:

Code: Select all

[email protected] /etc $ equo query files sys-apps/hdparm
╠  @@ Files Search
╠  ### /etc
╠  ### /etc/conf.d
╠  ### /etc/conf.d/hdparm
╠  ### /etc/init.d
╠  ### /etc/init.d/hdparm
╠  ### /sbin
╠  ### /sbin/hdparm
╠  ### /sbin/idectl
<...snip...>
So the problem seems to be caused by hdparm wich is not adapted for systemd.

On the following post : http://lists.freedesktop.org/archives/s ... 05600.html
Mr. Leonardt Poettering suggest that we should use a udev rule for setting hdparms. This is viewed as the "systemd" way of doing thoses things since it would not be distro specific.

How about something like this. Use udev to determine if a given disk is rotational or not, and then run that hdparm command on the rotational ones.

So make a file /etc/udev/rules.d/75-hdparm.rules that includes:

Code: Select all

ACTION=="add", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", RUN+="/sbin/hdparm -B 254 /dev/$kernel" 
I figure that this way you are not unecessarily changing the setting on SSDs.

Change the hdparm parameters to whatever you need (but be very carefull... wrong settings can destroy your disk).

For different settings when running on AC / battery, You could do it via a simple udev rule also :

/etc/udev/rules.d/98-apmsettings.rules:

Code: Select all

SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="/usr/bin/hdparm -B 128 /dev/sda"
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="/usr/bin/hdparm -B 254 /dev/sda"
This would set apm to 254 when the laptop is plugged in and respectively 128 when unplugged. Also, it should always work, even after resuming from suspend.

In my point of view these udev rules should be added when you install hdparm. So you don't even need to find out a way to use it at boot...

I hope it helps!

Regards,
Bernard

Re: HDD tweak

Posted: Thu Jan 02, 2014 23:59
by sabayonino
you're running all comands as user .... ($)

use "sudo" or log as root (#)

[edit] oppss ... i missed Fitz post viewtopic.php?f=56&t=31229&p=168502#p168455 :mrgreen:

Re: HDD tweak

Posted: Sat Jan 04, 2014 13:54
by batvink
You could use Cron for that, or in our case: systemd-timers.
But that would be a workaround, not a solution.

udev rules are run when power is connected/disconnected but not after suspending/resuming.
You can create a systemd unit that will run both after boot and after resuming from suspend.

As root:

Code: Select all

nano -w /etc/systemd/system/hdparm.service
with following content:

Code: Select all

[Unit]
Description=HD params
After=suspend.target
After=hibernate.target
 
[Service]
Type=oneshot
ExecStart=/sbin/hdparm -a16 -c1 -k1 -u1 -S0 /dev/sda
ExecStart=/sbin/hdparm -c1 -k1 -u1 /dev/sr0

[Install]
WantedBy=suspend.target basic.target
WantedBy=hibernate.target
Then, enable and start the service:

Code: Select all

systemctl enable hdparm.service

Code: Select all

systemctl daemon-reload

Or, even more simple., you could create a script called: hdparm_set in:
/usr/lib/systemd/system-sleep/
with following content:

Code: Select all

#!/bin/sh
hdparm -a16 -c1 -k1 -u1 -S0 /dev/sda
hdparm -c1 -k1 -u1 /dev/sr0
save the script, and make it executable:
chmod +x /usr/lib/systemd/system-sleep/hdparm_set