天天看點

恢複/etc/fstab檔案實驗

恢複/etc/fstab檔案實驗

一、恢複/etc/fstab檔案(Centos6分區情況)

現象:出現 error 15,出現不了菜單

思路:首先找到根分區

破壞:rm -rf /etc/fstab, rm -rf /boot/

恢複/etc/fstab檔案實驗

恢複:① 進入救援模式

恢複/etc/fstab檔案實驗

②恢複/etc/fstab檔案

恢複/etc/fstab檔案實驗
vi在這裡沒法使用,是以使用cat >> /etc/fstab 編輯内容: /dev/sda1     /boot    ext4   defaults     0  0 /dev/sda2     /            ext4  defaults    0  0 /dev/sda5    swap       swap  defaults    0  0

③、恢複根檔案

恢複/etc/fstab檔案實驗

④、安裝缺少的檔案

恢複/etc/fstab檔案實驗
恢複/etc/fstab檔案實驗
恢複/etc/fstab檔案實驗

⑤啟動成功

恢複/etc/fstab檔案實驗

二、現在來分析另一種情況:删除/etc/fstab檔案(在邏輯卷環境)

現象:停留在 grub> 處,顯示沒有任何分區(由于核心檔案都不在了,隻能挂在CD光牒,進入救援模式,它嘗試去找作業系統的根但是找不到)

恢複/etc/fstab檔案實驗

破壞:mv /etc/fstab /root, rm -rf /boot/*

恢複/etc/fstab檔案實驗

恢複:① 進入救援模式,恢複/etc/fstab檔案

恢複/etc/fstab檔案實驗
恢複/etc/fstab檔案實驗

注意:邏輯卷挂載到臨時檔案:mount /dev/VolGroup/lv_boot  /mnt/tmp(下圖寫錯了)

恢複/etc/fstab檔案實驗
恢複/etc/fstab檔案實驗

輸入sync,保證同步;再exit并重新開機。

②、修複/boot檔案

恢複/etc/fstab檔案實驗
恢複/etc/fstab檔案實驗
恢複/etc/fstab檔案實驗
恢複/etc/fstab檔案實驗

exit--->reboot,然後步驟結束。

注意:如果缺少檔案可以使用網絡,配置IP位址,從别的主機上通過scp拷貝;這裡就不做示範了。
恢複/etc/fstab檔案實驗

本文轉自 優果馥思 51CTO部落格,原文連結:http://blog.51cto.com/youguofusi/1967991