Troubleshoot your Linux instance using SysRq
The System Request (SysRq) key, which is sometimes referred to as "magic SysRq", can be
used to directly send the kernel a command, outside of a shell, and the kernel will respond,
regardless of what the kernel is doing. For example, if the instance has stopped responding,
you can use the SysRq key to tell the kernel to crash or reboot. For more information, see
Magic SysRq key
Prerequisites
Before you can configure and use SysRq, you must grant access to the serial console. For more information, see Configure access to the EC2 Serial Console.
Configure SysRq
To configure SysRq, you enable the SysRq commands for the current boot cycle. To make the configuration persistent, you can also enable the SysRq commands for subsequent boots.
To enable all SysRq commands for the current boot cycle
-
Connect to your instance.
-
Run the following command.
[ec2-user ~]$
sudo sysctl -w kernel.sysrq=1
Note This setting will clear on the next reboot.
To enable all SysRq commands for subsequent boots
-
Create the file
/etc/sysctl.d/99-sysrq.conf
and open it in your favorite editor.[ec2-user ~]$
sudo vi /etc/sysctl.d/99-sysrq.conf
-
Add the following line.
kernel.sysrq=1
-
Reboot the instance to apply the changes.
[ec2-user ~]$
sudo reboot
-
At the
login
prompt, enter the user name of the password-based user that you set up previously, and then press Enter. -
At the
Password
prompt, enter the password, and then press Enter.
Use SysRq
You can use SysRq commands in the EC2 Serial Console browser-based client or in an SSH client. The command to send a break request is different for each client.
To use SysRq, choose one of the following procedures based on the client that you are using.