CentOS 救援模式 (rescue installed system)修復損壞系統
2016年02月26日 ⁄ Linux ⁄
共 1038字 ⁄ 字號 小 中 大 ⁄ 暫無評論
前段時間遇到開發人員更新glibc版本,把/usr/lib64/libc-2.12.so& libc.so.6-> libc-2.12.so這個軟連接更改之後導致報錯:
ls: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
無法遠程登錄,終端也無法登錄,也無法單用戶登錄,如圖:
遠程登錄:

終端登錄:

單用戶:

其實在執行誤操作之後只要不斷開遠程連接還有挽回的余地,但遠程異常斷開連接之後很多人就沒有轍了,准備搶救數據&文件,重裝系統,其實這裡咱們先不要著急重裝系統,咱們來試試rescue !
一、首先准備好系統安裝盤,使用安裝盤啟動:

:
二、選擇語言和鍵盤(默認的就好):

三、稍等一會兒會出現要不要設置網絡,一般來說網絡沒問題就不用設置了,我這裡選擇No:

四、這裡就是rescue選項了:
選擇Continue,則救援模式程序會自動查找系統中已有的文件系統,並把他們掛載到/mnt/sysimage目錄下。
選擇Read-Only,則會以只讀的方式掛載已有的文件系統。
手動掛載則Skip。
Advanced ,高級選項就不作說明了。
咱們這兒選擇Continue:

五、原系統掛載路徑/mnt/sysimage,如果想獲得原系統root環境,執行行命令:chroot /mnt/sysimage 即可。

六、這裡可以執行fakd診斷,當然我們這裡直接進入shell 命令行:

七、本次重頭戲來了,因為/usr/lib64/libc-2.12.so& libc.so.6-> libc-2.12.so問題,執行chroot /mnt/sysinage會報錯:

八、不要害怕,執行:
1
cp
/lib64/libc-2
.12.so
/mnt/sysimage/lib64/libc-2
.12.so
2
cp
/lib64/libc
.so.6
/mnt/sysimage/lib64/libc
.so.6
將光盤文件拷貝到系統文件去,再執行chroot /mnt/sysinage 就正常了:

其實到這裡我這次rescue 已經完成了,因為系統缺少/usr/lib64/libc-2.12.so文件和 libc.so.6-> libc-2.12.so軟連接 ,復制過去就好了 。
九、退出shell & reboot

其他系統文件損壞也可以參照同樣步驟進行,就不在此贅述了 。
歡迎大家多多指教 ~~~