You are not logged in.
Hi,
I'm using a laptop with two video card, an ATI 3400 and a intel integrated video card.
Several months ago, I use rc.local to disable the ATI 3400 with the command below:
mount -t debugfs debugfs /sys/kernel/debug
echo OFF > /sys/kernel/debug/vgaswitcheroo/switch
What should I do to enable these commands with systemd?
Thank You!
Offline
Use tmpfiles. See man tmpfiles.d.
Offline
Make a .service file and make sure that systemd calls it.
I may have to CONSOLE you about your usage of ridiculously easy graphical interfaces...
Look ma, no mouse.
Offline
Make a .service file and make sure that systemd calls it.
I have write a video.service file like below
[Unit]
Description=Disable the Discrete Graphics
Requires=sys-kernel-debug.mount
After=sys-kernel-debug.mount
[Service]
Type=oneshot
ExecStart=echo OFF > /sys/kernel/debug/vgaswitcheroo/switch
And the result of "systemctl is-enabled video.service" is static
However, this just does not work. I'm not familiar with systemd.
Buy the way, thank you!
Offline
mount the debugfs via /etc/fstab and use tmpfiles.d to write OFF to /sys/kernel....
The service file does not work because ">" is a bash specific parameter and not interpreted by systemd. You would have to use something like "/bin/bash -c 'echo OFF > ...'". But nevertheless tmpfiles.d is the proper way to do this:
https://wiki.archlinux.org/index.php/Sy … rary_files
edit: also, you probably didn't even enable the service in the first place.
edit2: scratch the fstab idea, falconindy is right, debugfs is mounted by default, you don't have to worry about it.
Last edited by 65kid (2012-10-27 13:42:01)
Offline
nomorewindows wrote:Make a .service file and make sure that systemd calls it.
I have write a video.service file like below
[Unit]
Description=Disable the Discrete Graphics
Requires=sys-kernel-debug.mount
After=sys-kernel-debug.mount[Service]
Type=oneshot
ExecStart=echo OFF > /sys/kernel/debug/vgaswitcheroo/switchAnd the result of "systemctl is-enabled video.service" is static
However, this just does not work. I'm not familiar with systemd.
Buy the way, thank you!
First of all, put this into /etc/systemd/system/. Then add an install section to this unit:
[Install]
WantedBy=multi-user.target
or
[Install]
WantedBy=basic.target
(No idea which one is better). Then run:
# systemctl daemon-reload
systemctl enable video.service
Offline
yumtaoist wrote:nomorewindows wrote:Make a .service file and make sure that systemd calls it.
I have write a video.service file like below
[Unit]
Description=Disable the Discrete Graphics
Requires=sys-kernel-debug.mount
After=sys-kernel-debug.mount[Service]
Type=oneshot
ExecStart=echo OFF > /sys/kernel/debug/vgaswitcheroo/switchAnd the result of "systemctl is-enabled video.service" is static
However, this just does not work. I'm not familiar with systemd.
Buy the way, thank you!
First of all, put this into /etc/systemd/system/. Then add an install section to this unit:
[Install] WantedBy=multi-user.target
or
[Install] WantedBy=basic.target
(No idea which one is better). Then run:
# systemctl daemon-reload # systemctl enable video.service
Last edited by brain0 (2012-10-27 20:09:25)
Offline
In my system, the discrete gpu is card1, so I am able to use the udev rule
KERNEL=="card1", SUBSYSTEM=="drm", RUN+="/usr/bin/radeon"
where radeon is just a script:
#!/bin/sh
echo OFF > /sys/kernel/debug/vgaswitcheroo/switch
You should be able to find which device is your discrete card by trying
# udevadm info -a -p /sys/class/drm/cardX
Last edited by holomorph (2012-11-01 15:46:00)
Offline
Thank You, it works!
I create a file named "/etc/udev/rules.d/98-radeon.rules"
KERNEL=="card1", SUBSYSTEM=="drm", RUN+="/usr/bin/radeon"
and the "/usr/bin/radeon"
#!/bin/sh
echo OFF > /sys/kernel/debug/vgaswitcheroo/switch
then
chmod +x /usr/bin/radeon
Restart, then all works!
Thank you very much!
Please mark this as solved.
In my system, the discrete gpu is card1, so I am able to use the udev rule
KERNEL=="card1", SUBSYSTEM=="drm", RUN+="/usr/bin/radeon"
where radeon is just a script:
#!/bin/sh echo OFF > /sys/kernel/debug/vgaswitcheroo/switch
You should be able to find which device is your discrete card by trying
# udevadm info -a -p /sys/class/drm/cardX
Offline
You're misusing udev for this. Use tmpfiles.d. It's a one-liner:
w /sys/kernel/debug/vgaswitcheroo/switch - - - - OFF
Last edited by adee (2012-11-10 17:00:25)
Offline
You're misusing udev for this.
He is not.
Offline
I have try this, but it does not work, I think perhaps it is because that tmpfiles is excuted earlier than the mounting of debug module
You're misusing udev for this. Use tmpfiles.d. It's a one-liner:
w /sys/kernel/debug/vgaswitcheroo/switch - - - - OFF
Offline
I have try this, but it does not work, I think perhaps it is because that tmpfiles is excuted earlier than the mounting of debug module
adee wrote:You're misusing udev for this. Use tmpfiles.d. It's a one-liner:
w /sys/kernel/debug/vgaswitcheroo/switch - - - - OFF
Yup. I forgot to mention that I needed to put the intel and radeon modules in initramfs for this to work.
Last edited by adee (2012-11-11 17:39:33)
Offline