Linux 会死机么?我可以很肯定地说,会!要让 Linux 死机很容易,但难的是在死机以后如何安全的让他摆脱死机状态,本文讲述如何从 linux 的死机状态中挣脱出来。
Linux 死机有很多种情况,最常见的是系统负载过高导致的。如上次介绍的 fork 炸弹就是这个原理,此外还可以运行内存耗用极大的程序(如虚拟机),也会迅速提升系统负载。由于系统负载过高导致的卡死,一定是解决的越快越好!此时必须记住的是,不能再试图依赖任何图形界面的东西,如 Gnome 的系统监视器(这是我从 Windows 遗留下来的愚昧习惯……),这只会继续加重这种卡死的局面。那怎么办?
不要怕,Linux 最初就是不需要图形界面的,因为有一个很强大的文字界面。按 Ctrl-Alt-F1(F1-F6 一般来说都可以),然后等一会儿,就会切换到 tty,也就是所谓的文字界面。这个时候需要用用户名密码登入。注意,可能键盘输入的速度比较慢,不过应该还是可以忍受的。下面在提示符后面输入 top 回车,这时会看到一张动态的表,上面列出了耗用资源最多的进程。观察它刷新一两次,按q退出,然后输入 kill
除了上面这种情况外,一些底层软件的 bug 也可能导致一些奇怪的死机问题。我某位同学近日就因为莫名其妙的死机强制重启把 ext4 的分区给伤了。(最后是 sysreccd 修复了,貌似是分区表部分损坏)据其说,死机是键鼠均无反应。一般来说,系统负载高导致的死机,在可怕键盘也会有反应,有人说如果死机到键盘无响应“负载 都无限大了”,亦有人说这可能是 X Server 与驱动配合有问题导致的。不过我们考虑一下遇到这种情况怎么办?
OK,这是今天才学到的方法,叫做 reisub,这个方法可以在各种情况下安全地重启计算机。大家在键盘上找,可以找到一个叫做“Sys Rq”的键,在台机的键盘上通常与 Prt Sc 共键,在笔记本可能在其他位置,如 Delete。以台机为例,要使用这种方法需要按住 Alt-Print(Sys Rq),然后依次按下 reisub 这几个键,按完 b 系统就会重启。
下面解释一下这个方法:其实 Sys Rq 是一种叫做系统请求的东西,按住 Alt-Print 的时候就相当于按住了 Sys Rq 键,这个时候输入的一切都会直接由 Linux 内核来处理,它可以进行许多低级操作。这个时候 reisub 中的每一个字母都是一个独立操作,他们分别表示:
unRaw 将键盘控制从 X Server 那里抢回来 tErminate 给所有进程发送 SIGTERM 信号,让他们自己解决善后 kIll 给所有进程发送 SIGKILL 信号,强制他们马上关闭 Sync 将所有数据同步至磁盘 Unmount 将所有分区挂载为只读模式 reBoot 重启
这6个字母的顺序是不可以记错的。那怎么记呢?这里提供一个个人认为比较好的方法:单词 busier(busy 的比较级,更忙)倒过来就是了。
基本上就这样了,Linux 的死机本来就不多见,现在见了也可以安全解决,多好~
2009年8月21日 23:09
前半部分关于TTY,之前也了解。
后半部分,关于reisub部分,学习了!TKS。。。
2009年8月21日 23:39
死机?不合适吧。真死机了除了hard reset还能干什么?叫失去响应或者无响应更合适吧?
另外服务器一般都是远程操作的,sysrq怎么用呢?
X挂掉,通常psuedo console就能搞定。通常大家也会开ssh,绝大多数情况下都能连上去杀进程,做重启前的收尾比如sync来commit。
关于sysrq,通常RHEL/OEL等Enterprise Linux默认都是关闭的需要事先开启才可以用。不过还是学习一下sysrq这个东西,从没用过,囧。
cat /proc/sys/kernel/sysrq,看了手头的几个桌面发行版本,只有Ubuntu默认是开的,Arch是关闭的。
BTW: 不知道是不支持Chrome还是我多次提交了,如果是多次,保留我最后一个comment吧,不好意思;-)
2009年8月22日 00:32
@Terry:
对于桌面用户而言,当桌面僵死时,用这个来搞一下,还是很方便的。
2009年8月22日 02:59
reisub这么好的方法今天才知道,谢谢博主了!
2009年8月22日 03:34
这个必须顶啊... 特别是刚从win转过来的用户, 碰到失去响应的情况真是完全束手无策的..
2009年8月22日 03:47
top后直接按k,然后提示输入pid...再提示kill级别...一般选8
一样达到kill -8 pid的效果
XD
2009年8月23日 21:47
linux强制reset有很大可能会坏分区。我都发生了二次了。
2009年8月24日 04:03
@peigen:
那个号码不是级别吧,应该是表示发送的信号的编号,8是表示进程出现浮点数异常,也是强制结束的
2009年8月24日 05:01
楼上正解..."级别"只是通用解释罢了...
2009年8月25日 05:27
噢,键盘和鼠标失去相应也可以busier吗?
thanks a lot.
记下来先
2009年8月25日 05:49
@tlhl28:
一般来说是没有问题的
2009年9月26日 22:57
在键盘失去响应的情况下,我从另一台电脑用ssh登录后然后reboot。
2009年10月02日 18:43
恕我愚钝
Alt-Print和SysRq是一个键吗?
2009年10月20日 00:11
受教了
2009年11月04日 01:43
挺有意思的
2020年12月28日 00:22
whoah this blog is magnificent i love reading your posts. Keep up the great work! You know, lots of people are looking around for this info, you could help them greatly. Animation de Mariage
2021年1月17日 19:47
Hiya, I’m really glad I’ve found this information. Nowadays bloggers publish just about gossips and net and this is actually irritating. A good blog with interesting content, this is what I need. Thank you for keeping this website, I’ll be visiting it. Do you do newsletters? Can not find it.
2021年2月17日 00:27
I don’t usually comment but I gotta say thankyou for the post on this amazing one : D. american traveler magazine
2021年2月22日 21:09
I never realized that fr.altoprotectpdf.com = offered types of assistance due to which I can change over my PDF reports. I'm glad to hear this as this will make my life simpler as now I can deal with my archives quicker.
2021年4月06日 21:52
Many thanks picking the correct to go about this in turn, Personally i think really measurements along with really enjoy researching a little more about the idea market. Assuming feasible, since realise mastery, on earth would you intellect adding to ones own blogging site by way of additional information? This is very useful for us.
2021年4月24日 20:15
Very good piece of writing! Thought about celebrated most of the following. I’m hoping to share increased from your business. Book that you’ve fine imminent and so eye sight. What i’m seriously satisfied utilizing this type of specifics. Monthly Income Review
2021年5月16日 21:34
What your saying is fully true. I know that everybody have to say the exact same matter, but I just consider that you put it in a way that everyone can understand. I also love the photographs you set in the following. They match so properly with what youre attempting to say. Im positive youll reach so many men and women with what youve got to say.
2021年5月26日 13:35
Your blog is one of the better blogs I’ve came across in months. Thank you for your posts and all the best with your work and blog. Looking forward to reading new entries!
2021年6月27日 16:52
An intriguing discussion may be worth comment. I believe that you can write regarding this topic, it will not be a taboo subject but usually people are insufficient to talk on such topics. To the next. Cheers The Simplest Baccarat Strategy
2021年6月29日 18:45
Thanks for making the effort to line all this out for us. This kind of post was in fact quite helpful in my opinion. Slotxo
2021年7月01日 18:37
I’m impressed, I must say. Actually rarely can i encounter a blog that’s both educative and entertaining, and let me tell you, you could have hit the nail to the head. Your concept is outstanding; the thing is an issue that inadequate consumers are speaking intelligently about. We’re very happy which i came across this inside my search for something concerning this. How to Gain Baccarat
2021年7月11日 22:13
You should join in a tournament first of the greatest blogs on the web. I will recommend this web site! read more
2021年9月28日 21:59
Students can get the TN 12th Model Question Paper 2022 with Solutions in PDF format from the links provided on this website. (+2) HSC Regular and private students can use these Sample Papers to prepare for their exams. Students must register for the Public Exam 2022. TN +2 Question Paper If you are one of the students who has registered as a Regular or Private Student, it is recommended that you download these Tamil Nadu Board Plus Two Sample Paper 2022 and prepare all subjects. Model papers are a valuable resource provided by the recognised educational board.
2023年1月15日 08:28
敬启者:个人小网站希望大家多多支持 感谢您对我们热心的支持 f88tw┃华歌尔┃I appreciate your kind assistance.
https://mypaper.pchome.com.tw/f88tw
f88tw|修坟|修墓|新竹|桃园|苗栗|捡骨|拾骨|发票
https://mypaper.pchome.com.tw/f88tw/post/1370781143
https://mypaper.m.pchome.com.tw/f88tw/post/1370781143
2023年4月30日 03:57
First of all, there are many cases where the capital power is not strong and the server security is not safe. In particular, in the case of a new site, 먹튀사이트 a relatively cheap server is used because it is very weak internally and the maintenance cost of the server is very expensive.
2023年5月01日 23:06
当Linux操作系统死机时,您可以尝试以下步骤来解决问题:
重启系统:首先,尝试通过按下Ctrl+Alt+Delete组合键来尝试重新启动系统。如果系统未响应,请按住电源键强制关闭计算机,然后重新启动。
检查硬件:死机可能是由于硬件问题引起的,如内存损坏、硬盘故障等。您可以通过检查硬件连接和运行内存测试程序等方式来检查硬件问题。
2023年5月02日 19:59
Robinjack 说: 2021年7月01日 18:37 I’m impressed, I must say. Actually rarely can i encounter a blog that’s both educative and entertaining,online team builders work from home and let me tell you, you could have hit the nail to the head. Your concept is outstanding; the thing is an issue that inadequate consumers are speaking intelligently about.