Novell Cool Solutions

Magic Sysrq — your emergency link to the kernel



By:

October 23, 2008 8:31 am

Reads:8,258

Comments:0

Score:Unrated

Print/PDF

Magic SysRq — your emergency link to the kernel

With most Linux distributions you do have emergency access to the kernel should your machine freeze or become unresponsive to normal keyboard input. This then can allow for a safe reboot. The first thing to check is that your compiled kernel has support for Magic SysRq. To do this check out the config file in the /boot directory of your server or desktop machine. The OS I am working with is SUSE Enterprise Server 10 SP1. The kernel configuration file will relate to the running kernel. As I look at this file it is named:

/boot/config-2.6.16.46-0.12-default

Now that is a bit of a mouthful and you may find that you have many configuration files in the boot directory that represent kernels you have or have had on your system. So try this:

ls /boot/config-$(uname -r) 

uname -r displays the current kernel version, $() returns the output of any command that is run from within the brackets.

Once you have located the kernel configuration file you then need to verify that support for MagicSysRq is in your kernel:

grep MAGIC_SYSRQ  /boot/config-$(uname -r) 

Hopefully you will see something similar to this:

CONFIG_MAGIC_SYSRQ=y 

If you don’t have support you will need to use another kernel with the required support . On SUSE the support is built in to the kernel, however, you need to turn enable it as it is turned off by default..

cat /proc/sys/kernel/sysrq

This will have a value of 1 or 0
• 0 = off
• 1 = on

To turn it on then:

echo 1 > /proc/sys/kernel/sysrq 

This will turn it until the next reboot. If you need it set permanently you will need to edit files or use the SUSE YaST tool.

From the YaST Local Security Tool you can turn on support for Magic SysRq. This actually writes to the file:

/etc/sysconfig/sysctl
ENABLE_SYSRQ=”yes” 

This line should be yes as above to permanently turn on Sysrq. This will have effect after a server reboot but you can turn it on immediately as described on the previously.

  • Using YaST will set the file and current running value.
  • Other systems use the line kernel.sysrq=1 in /etc/sysctl.conf

Ok, so we have Magic SysRq support in the kernel and we have turned it on. Now to use it.
( Well of course you will hope that you don’t have to use it )

Using the Sysrq key on the keyboard it is possible to send signals directly to the kernel. In the event of a system freeze we can

  • sync all disks (flush buffers to disk),
  • remount file-systems as read-only and
  • reboot.

Preserving the file-system’s integrity during the emergency reboot. The key sequences are best pressed from you system console or Alt+F10 screen. This way you will see the messages passed back from the kernel.

Hold down the ALT and SysRq Key and then the option key that you require. Consider BUSIER but spelled backwards:

R E I S U B

  • ALT + SysRq + R
    Captures the keyboard from X server
  • ALT + SysRq + E

    SIGTERM to all processes except init
  • ALT + SysRq + I

    SIGKILL to all processes except init
  • ALT + SysRq + S

    Sync all filesystems ( flush write buffers )
  • ALT + SysRq + U

    Remount all filesystem as Read-only
  • ALT + SysRq + B

    Reboot

See /usr/src/linux/Documentation/sysreq.txt

0 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 5 (0 votes, average: 0.00 out of 5)
You need to be a registered member to rate this post.
Loading...Loading...

Tags:
Categories: Uncategorized

0

Disclaimer: This content is not supported by Novell. It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test it thoroughly before using it in a production environment.

Comment

RSS