You are not logged in.

#1 2012-09-05 14:58:16

indianahorst
Member
Registered: 2008-08-23
Posts: 133

[sysvinit, NOT systemd] Commands in rc.local not executed

Hello Community,

I'm using the common sysvinit initscripts, so the following problem should not be related to systemd.

I just made some powersaving settings as advised in https://wiki.archlinux.org/index.php/Powertop in /etc/rc.local, so for example

echo min_power > /sys/class/scsi_host/host0/link_power_management_policy

After rebooting I checked the settings and found...

$ cat /sys/class/scsi_host/host0/link_power_management_policy
max_performance

This is my complete rc.local file:

#!/bin/bash
#
# /etc/rc.local: Local multi-user startup script.
#

# Keep dirty writes in memory
echo 90 > /proc/sys/vm/dirty_ratio

# Keep dirty writes out of cache
echo 5 > /proc/sys/vm/dirty_background_ratio

# VM writeback timeout
echo 6000 > /proc/sys/vm/dirty_writeback_centisecs

#  SATA Active Link Powermanagement 
echo min_power > /sys/class/scsi_host/host0/link_power_management_policy

# set Advanced Power Management feature
hdparm -B 128 /dev/sda

The upper "echo" commands aren't executed, as well as the SATA Active Link Powermanagement.

Strange enough, but the hdparm command seems to be executed. I see the output in the boot messages and in /var/log/boot:

Wed Sep  5 13:11:22 2012: /dev/sda:
Wed Sep  5 13:11:22 2012:  setting Advanced Power Management level to 0x80 (128)
Wed Sep  5 13:11:23 2012:  APM_level	= 128

Does anybody have a clue, why the "echo" commands aren't executed while the hdparm is?

Any hint would really be appreciated!

Offline

#2 2012-09-05 15:27:39

solamir
Member
From: Yaroslavl, Russia
Registered: 2012-09-02
Posts: 26
Website

Re: [sysvinit, NOT systemd] Commands in rc.local not executed

It has long been known.
https://bugs.launchpad.net/ubuntu/+sour … bug/427925
https://bugs.launchpad.net/ubuntu/+sour … bug/431822
In general, it comes down to that not all host controllers support this.
Do other numbers of hosts save settings?

Offline

#3 2012-09-05 15:44:40

indianahorst
Member
Registered: 2008-08-23
Posts: 133

Re: [sysvinit, NOT systemd] Commands in rc.local not executed

Thank you for your answer, but this bug can't be the reason, because if I execute the commands as root after booting, all settings are made:

$ echo 90 > /proc/sys/vm/dirty_ratio
$ cat /proc/sys/vm/dirty_ratio
90

$ echo 5 > /proc/sys/vm/dirty_background_ratio
$ cat /proc/sys/vm/dirty_background_ratio
5

$ echo 6000 > /proc/sys/vm/dirty_writeback_centisecs
$ cat /proc/sys/vm/dirty_writeback_centisecs
6000

$ echo min_power > /sys/class/scsi_host/host0/link_power_management_policy
$ cat /sys/class/scsi_host/host0/link_power_management_policy
min_power

It is just the execution in the boot process in rc.local which is not done.

Offline

#4 2012-09-05 15:52:51

solamir
Member
From: Yaroslavl, Russia
Registered: 2012-09-02
Posts: 26
Website

Re: [sysvinit, NOT systemd] Commands in rc.local not executed

Hm, but what if you try to use сustom hooks?
https://wiki.archlinux.org/index.php/Arch_Boot_Process

Offline

#5 2012-09-05 16:45:44

indianahorst
Member
Registered: 2008-08-23
Posts: 133

Re: [sysvinit, NOT systemd] Commands in rc.local not executed

Okay, I have created a  custom hook script in /etc/rc.d/functions.d/ on the basis of https://wiki.archlinux.org/index.php/Ar … stom_hooks

$ cat /etc/rc.d/functions.d/testingscript 
testingscript() {
    echo 2000 > /proc/sys/vm/dirty_writeback_centisecs
}
add_hook multi_end testingscript

After rebooting, I tried cat /proc/sys/vm/dirty_writeback_centisecs:

 $ cat /proc/sys/vm/dirty_writeback_centisecs
500

It seems that also custom hooks aren't executed... WTF?

Offline

#6 2012-09-05 17:04:22

indianahorst
Member
Registered: 2008-08-23
Posts: 133

Re: [sysvinit, NOT systemd] Commands in rc.local not executed

Okay, the misfunction of  the testingscript above was my mistake, I forgot to chmod +x /etc/rc.d/functions.d/testingscript. After rebooting, I got

$ cat /proc/sys/vm/dirty_writeback_centisecs
2000

But the rc.local issue remains unsolved (yes, rc.local is executable!). Any further hints?

Offline

#7 2012-09-05 17:15:01

progandy
Member
Registered: 2012-05-17
Posts: 5,317

Re: [sysvinit, NOT systemd] Commands in rc.local not executed

Is rc.local executable? Maybe you accidentally removed the flag. Sorry I skipped the paranthesis Also try to echo somethin in e.g. /tmp/testfile where you don't need root permissions. If that works, read one of the proc files and echo the content to the testfile. Then you know that it is at least readable.

Last edited by progandy (2012-09-05 17:44:58)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#8 2012-09-05 17:42:14

solamir
Member
From: Yaroslavl, Russia
Registered: 2012-09-02
Posts: 26
Website

Re: [sysvinit, NOT systemd] Commands in rc.local not executed

indianahorst wrote:

But the rc.local issue remains unsolved (yes, rc.local is executable!). Any further hints?

Good question, indeed! smile
I'm also using the common sysvinit initscripts and check executioning some of these commands.
Many settings of powersaving was reseted to max_performance but simple commands I has tryed (touch; echo "WTF" > /home/.../wtf.txt) was performed.
It means that rc.local is working, but then settings of powersaving are reseted.

I has searched about this question in other forums and saw that people have same problems. However, there is no solution in forums. Maybe the scsi-devices is not ready during script execution?

Last edited by solamir (2012-09-05 17:42:51)

Offline

#9 2012-09-05 19:35:15

solamir
Member
From: Yaroslavl, Russia
Registered: 2012-09-02
Posts: 26
Website

Re: [sysvinit, NOT systemd] Commands in rc.local not executed

I think scsi-devices isn't ready yet true. If put the script

#!/bin/sh

sh -c "echo 'min_power' > /sys/class/scsi_host/host0/link_power_management_policy"

exit 0

in ~/.kde4/Autostart/ and make it executable without password with /etc/sudorc all will work.
You are able use this way. Also maybe you should use laptop-mode-tools, which will switch this settings automatically when power off.

Last edited by solamir (2012-09-05 19:41:45)

Offline

#10 2012-09-05 21:59:13

Leonid.I
Member
From: Aethyr
Registered: 2009-03-22
Posts: 999

Re: [sysvinit, NOT systemd] Commands in rc.local not executed

indianahorst wrote:

Hello Community,

I'm using the common sysvinit initscripts, so the following problem should not be related to systemd.

I just made some powersaving settings as advised in https://wiki.archlinux.org/index.php/Powertop in /etc/rc.local, so for example

echo min_power > /sys/class/scsi_host/host0/link_power_management_policy

After rebooting I checked the settings and found...

$ cat /sys/class/scsi_host/host0/link_power_management_policy
max_performance

This is my complete rc.local file:

#!/bin/bash
#
# /etc/rc.local: Local multi-user startup script.
#

# Keep dirty writes in memory
echo 90 > /proc/sys/vm/dirty_ratio

# Keep dirty writes out of cache
echo 5 > /proc/sys/vm/dirty_background_ratio

# VM writeback timeout
echo 6000 > /proc/sys/vm/dirty_writeback_centisecs

#  SATA Active Link Powermanagement 
echo min_power > /sys/class/scsi_host/host0/link_power_management_policy

# set Advanced Power Management feature
hdparm -B 128 /dev/sda

The upper "echo" commands aren't executed, as well as the SATA Active Link Powermanagement.

Strange enough, but the hdparm command seems to be executed. I see the output in the boot messages and in /var/log/boot:

Wed Sep  5 13:11:22 2012: /dev/sda:
Wed Sep  5 13:11:22 2012:  setting Advanced Power Management level to 0x80 (128)
Wed Sep  5 13:11:23 2012:  APM_level	= 128

Does anybody have a clue, why the "echo" commands aren't executed while the hdparm is?

Any hint would really be appreciated!

What desktop do you use? Specifically, do you run upower? This seems to be related to upower's call to pm-powersave which would turn on high-performance settings when running on AC...

FWIW, here is my rc.local

. /etc/rc.conf
. /etc/rc.d/functions

echo "Entering rc.local"

stat_busy "Setting WiFi powersave"
iw dev wlan0 set power_save on
if [ $? -gt 0 ]; then
	stat_fail
else
	stat_done
fi

stat_busy "Setting CPU and SCSI powersavings"
echo 99 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
for h in /sys/class/scsi_host/host?; do
        if [ -f $h/link_power_management_policy ]; then
                echo "min_power" > $h/link_power_management_policy
        fi
done
stat_done

stat_busy "Remount /dev/shm noexec"
mount -o remount,noexec /dev/shm
if [ $? -gt 0 ]; then
        stat_fail
else
        stat_done
fi

and

$ for h in /sys/class/scsi_host/host?; do cat $h/link_power_management_policy; done
min_power
min_power
min_power
min_power

Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd

Offline

#11 2012-09-06 10:54:53

indianahorst
Member
Registered: 2008-08-23
Posts: 133

Re: [sysvinit, NOT systemd] Commands in rc.local not executed

Leonid.I wrote:

What desktop do you use? Specifically, do you run upower? This seems to be related to upower's call to pm-powersave which would turn on high-performance settings when running on AC...

I use XFCE 4.10 and in the dependencies is upower (in pstree and htop I see running multiple  instances of upowerd).

Thank you for this hint, I think upowerd is to blame. I have written a short script to read one of the proc files immediately after writing my custum value into it and got the correct custom value:

rc.local:

echo 90 > /proc/sys/vm/dirty_ratio
cat /proc/sys/vm/dirty_ratio | while read line; do echo "${line}" > /tmp/dirtyratio ; done

After logging into XFCE and checking the two values I got:

$ cat /tmp/dirtyratio 
90 

BUT

$ cat /proc/sys/vm/dirty_ratio
30

It seems that /etc/rc.local is executed correctly, but upowerd alters the values in /proc after some seconds. I have yet not found a solution, because there is really less information about this crappy upower, but it seems to be connected with dbus.

Last edited by indianahorst (2012-09-06 10:56:40)

Offline

#12 2012-09-06 17:33:03

Leonid.I
Member
From: Aethyr
Registered: 2009-03-22
Posts: 999

Re: [sysvinit, NOT systemd] Commands in rc.local not executed

There are two ways in which you can solve your problem:
1. Alter pm-utils config. Namely, you'll have to disable offending hooks in /usr/lib/pm-utils/power.d. For instance:

$ cat /etc/pm/config.d/00-disable-all-hooks.conf 
HOOK_BLACKLIST="hal-cd-polling journal-commit pcie_aspm sata_alpm wireless intel-audio-powersave laptop-mode readahead sched-powersave xfs_buffer"

2. Disable upower call to pm-utils alltogether. In /etc/Upower/Upower.conf change RunPowersaveCommand from true  (default) to false.

EDIT: By default xfce-session doesn't call upower. on startup, but only on shutdown  You must be using some power applet...

Last edited by Leonid.I (2012-09-06 17:34:24)


Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd

Offline

Board footer

Powered by FluxBB