LinuxSir.cn,穿越时空的Linuxsir!

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

求助:无法正常关机

[复制链接]
发表于 2007-6-12 12:26:26 | 显示全部楼层 |阅读模式
前几天看贴说把rc.shutdown文件改了可以保护笔记本硬盘,可是后来发现无法正常关机了,重启也挂了,提示信息如下:
INIT: Switching to runlevel:6
INIT: Sending processes started by init TERM signal
INIT: cannot execute "/etc/rc.shutdown"
INIT: no more processes left in this runlevel
哪位高手帮帮忙啊!
发表于 2007-6-12 12:33:17 | 显示全部楼层
未修改過的rc.shutdown,自己參照著改回來(以後修改系統文件之前記得備份)。

  1. #!/bin/bash
  2. #
  3. # /etc/rc.shutdown
  4. #

  5. . /etc/rc.conf
  6. . /etc/rc.d/functions

  7. # avoid staircase effect
  8. /bin/stty onlcr

  9. echo " "
  10. printhl "Initiating Shutdown..."
  11. echo " "

  12. # avoid NIS hanging syslog-ng on shutdown by unsetting the domainname
  13. if [ -x /bin/domainname ]; then
  14.         /bin/domainname ""
  15. fi

  16. if [ -x /etc/rc.local.shutdown ]; then
  17.         /etc/rc.local.shutdown
  18. fi

  19. if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL" = "5" ]; then
  20.         # Shutdown daemons
  21.         let i=${#DAEMONS[@]}
  22.         while [[ i -ge 0 ]]; do
  23.                 if [[ `echo ${DAEMONS[$i]} | grep '^[^\!]' | wc -l` -eq 1 ]]; then
  24.                         /etc/rc.d/${DAEMONS[$i]#@} stop
  25.                 fi
  26.                 let i=i-1
  27.         done
  28.         # find any leftover daemons and shut them down
  29.         if [ -d /var/run/daemons ]; then
  30.                 for daemon in `ls /var/run/daemons`; do
  31.                         /etc/rc.d/$daemon stop
  32.                 done
  33.         fi
  34. fi

  35. # Terminate all processes
  36. stat_busy "Sending SIGTERM To Processes"
  37. /sbin/killall5 -15 &> /dev/null
  38. /bin/sleep 5
  39. stat_done

  40. stat_busy "Sending SIGKILL To Processes"
  41. /sbin/killall5 -9 &> /dev/null
  42. /bin/sleep 1
  43. stat_done

  44. stat_busy "Saving Random Seed"
  45. /bin/dd if=/dev/urandom of=/var/run/random-seed count=1 bs=512 2> /dev/null
  46. stat_done

  47. stat_busy "Saving System Clock"
  48. if [ "$TIMEZONE" != "" -a -e /usr/share/zoneinfo/$TIMEZONE ]; then
  49.         /bin/rm -f /etc/localtime
  50.         /bin/cp /usr/share/zoneinfo/$TIMEZONE /etc/localtime
  51. fi
  52. if [ "$HARDWARECLOCK" = "UTC" ]; then
  53.         /sbin/hwclock --directisa --utc --systohc
  54. else
  55.         /sbin/hwclock --directisa --localtime --systohc
  56. fi
  57. stat_done

  58. # removing psmouse module to fix some reboot issues on newer laptops
  59. modprobe -r psmouse >/dev/null 2>&1

  60. # Write to wtmp file before unmounting
  61. /sbin/halt -w

  62. stat_busy "Deactivating Swap"
  63. /sbin/swapoff -a
  64. stat_done

  65. stat_busy "Unmounting Filesystems"
  66. /bin/umount -a -t noramfs,notmpfs,nosysfs,noproc
  67. stat_done

  68. # Kill non-root encrypted partition mappings
  69. if [ -f /etc/crypttab -a -n "$(grep -v ^# /etc/crypttab | grep -v ^$)" ]; then
  70.         stat_busy "Deactivating encrypted volumes:"
  71.         CS=/sbin/cryptsetup.static
  72.         do_uncrypt() {
  73.                 if [ $# -ge 3 ]; then
  74.                         stat_append "${1}.."
  75.                         $CS remove $1 >/dev/null 2>&1
  76.                         if [ $? -ne 0 ]; then
  77.                                 stat_append "failed "
  78.                         else
  79.                                 stat_append "ok "
  80.                         fi
  81.                 fi
  82.         }
  83.         while read line; do
  84.                 eval do_uncrypt "$line"
  85.         done </etc/crypttab
  86.         stat_done
  87. fi

  88. if [ "$USELVM" = "yes" -o "$USELVM" = "YES" ]; then
  89.         if [ -x /sbin/lvm -a -d /sys/block ]; then
  90.                 stat_busy "Deactivating LVM2 groups"
  91.                 /sbin/lvm vgchange --ignorelockingfailure -an >/dev/null 2>&1
  92.                 stat_done
  93.         fi
  94. fi

  95. stat_busy "Remounting Root Filesystem Read-only"
  96. /bin/mount -n -o remount,ro /
  97. stat_done

  98. # Power off or reboot
  99. if [ "$RUNLEVEL" = "0" ]; then
  100.         printsep
  101.         printhl "${C_H2}POWER OFF"
  102.         /sbin/poweroff -d -f -h -i
  103. else
  104.         printsep
  105.         printhl "${C_H2}REBOOTING"
  106.         # if kexec is installed and a kernel is loaded, use it
  107.         [ -x /sbin/kexec ] && /sbin/kexec -e > /dev/null 2>&1
  108.         /sbin/reboot -d -f -i
  109. fi

  110. # End of file
  111. # vim: set ts=2 noet:
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-6-12 12:39:59 | 显示全部楼层
我已经把那个删了重新改回去了,可是还是不行,不知道怎么回事啊?
回复 支持 反对

使用道具 举报

发表于 2007-6-12 13:04:39 | 显示全部楼层
pacman -S initscripts

重新安裝initscripts呢?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-6-12 13:09:22 | 显示全部楼层
ok啦!这次好了,刚是在win下面复制你的文件,所以进arch无法正常显示,我用朋友给我传的文件覆盖掉以前的,现在好了!谢啦!
回复 支持 反对

使用道具 举报

发表于 2007-6-12 13:11:52 | 显示全部楼层
> 我已经把那个删了重新改回去了,可是还是不行,不知道怎么回事啊?

是不是忘了给rc.shutdown加“可执行”属性?
sudo chmod 755 /etc/rc.shutdown
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-6-12 13:18:49 | 显示全部楼层
默认就是可执行的啊,你直接删了用把以前的文件加进去应该就好了!
回复 支持 反对

使用道具 举报

发表于 2007-6-12 14:01:41 | 显示全部楼层
> 默认就是可执行的啊,你直接删了用把以前的文件加进去应该就好了!

呵呵,误会了。

我以为你说的“把那个删了”指的是:
rm /etc/rc.shutdown
然后再
cp /xxx/../rc.shutdown.original /etc/rc.shutdown

vi /etc/rc.shutdown
回复 支持 反对

使用道具 举报

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

本版积分规则

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