閱讀1020 返回首頁    go 阿裏雲 go 技術社區[雲棲]


一次linux救援模式修複

環境描述:
係統版本:CentOS 6.5 64

故障描述:
/bin/sh目錄文件缺失,導致CentOS啟動卡條;

排查過程:
昨天晚上接到小夥伴反饋他們的yum源服務器重啟之後無響應,遂登錄Vcenter檢查發現係統卡開機進度條了,檢查發現有文件缺失的報錯;

init: Failed to spawn readahead-collector main process: unable to execute: No such file or directory  
init: Failed to spawn rcS pre-start process: unable to execute: No such file or directory  
init: Failed to spawn readahead main process: unable to execute: No such file or directory  
init: Failed to spawn readahead-collector post-stop process: unable to execute: No such file or directory  
init: Failed to spawn rcS post-stop process: unable to execute: No such file or directory  
init: Failed to spawn readahead-disable-services main process: unable to execute: No such file or directory

進入Vcenter掛載Centos6.5 ISO進入救援模式,進行如下操作:
通過tcsh切換根文件係統後用rpm命令安裝替換原來的bash

bash-4.1# chroot /mnt/sysimage/  
chroot: failed to run command  `/bin/sh `: No such file or directory

提示沒有找到/bin/sh,懷疑是Bash文件損壞;進行如下操作:

bash-4.1# chroot /mnt/sysimage/ /bin/tcsh  

指定切換後的shell為/bin/tcsh後成功;掛載安裝盤重新安裝bash

[root@localhost ~]# mkdir /media
[root@localhost ~]# mount /dev/cdrom /media
mount: block device /dev/sr0 is write-protected, mounting read-only  
[root@localhost ~]# cd /media/Packages/
[root@localhost Packages]# rpm -ivh bash-4.1.2-15.el6.x86_64.rpm --replacepkgs
Preparing...                ########################################### [100%]  
   1:bash                   ########################################### [100%]
[root@localhost Packages]# exit
exit  
bash-4.1# reboot

滿心歡喜的等待重啟,結果還是失敗,同樣的錯誤; 然後呢,進入帶網絡的救援模式,從另外的機器上CP了一個/bin/bash文件,然後ln /bin/sh後機器重啟恢複;

事件總結:
留意過程中的每一個報錯信息,第一次chroot報錯的時候就應該發現應該是/bin/sh出了問題;

最後更新:2017-10-23 11:03:53

  上一篇:go  Centos6.6下升級Python
  下一篇:go 雲棲玖著 委實難得一見!在杭州竟然還有這樣的139㎡小排!