LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1032|回复: 5

"shutdown -h now"和"init 0"都變成了重啟

[复制链接]
发表于 2010-4-18 14:57:17 | 显示全部楼层 |阅读模式
"shutdown -h now"和"init 0"都變成了重啟,無法關機,怎麽辦?
发表于 2010-4-18 15:29:25 | 显示全部楼层
我感觉这是个硬件问题...
回复 支持 反对

使用道具 举报

发表于 2010-4-18 16:48:20 | 显示全部楼层
我在控制台也遇到这样的情况了,不过,在xfce里可以关掉
回复 支持 反对

使用道具 举报

 楼主| 发表于 2010-4-18 17:13:22 | 显示全部楼层
Setting the system clock.
Sun Apr 18 14:37:17 2010: Activating swap...done.
Sun Apr 18 14:37:17 2010: Checking root file system...fsck 1.41.3 (12-Oct-2008)
Sun Apr 18 14:37:17 2010: /dev/sda1: Superblock last write time is in the future.  FIXED.      //这里有问题,但是不知道如何解决
Sun Apr 18 14:37:17 2010: /dev/sda1: clean, 215632/4276224 files, 2630026/17089135 blocks
Sun Apr 18 14:37:17 2010: done.
Sun Apr 18 14:37:17 2010: Setting the system clock.
Sun Apr 18 14:37:18 2010: Cleaning up ifupdown....
Sun Apr 18 14:37:18 2010: Loading kernel modules...done.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2010-4-19 10:26:35 | 显示全部楼层
又捣鼓了差不多一通宵。。。
按理说,init 0就是系统的关闭,在/etc/rc0.d/中最后一个运行的就是/etc/init.d/halt脚本,脚本内容:
#! /bin/sh
### BEGIN INIT INFO
# Provides:          halt
# Required-Start:
# Required-Stop:
# Default-Start:
# Default-Stop:      0
# Short-Description: Execute the halt command.
# Description:
### END INIT INFO

NETDOWN=yes

PATH=/sbin:/usr/sbin:/bin:/usr/bin
[ -f /etc/default/halt ] && . /etc/default/halt

. /lib/lsb/init-functions

do_stop () {
    if [ "$INIT_HALT" = "" ]
    then
        case "$HALT" in
          [Pp]*)
            INIT_HALT=POWEROFF
            ;;
          [Hh]*)
            INIT_HALT=HALT
            ;;
          *)
            INIT_HALT=POWEROFF
            ;;
        esac
    fi

    # See if we need to cut the power.
    if [ "$INIT_HALT" = "OWEROFF" ] && [ -x /etc/init.d/ups-monitor ]
    then
        /etc/init.d/ups-monitor poweroff
    fi

    # Don't shut down drives if we're using RAID.
    hddown="-h"
    if grep -qs '^md.*active' /proc/mdstat
    then
        hddown=""
    fi

    # If INIT_HALT=HALT don't poweroff.
    poweroff="-p"
    if [ "$INIT_HALT" = "HALT" ]
    then
        poweroff=""
    fi

    # Make it possible to not shut down network interfaces,
    # needed to use wake-on-lan
    netdown="-i"
    if [ "$NETDOWN" = "no" ]; then
        netdown=""
    fi

    log_action_msg "Will now halt"
    halt -d -f $netdown $poweroff $hddown
}

case "$1" in
  start)
    # No-op
    ;;
  restart|reload|force-reload)
    echo "Error: argument '$1' not supported" >&2
    exit 3
    ;;
  stop)
    do_stop
    ;;
  *)
    echo "Usage: $0 start|stop" >&2
    exit 3
    ;;
esac

:

其中/etc/default/halt里面的内容是
# Default behaviour of shutdown -h / halt. Set to "halt" or "poweroff".
HALT=poweroff
由于没有/etc/init.d/ups-monitor,不知道为何没有ups-monitor,之前都照样正常关机的,那/etc/init.d/halt脚本最后一般就会运行halt -d -f,我不知道这个可不可以关机的......至少目前是无法关机。
而让我庆幸的是,使用halt -d -f -p就可以关机了...
回复 支持 反对

使用道具 举报

 楼主| 发表于 2010-4-19 10:39:08 | 显示全部楼层
哦!!!!!原来我看漏眼了!!
该脚本一般应该运行:halt -d -f -i -p -h才对阿!!!!!!那就是说halt脚本没问题!
那为何init 0的效果变成restart呢?????明明init 0最后运行的是halt脚本......
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表