Some Linux distributions have kernel.sysrq=16 which means only Sysrq+s (sync) is allowed. As an example: Fedora (25 and 28) has it set as such in /usr/lib/sysctl.d/50-default.conf

I had to create a file as /etc/sysctl.d/95-sysrq.conf where I manually set kernel.sysrq=1 so it's available as soon as possible(but possibly not soon enough depending on situation):

$ grep -nHi sysrq /usr/lib/sysctl.d/* /etc/sysctl.d/*
/usr/lib/sysctl.d/50-default.conf:16:# Use kernel.sysrq = 1 to allow all keys.
/usr/lib/sysctl.d/50-default.conf:17:# See http://fedoraproject.org/wiki/QA/Sysrq for a list of values and keys.
/usr/lib/sysctl.d/50-default.conf:18:kernel.sysrq = 16

Is there a way to enable Sysrq from early boot, possibly also ignoring any setting for kernel.sysrq ? for example adding a kernel boot parameter (eg. cat /proc/cmdline for current ones) such as from the Grub boot menu (or in xen.cfg's kernel= line).


There is kernel boot parameter sysrq_always_enabled according to the doc:

            Ignore sysrq setting - this boot parameter will
            neutralize any effect of /proc/sys/kernel/sysrq.
            Useful for debugging.

I have tested Sysrq to work(eg. help,sync) even when kernel.sysctl=0 (so it's just as the doc above says), if I add kernel boot argument sysrq_always_enabled (note: it doesn't have to be sysrq_always_enabled=1).
(to double check, I've also tested Sysrq to NOT work when kernel.sysctl=0 and sysrq_always_enabled is NOT present in /proc/cmdline)
Source code confirms it too.

Note: /proc/sys/kernel/sysrq is another way to read/write kernel.sysrq

For more info on sysrq: https://www.kernel.org/doc/html/v4.15/admin-guide/sysrq.html
(though sysrq_always_enabled is not mentioned there, but it is here)

EDIT: When sysrq_always_enabled is in effect, there is a dmesg line:

[    0.000000] sysrq: sysrq always enabled.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.