http://www.cyberciti.biz/tips/reboot-or-halt-linux-system-in-emergency.html

Linux kernel includes magic system request keys. It was originally developed for kernel hackers. However, you can use this hack to reboot, shutdown or halt computer safely (remember safe reboot/shutdown == flush filesystem buffers and unmount file system and then reboot so that data loss can be avoided).

This is quite useful when Linux based system is not available after boot or after a X server crashed ( svgalib program crashes) or no display on screen. Sysrq key combo forces the kernel to respond it regardless of whatever else it is doing, unless it is completely locked up (dead).

Using further extension to iptables called ipt_sysrq (new iptables target), which allows you to do the same as the magic sysrq key on a keyboard does, but over the network. So if your network server is not responding you can still reboot it. Please note that Magic SysRq support need to be compiled in your kernel. You need to say "yes" to 'Magic SysRq key (CONFIG_MAGIC_SYSRQ)' when configuring the kernel. I'm assuming that you have Magic SysRq key' support is compiled in your kernel.

Enable sysrq keys

By default it is not enabled on many Linux distributions. Add or modify following line (as soon as new Linux system installed) /etc/sysctl.conf:
# vi /etc/sysctl.conf
Append following config directive:
kernel.sysrq=1
Save and close the file. Reload settings:
# sysctl -p

Save and close the file and reboot system to take effect

How do I use the magic SysRq keys in emergency?

You need to use following key combination in order to reboot/halt/sync file system etc:
ALT+SysRq+COMMAND-KEY

The 'SysRq' key is also known as the 'Print Screen' key. COMMAND-KEY can be any one of the following (all keys need to hit simultaneously) :

  • 'b' : Will immediately reboot the system without syncing or unmounting your disks.
  • 'o' : Will shutdown your system off (if configured and supported).
  • 's': Will attempt to sync all mounted filesystems.
  • 'u' : Will attempt to remount all mounted filesystems read-only.
  • 'e' : Send a SIGTERM to all processes, except for init.
  • 'h': Show help, indeed this the one you need to remember.

So whey you need to tell your Linux computer to reboot or when your X server is crashed or you don't see anything going across the screen then just press:

ALT+SysRQ+s : (Press and hold down ALT, then SysRQ (Print Screen) key and press 's') -Will try to syn all mounted system

ALT+SysRQ+r : (Press and hold down ALT, then SysRQ (Print Screen) key and press 'r') -Will reboot the system.

If you wish to shutdown the system instead of reboot then press following key combination:
ALT+SysRQ+o

ipt_sysrq is a new iptables target that allows you to do the same as the magic sysrq key on a keyboard does, but over the network. Sometimes a remote server hangs and only responds to icmp echo request (ping). Every administrator of such machine is very unhappy because (s)he must go there and press the reset button. It takes a long time and it's inconvenient. So use the Network Magic SysRq and you will be able to do more than just pressing a reset button. You can remotely sync disks, remount them read-only, then do a reboot. And everything comfortably and only in a few seconds. Please see Marek Zelem page to enableIP Tables network magic SysRq function.

For more information read official Documentation for sysrq.c version 1.15 stored in /usr/src/linux/Documentation/sysrq.txt and read man page of sysctl, sysctl.conf.

最新文章

  1. 梅须逊雪三分白,雪却输梅一段香——CSS动画与JavaScript动画
  2. 【Java并发编程实战】-----“J.U.C”:ReentrantLock之一简介
  3. MySQL内核:InnoDB存储引擎 卷1
  4. sublime text2 解决中文乱码
  5. cordova ios --->OC 调用 js (一)
  6. 14、NFC技术:使用Android Beam技术传输文本
  7. Android日期时间格式国际化
  8. C++模板编程
  9. Tcl语言笔记之一
  10. JVM 设置
  11. [Angular Tutorial] 5-Filtering Repeaters
  12. 备份Rhythmbox播放器的曲目和播放列表信息
  13. MySQL忘记密码后找回密码
  14. MyBatis-Plus 3.0.3 Sql注入器添加,即全局配置Sql注入器,sqlInjector改写
  15. Python入门:内置函数
  16. bzoj4566 找相同字符
  17. Java基础 变量的作用域
  18. Java中try、finally语句中有return时的执行情况 [转]
  19. java12小时制的时间转换为24小时制
  20. 修改CentOS的IP地址

热门文章

  1. 2017 GDS 全球域名大会7月7日举行
  2. vue自定义事件 子组件把数据传出去
  3. Keystone集成LDAP
  4. java:jsp: 一个简单的自定义标签 tld
  5. ural 2020 Traffic Jam in Flower Town(模拟)
  6. mysql数据库优化。(强力推荐)
  7. Android Studio 开始运行错误
  8. Reinforcement Learning Q-learning 算法学习-1
  9. scrapy入门实践1
  10. kong插件官方文档翻译