Saving sysrq value across reboot

I’m not sure if this is even strictly related to Qubes OS but how do I save the sysrq value in

/proc/sys/kernel/sysrq

I would like to be able to turn off and restart my computer immediately with the sysrq key but it’s disabled by default in Qubes OS.

And also, would it cause any harm other than what it would do to any other distro?

After setting the value to 128 and rebooting it goes back to 16, which doesn’t support reboot/power off with the key.

It isnt Qubes specific.
Set the value in /usr/lib/sysctl.d/50-default.conf, kernel.sysrq key.

2 Likes

User custom dom0 sysrq value should go in the /etc/sysctl.d/ directory for overriding the kernel.sysrq = 16 from the /usr/lib/sysctl.d/50-default.conf file.

Example for reboot/poweroff/read-only/sync shortcuts:

[user@dom0 ~]$ cat /etc/sysctl.d/99-sysrq.conf
# System Request functionality of the kernel
#
# See https://www.kernel.org/doc/html/latest/admin-guide/sysrq.html for a list
# of values and keys.
# 176=128((r)eboot/p(o)weroff) + 32 ((u)mount) + 16 ((s)ync)
kernel.sysrq = 176

See the Linux kernel sysrq documentation for all the function shortcuts and the function masks:
https://docs.kernel.org/admin-guide/sysrq.html