教你如何學習GRUB
只有少數情況下,才需要將 GRUB 引導裝入器重新安裝到引導記錄。首先,如果更改 GRUB root 分區的分區類型(例如,從 ext2 改成 ReiserFS),則需要重新安裝?;蛘撸绻?/boot/grub 中的 stage1 和 stage2 文件,由于它們來自更新版本的 GRUB,很有可能要重新安裝引導裝入器。其它情況下,可以不必理睬!
GRUB的最大的特點就是交互性特別強。在開機時,按一下“c”,將進入GRUB 控制臺。顯示如下:
GRUB version 0.5.96.1 (640K lower / 3072K upper memory)
[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename. ]
grub>
歡迎使用 GRUB 控制臺?,F在,再研究命令:
將通過GRUB 控制臺繞過lilo來啟動RedHat linux,
grub> root (h
現在,按一次 Tab 鍵。如果系統中有多個硬盤,GRUB 將顯示可能完成的列表,從 hd0 開始。如果只有一個硬盤,GRUB 將插入 hd0,。如果有多個硬盤,繼續進行,在 (hd2 中輸入名稱并在名稱后緊跟著輸入逗號,但不要按 Enter 鍵。部分完成的 root 命令看起來如下:
grub> root (hd0,
現在,繼續操作,再按一次 Tab 鍵。GRUB 將顯示特定硬盤上所有分區的列表,以及它們的文件系統類型。在我的系統中,按 Tab 鍵時得到以下列表:
grub> root (hd0, (tab,按tab一下鍵)
Possible partitions are:
Partition num: 0, Filesystem type is fat, partition type 0x6
Partition num: 2, Filesystem type is ext2fs, partition type 0x83
Partition num: 4, Filesystem type unknown, partition type 0x7
Partition num: 5, Filesystem type is ext2fs, partition type 0x83
Partition num: 6, Filesystem type is fat, partition type 0xb
Partition num: 7, Filesystem type is fat, partition type 0xb
Partition num: 8, Filesystem type is ext2fs, partition type 0x83
Partition num: 9, Filesystem type unknown, partition type 0x82
如您所見,GRUB 的交互式硬盤和分區名稱實現功能非常有條理。這些,只需要好好理解 GRUB 新奇的硬盤和分區命名語法,然后就可以繼續操作了
grub> root (hd0,8)
現在已安裝了 root 文件系統,到裝入內核的時候了
grub> kernel /boot/vmlinuz-2.4.2 root=/dev/hda5 ro
[Linux-bzImage, setup=0x1200, size=0xe1a30]
您已經安裝了 root 文件系統并裝入了內核。現在,可以引導了。只要輸入 boot,Linux 引導過程就將開始。是不是很cool啊,GRUB的menu.lst更像一個linux下的腳本程序。
5 常見grub除錯方法的思路
首先進去Linux的rescue模式!
用軟盤或光盤啟動,然后在啟動的提示符輸入:linux rescue
按照提示進入一個Shell狀態,你可以到/mnt/下面看到一個sysimage這么目錄,進去以后,就是你安裝linux的/分區.
使用命令將根分區變為當前目錄的根分區:chroot /mnt/sysimage
然后轉到/sbin/這個目錄中.
使用fdisk -l 顯示當前分區情況,然后使用#grub-install /dev/hdx(x為你使用的是那塊硬盤安裝的,一般情況下是hda)
使用exit推出chroot,再使用exit退出linux rescue模式,系統將重新啟動!取出光盤,應該可以看到grub安裝好了.
在具體的環境中,編輯/boot/grub/grub.conf文件和menu.lst文件.
評論