Sunday, November 28, 2010

Frozen Linux and Secure Files System Recovery with Magic Keys

Hi Friends,

Magic system recovery keys are combination of key hits that we can perform and kernel responds on priority. Before using magic keys we need to enable CONFIG_MAGIC_SYSRQ, by default sysreq compiled file (/proc/sys/kernel/sysrq) contains 1 that enables every possible sysreq.
 To customize this file we can use command :

echo "integer" >/proc/sys/kernel/sysrq 
 
integer 0 disable sysreq
integer 1 enables all functions of sysreq
Using:
echo command > /proc/sysrq-trigger 
 
command:
b : immediate reboot without unmunting.
c : perform system crash by null pointer de-referencing.
d : shows all locks that are held.
Rebooting your system due to freeze state (hanged state) may 
temper your file system.We can use magic key controls to handle
the situation that was initially used for kernel debugging.
Securely Restarting Hanged System:
Hit ALT+PrintScreen 
 
While holding the above keys press following given below 
keys one after other (press and hold for 3-4 seconds)
 
For Reboot: 
R S E I U B 
For Shut Down:
R S E I U O
 
What it does? : 
1. It takes control of keyboard back from X
2. Sends SIGTERM to all processes, allowing then to terminate racefully.
3. SIGKILL to force all processes terminate immediately.
4. Flushes data to disk.
5. Remounts or Unmounts all file systems.
 
For more details please refer:
http://en.wikipedia.org/wiki/Magic_SysRq_key