You are not logged in.

#1 2012-11-01 13:41:18

caasi
Member
Registered: 2012-03-21
Posts: 44
Website

rc-local.service keeps failing after one time success

Actually it's quite weird, every time rc-local.service was enable successfully with boot but then it keeps failing. However, once I modify /etc/systemd /system/rc-local.service( even something that really doesn't matter ), it will be enabled successfully again. but only ONCE each time.

[Unit]
Description=/etc/rc.local compatibility

[Service]
Type=oneshot
ExecStart=/etc/rc.local
TimeoutSec=0
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Offline

#2 2012-11-01 14:14:53

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: rc-local.service keeps failing after one time success

You really should get rid of this. Post the contents of /etc/rc.local.

Last edited by falconindy (2012-11-01 14:20:00)

Offline

#3 2012-11-01 15:18:39

caasi
Member
Registered: 2012-03-21
Posts: 44
Website

Re: rc-local.service keeps failing after one time success

This is my rc.local:

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

# Solve the load/unload problem
hdparm -B 254 /dev/sda
# switch to the intergrated graphics card
echo IGD > /sys/kernel/debug/vgaswitcheroo/switch
# turn off the ati card
echo OFF > /sys/kernel/debug/vgaswitcheroo/switch
# save the brightness config
echo 3 > /sys/class/backlight/acpi_video0/brightness

And maybe tmpfiles.d is recommended for the three echo thing. but when I created the three files in /etc/tmpfiles.d/ and run sudo systemd-tmpfiles --create filename, then i boot, it doesn't work at all.

Offline

#4 2012-11-01 15:20:19

caasi
Member
Registered: 2012-03-21
Posts: 44
Website

Re: rc-local.service keeps failing after one time success

I mean i just remove rc.local, disable rc-local.service and add the tmpfiles.d/filename, but the tmpfiles.d does not work.
Any idea?

Offline

#5 2012-11-01 15:37:46

Stebalien
Member
Registered: 2010-04-27
Posts: 1,239
Website

Re: rc-local.service keeps failing after one time success

Make sure that 'filename' ends in '.conf'. If the configs still don't work, please post them.
Also, what do you mean by failing? Is there any relevant journal output?


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C

Offline

#6 2012-11-01 16:11:08

caasi
Member
Registered: 2012-03-21
Posts: 44
Website

Re: rc-local.service keeps failing after one time success

yes, 'filename' ends in '.conf' but it does not work at all.
or... any other solution for my `rc.local`?
`failing` means 'rc-local.service Active: failed `

Offline

#7 2012-11-01 16:26:02

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: rc-local.service keeps failing after one time success

All of those things can be done with udev rules.  I had a Momentus XT, which I now no longer have in my system, but my old rule is still there.  It is as follows:

ACTION=="add", SUBSYSTEM=="block", ATTRS{model}=="ST95005620AS", RUN+="/sbin/hdparm -B 247 /dev/$kernel"

You could also do something like this to apply it to all rotational disks

ACTION=="add", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", RUN+="/sbin/hdparm -B 254 /dev/$kernel"

As far as the stuff in /sys, use udevadm to get stuff to put in your rule to identify it.  So something like

$ udevadm info -a -p /sys/kernel/debug/vgaswiteroo 

I have also used a rule for my backlight setting on boot.  To find stuff, once again use the udevadm

$ udevadm info -a -p /sys/class/backlight/acpi_video0 

My resulting backlight rule is:

ACTION=="add", KERNEL=="acpi_video0", SUBSYSTEM=="backlight", SUBSYSTEMS=="pci", DRIVERS=="i915", ATTR{brightness}="2"

For more info on writing udev rules see http://www.reactivated.net/writing_udev_rules.html but when you get to the part about the udev commands, those no longer apply, as they have now been replaced by the udevadm commands listed above.  The commands are mostly correct, just instead of udevinfo, it is udevadm.

I hope this helps!

Last edited by WonderWoofy (2012-11-02 02:59:59)

Offline

#8 2012-11-02 01:45:54

caasi
Member
Registered: 2012-03-21
Posts: 44
Website

Re: rc-local.service keeps failing after one time success

I just tried udev but unfortunately it still does not work.
My `/etc/udev/rules.d/hybrid-graphics.rules` is as follow:

ACTION="add", KERNEL=="vgaswitcheroo", RUN+="echo OFF > /sys/kernel/debug/vgaswitcheroo/switch"

Anyway, thank yo.u

Offline

#9 2012-11-02 02:12:55

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: rc-local.service keeps failing after one time success

I think you need ACTION=="add" also, I would not try and actually run a command, but rather just have it change the contents of the file.  What is the output of

$ udevadm -a -p /sys/kernel/debug/vgaswitcheroo 

Last edited by WonderWoofy (2012-11-02 02:15:26)

Offline

#10 2012-11-02 02:32:47

caasi
Member
Registered: 2012-03-21
Posts: 44
Website

Re: rc-local.service keeps failing after one time success

The output of `udevadm info -a -p /sys/kernel/debug/vgaswitcheroo` is as follow:

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/kernel/debug/vgaswitcheroo':
    KERNEL=="vgaswitcheroo"
    SUBSYSTEM==""
    DRIVER==""

  looking at parent device '/kernel/debug':
    KERNELS=="debug"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{sched_features}=="GENTLE_FAIR_SLEEPERS START_DEBIT AFFINE_WAKEUPS NO_NEXT_BUDDY LAST_BUDDY CACHE_HOT_BUDDY NO_ARCH_POWER NO_HRTICK NO_DOUBLE_TICK LB_BIAS OWNER_SPIN NONTASK_POWER TTWU_QUEUE NO_FORCE_SD_OVERLAP RT_RUNTIME_SHARE NO_LB_MIN "
    ATTRS{gpio}==""

I'm trying it again with '==' (really a stupid mistake)
[EDIT]Sorry, it still doesn't work.

Last edited by caasi (2012-11-02 02:39:07)

Offline

#11 2012-11-02 03:01:54

caasi
Member
Registered: 2012-03-21
Posts: 44
Website

Re: rc-local.service keeps failing after one time success

And I tried @holomorph 's KERNEL=="card1", SUBSYSTEM=="drm", WAIT_FOR="/sys/kernel/debug/vgaswitcheroo/switch", RUN+="echo OFF > /sys/kernel/debug/vgaswitcheroo/switch" (actually I tried both with or without WAIT_FOR) but it just does not work as expected. Log is as follow:

systemd-udevd[368]: failed to execute '/usr/lib/udev/echo' 'echo OFF > /sys/kernel/debug/vgaswitcheroo/switch': No such file or directory

Offline

#12 2012-11-02 03:12:35

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: rc-local.service keeps failing after one time success

Seeing as the 'switch' file is not showing up as an ATTR, I am kind of at a loss here.  At this point, personally I might just switch tactics, and have the command run as a service.  Just a simple oneshot and probably requiring an AFTER=<something well into the boot> and wanted by the multi-user.target... I don't have this hardware, so I am unable to really help you any further.  Sorry.  Maybe someone else can step in here who actually has switching graphics?

Offline

#13 2012-11-02 03:22:30

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: rc-local.service keeps failing after one time success

RUN does not give you a shell (so your redirection doesn't work), and the semantics in the manpage note that if you don't provide an absolute path, it assumes the binary is in udev's runtime dir -- aka /usr/lib/udev.

This isn't suitable for a udev rule -- many people have done this using tmpfiles.d.

Last edited by falconindy (2012-11-02 03:22:57)

Offline

#14 2012-11-02 03:49:41

caasi
Member
Registered: 2012-03-21
Posts: 44
Website

Re: rc-local.service keeps failing after one time success

@falconindy Thank you. Yes, I find that `echo` is not found in my udev rules. But I tried tmpfiles.d yesterday and it does not work. So I focus on udev now.
How to solve it with tmpfiles.d? any related posts?

Offline

#15 2012-11-02 13:01:25

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: rc-local.service keeps failing after one time success

Again, udev is the wrong tool, and there's plenty of people who've used tmpfiles. If something such as the below doesn't do what you want, then you need to be more specific than "it does not work"

/etc/tmpfiles.d/swtcheroo.conf wrote:
w /sys/kernel/debug/vgaswitcheroo/switch - - - - OFF

Offline

Board footer

Powered by FluxBB