1. 程式人生 > 其它 >LINXU_救援模式修復sh檔案缺失

LINXU_救援模式修復sh檔案缺失

技術標籤:Linux

簡述

本次故障於下面連線的博文一致,解決方法也是借鑑博文,推薦去下面的博文檢視
https://yq.aliyun.com/articles/225837

系統版本:CentOS 6.5 64
故障描述:/bin/sh檔案缺失,導致系統啟動卡在進度條

處理過程

問題發現及重置密碼

由於是問題解決後寫的本文件,所以有些沒有截圖

由研發人員說伺服器無法登陸,嘗試ssh連線一致提示密碼錯誤,溝通後通過vcenter進行密碼重置
通過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

救援模式恢復

通過搜尋報錯資訊發現問題於此博文十分相似:https://yq.aliyun.com/articles/225837

Vcenter中開啟對應機器的控制檯,重啟機器按f2或者ESC即可進入bios或者啟動項選擇

因為系統是CentOS6.5的系統,特地從其他宿主機拷貝了一份6.5映象到本宿主機,發現進入救援模式最後一步報錯,如下

又嘗試掛載CentOS7.6的映象,進入救援模式成功

#從救援模式的bash切換到系統的bash
bash-4.2# chroot /mnt/sysimage/  
chroot: failed to run command  `/bin/sh    `: No such file or directory
#切換到bash失敗,從救援模式的bash切換到系統的tcsh(另一種sh)
bash-4.1# chroot /mnt/sysimage/ /bin/tcsh 
[[email protected] ~]# mkdir /media
#將救援模式映象掛載到系統中
[[email protected] ~]# mount /dev/cdrom /media
mount: block device /dev/sr0 is write-protected, mounting read-only  
#重新安裝bash,但我用的Centos7的映象,bash版本CentOS6.5不支援
> [[email protected] ~]# cd /media/Packages/
> [[email protected] Packages]# rpm -ivh bash-4.1.2-15.el6.x86_64.rpm --replacepkgs
> Preparing...                ########################################### [100%]  
>    1:bash                   ########################################### [100%]
> [[email protected] Packages]# exit
> exit  
> bash-4.1# reboot

看到版本不符合,就像去網上找對應版本的bash,發現CSDN的下載資源好坑,明明是開源的還要各種限制,還是推薦大家去國內知名的映象源下載
https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.5/os/x86_64/Packages/bash-4.1.2-15.el6_4.x86_64.rpm
下載完傳到一臺伺服器上,在救援模式中 配置IP,通過scp 將安裝包複製到本地
在執行此步驟:rpm -ivh bash-4.1.2-15.el6.x86_64.rpm --replacepkgs
然後複製一臺相同版本機器的/bin/sh檔案到本機的/bin/sh(/bin/sh是連結檔案,應該做個/bin/bash /bin/sh的軟連線就可以,沒嘗試此方法)
重啟機器即可