天天看點

linux關機重新開機六種方法(sysrq shutdown halt init ipmi poweroff)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

<code>我的部落格已遷移到xdoujiang.com請去那邊和我交流</code>

<code>linux關機重新開機六種方法(sysrq </code><code>shutdown</code> <code>halt init)</code>

<code>目前版本</code>

<code>cat</code> <code>/etc/debian_version</code>

<code>5.0.1</code>

<code>一、linux關機指令(前四種)</code>

<code>1、</code><code>shutdown</code> <code>-h now(-h:halt after </code><code>shutdown</code><code>.)</code>

<code>halt</code>

<code>init 0</code>

<code>poweroff</code>

<code>2、linux重新開機指令(前四種)</code>

<code>shutdown</code> <code>-r(-r:reboot after </code><code>shutdown</code><code>.)</code>

<code>reboot</code>

<code>init 6</code>

<code>二、特殊情況重新開機和關機(能</code><code>ping</code><code>通 上述指令無法使用情況下 也就是系統挂起了)</code>

<code>1、檢視核心是否支援</code>

<code>cat</code> <code>/boot/config-</code><code>`</code><code>uname</code> <code>-r`|</code><code>grep</code> <code>"CONFIG_MAGIC_SYSRQ"</code>

<code>CONFIG_MAGIC_SYSRQ=y</code>

<code>2、臨時開啟或關閉</code>

<code>echo</code> <code>0 &gt; </code><code>/proc/sys/kernel/sysrq</code>

<code>echo</code> <code>1 &gt; </code><code>/proc/sys/kernel/sysrq</code>

<code>0 - disable sysrq completely</code>

<code>1 - </code><code>enable</code> <code>all functions of sysrq</code>

<code>3、通過sysctl指令永久設定</code>

<code>sysctl -w kernel.sysrq=1</code>

<code>sysctl -a|</code><code>grep</code> <code>"kernel.sysrq"</code>

<code>kernel.sysrq = 1</code>

<code>4、具體指令</code>

<code>重新開機系統</code>

<code>echo</code> <code>"b"</code><code>&gt; </code><code>/proc/sysrq-trigger</code>

<code>'b'</code>     <code>- Will immediately reboot the system without syncing or unmounting</code>

<code>          </code><code>your disks.</code>

<code>關閉系統 </code>

<code>echo</code> <code>"o"</code><code>&gt; </code><code>/proc/sysrq-trigger</code>

<code>'o'</code>     <code>- Will shut your system off (</code><code>if</code> <code>configured and supported). </code>

<code>三、調用ipmi指令關機和重新開機(前提是配置過)</code>

<code>1、重新開機機器</code>

<code>ipmitool -Ilanplus -H 172.16.1. -U root -P 123456 power reset</code>

<code>2、關閉電源</code>

<code>ipmitool -I lanplus -H 172.16.1. -U root -P 123456 power off</code>

<code>一些sysrq的指令參數說明</code>

<code>'b'</code>      <code>- Will immediately reboot the system without syncing or unmounting your disks.</code>

<code>'c'</code>      <code>- Will perform a system crash by a NULL pointer dereference.A crashdump will be taken </code><code>if</code> <code>configured.</code>

<code>'d'</code>      <code>- Shows all locks that are held.</code>

<code>'e'</code>      <code>- Send a SIGTERM to all processes, except </code><code>for</code> <code>init.</code>

<code>'f'</code>      <code>- Will call oom_kill to </code><code>kill</code> <code>a memory hog process.</code>

<code>'g'</code>      <code>- Used by kgdb (kernel debugger)</code>

<code>'h'</code>      <code>- Will display help (actually any other key than those listed here will display help. but </code><code>'h'</code> <code>is easy to remember :-)</code>

<code>'i'</code>      <code>- Send a SIGKILL to all processes, except </code><code>for</code> <code>init.</code>

<code>'j'</code>      <code>- Forcibly </code><code>"Just thaw it"</code> <code>- filesystems frozen by the FIFREEZE ioctl.</code>

<code>'k'</code>      <code>- Secure Access Key (SAK) Kills all programs on the current virtual console. NOTE: See important comments below </code><code>in</code> <code>SAK section.</code>

<code>'l'</code>      <code>- Shows a stack backtrace </code><code>for</code> <code>all active CPUs.</code>

<code>'m'</code>      <code>- Will dump current memory info to your console.</code>

<code>'n'</code>      <code>- Used to </code><code>make</code> <code>RT tasks </code><code>nice</code><code>-able</code>

<code>'o'</code>      <code>- Will shut your system off (</code><code>if</code> <code>configured and supported).</code>

<code>'p'</code>      <code>- Will dump the current registers and flags to your console.</code>

<code>'q'</code>      <code>- Will dump per CPU lists of all armed hrtimers (but NOT regular timer_list timers) and detailed information about all clockevent devices.</code>

<code>'r'</code>      <code>- Turns off keyboard raw mode and sets it to XLATE.</code>

<code>'s'</code>      <code>- Will attempt to </code><code>sync</code> <code>all mounted filesystems.</code>

<code>'t'</code>      <code>- Will dump a list of current tasks and their information to your console.</code>

<code>'u'</code>      <code>- Will attempt to remount all mounted filesystems </code><code>read</code><code>-only.</code>

<code>'v'</code>      <code>- Forcefully restores framebuffer console</code>

<code>'v'</code>      <code>- Causes ETM buffer dump [ARM-specific]</code>

<code>'w'</code>      <code>- Dumps tasks that are </code><code>in</code> <code>uninterruptable (blocked) state.</code>

<code>'x'</code>      <code>- Used by xmon interface on ppc</code><code>/powerpc</code> <code>platforms. Show global PMU Registers on sparc64.</code>

<code>'y'</code>      <code>- Show global CPU Registers [SPARC-64 specific]</code>

<code>'z'</code>      <code>- Dump the ftrace buffer</code>

本文轉自 xdoujiang 51CTO部落格,原文連結:http://blog.51cto.com/7938217/1643948,如需轉載請自行聯系原作者

繼續閱讀