天天看點

linux啟動過程故障排除

linux機器的啟動過程:

開機自檢(BIOS)---> MBR引導---> GRUB菜單---> 加載核心(kernel)--->

運作INIT程序

<a href="http://blog.51cto.com/attachment/201307/145659571.png" target="_blank"></a>

全部過程可以主要分為兩個過程:MBR引導和grub

第一階段失效:

NBR引導區域一共隻有446個位元組,是以當它出現問題時,grub菜單是沒法見到的,是以我們來模拟這個問題

使用如下的指令我們可以将開機是啟動的446個位元組給覆寫住,重新開機

<a href="http://blog.51cto.com/attachment/201307/145701400.png" target="_blank"></a>

此時開機的界面變成這樣,硬碟啟動不了,說明它要用PXE引導,但是起不來

<a href="http://blog.51cto.com/attachment/201307/145703981.png" target="_blank"></a>

這時候我們要使用CD光牒引導,進入急救模式

<a href="http://blog.51cto.com/attachment/201307/145705658.png" target="_blank"></a>

<a href="http://blog.51cto.com/attachment/201307/145708927.png" target="_blank"></a>

<a href="http://blog.51cto.com/attachment/201307/145710862.png" target="_blank"></a>

<a href="http://blog.51cto.com/attachment/201307/145713975.png" target="_blank"></a>

<a href="http://blog.51cto.com/attachment/201307/145716867.png" target="_blank"></a>

<a href="http://blog.51cto.com/attachment/201307/145718173.png" target="_blank"></a>

然後我們要怎樣來重建MBR裡面的446個位元組呢?我們進入在指令行裡直接輸入grub ,enter鍵進入

接下來我們要指明跟分區的位置,因為我的是在第一塊兒盤的第一個分區

<a href="http://blog.51cto.com/attachment/201307/145720829.png" target="_blank"></a>

<a href="http://blog.51cto.com/attachment/201307/145723992.png" target="_blank"></a>

此時執行 grub&gt;quit 推出

接着在所在的指令行輸入兩次exit推出急救模式,并且系統會自動啟動

我們發現系統啟動成功,故障排除成功!

第二階段失效:

/boot/grub/grub.conf檔案

我們在這裡删除它,來模拟實驗

<a href="http://blog.51cto.com/attachment/201307/145725699.png" target="_blank"></a>

删除後,進行重新開機,發現啟動的情況是這樣

<a href="http://blog.51cto.com/attachment/201307/145728967.png" target="_blank"></a>

看到了這種情況,也就是說我們第一階段啟動成功,但是第二階段失敗

我們要使用指令來啟動了

<a href="http://blog.51cto.com/attachment/201307/145730142.png" target="_blank"></a>

我們選擇第一塊兒硬碟,但是若是我們忘記是第幾個分區,我們可以一個個的實驗,這個不會有影響,

使用 find /  lai chakan 跟分區上的内容來确定跟分區,因為跟分五上有核心和驅動程式

<a href="http://blog.51cto.com/attachment/201307/145732273.png" target="_blank"></a>

接下來我們要告訴系統核心在哪去引導,指令如下

<a href="http://blog.51cto.com/attachment/201307/145735201.png" target="_blank"></a>

接下來系統就會自己成功的啟動進入主界面,我們登入就ok!

但是我們需要在/boot/grub/目錄下手動添加grub.conf檔案

使用grub-install來指明二階段需要的檔案安裝位置

<a href="http://blog.51cto.com/attachment/201307/145737565.png" target="_blank"></a>

使命後就去編寫grub.conf檔案

<a href="http://blog.51cto.com/attachment/201307/145739957.png" target="_blank"></a>

編寫成功後再次重新開機,我們發現可以重新開機成功,因為編寫的grub.conf很簡單,是以登入的界面也很簡單

現在我們再來一次,把整個grub目錄下的檔案都删掉,肯定是開機不了

<a href="http://blog.51cto.com/attachment/201307/145742250.png" target="_blank"></a>

這樣我們隻能使用急救模式,首先使用CD光牒引導,進入grub

<a href="http://blog.51cto.com/attachment/201307/145744800.png" target="_blank"></a>

<a href="http://blog.51cto.com/attachment/201307/145746593.png" target="_blank"></a>

我們查詢一下安裝的結果,我發現缺少了grub.conf檔案,還需要我們手動編寫

<a href="http://blog.51cto.com/attachment/201307/145748730.png" target="_blank"></a>

接下來我們推出,按下F2重新開機

進入grub指令行,我們就像上面那樣手動進入系統

<a href="http://blog.51cto.com/attachment/201307/145751516.png" target="_blank"></a>

進入系統後我們隻需要編寫grub.conf檔案,系統的故障就會解除了。

有時候我們忘記了管理者的密碼,那麼隻要我們可以接觸到機器,就可以修改管理者帳号密碼

進入引導界面,按下e鍵

<a href="http://blog.51cto.com/attachment/201307/145753337.png" target="_blank"></a>

<a href="http://blog.51cto.com/attachment/201307/145755799.png" target="_blank"></a>

<a href="http://blog.51cto.com/attachment/201307/145758549.png" target="_blank"></a>

然後按下b鍵進行引導,進入單使用者模式

<a href="http://blog.51cto.com/attachment/201307/145800270.png" target="_blank"></a>

也可以直接删掉管理者的密碼

<a href="http://blog.51cto.com/attachment/201307/145802615.png" target="_blank"></a>

重新開機就可以實作登入了!

    本文轉自Tar0 51CTO部落格,原文連結:http://blog.51cto.com/tar0cissp/1260535,如需轉載請自行聯系原作者

繼續閱讀