歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> grub menu.list配置

grub menu.list配置

日期:2017/3/1 15:43:22   编辑:關於Linux
grub menu.list配置 因重裝系統,把GRUB引導菜單搞沒了,一直不知道怎麼找回來,今天看到貼子,試了下,成功了,主要步驟是下邊蘭字部分t 而恢復Grub,其實也很簡單的:用Live CD(對於Ubuntu來說就是Desktop CD或者DVD)啟動,打開終端(Applications──>Accessory──>Terminal),執行以下代碼: 代碼: sudo grub find /boot/grub/stage1 root (hdX,Y) setup (hdX) quit 注意:其中的X、Y是執行find /boot/grub/stage1命令後系統提示的。,比如: 代碼: grub> find /boot/grub/menu.lst (hd0,7) 注意:這裡的grub>是執行sudo grub命令後進入grub環境得到的提示符,不用輸入。這時,X就是0,Y就是7。 下面詳細解釋一下這幾條命令: sudo grub 以root用戶身份啟動grub,否則會出錯,錯誤見後文 find /boot/grub/stage1 尋找/boot所在分區,其實換用find /boot/grub/menu.lst也一樣。 這一步也可以跳過,在執行root (hdX,時連按兩下Tab列出可用分區,自己確定是哪個分區。 如果是將/boot單獨分區,詳見說明。 root (hdX,Y) 設置硬盤hdX的根文件系統(root Device),實際就是設置/boot所在的分區 setup (hdX) 自動安裝GRUB到硬盤hdX。 quit 退出GRUB root、setup命令後都有空格,如果沒有會出錯誤。 如果不以root用戶身份會出現什麼樣的錯誤呢? 引用: ubuntu@ubuntu:~$grub [ 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> find /boot/grub/stage1 Error 15: File not found grub> find /boot/grub/menu.lst Error 15: File not found grub> root(hd0,7) Error 27: Unrecognized command grub> root (hd0,7) Error 21: Selected disk does not exist grub> setup (hd0) Error 12: Invalid device requested 一個成功例子: 引用: ubuntu@ubuntu:~$ sudo grub [ 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> find /boot/grub/menu.lst (hd0,7) grub> root (hd0,7) grub> setup (hd0) Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded. succeeded Running "install /boot/grub/stage1 (hd0) (hd0)1+15 p (hd0,7)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded Done. grub>quit 這是最簡單的方法,也有其它幾個尋找/boot分區的方法,但稍麻煩點: 在終端使用ls /dev/sd*和ls /hd*命令來查找系統的外部設置,用sudo mkdir命令來建立掛載目錄,用sudo mount命令掛載,再用ls命令查看是否/boot所在的分區。 也可以用sudo fdisk -l來找到啟動分區(這裡不涉及將/boot單獨分區的情況,因為那種我沒有實驗過,不太清楚),如: 引用: ubuntu@ubuntu:~$ sudo fdisk -l Disk /dev/sda: 160.0 GB, 160041885696 bytes 255 heads, 63 sectors/track, 19457 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 2295 18434556 7 HPFS/NTFS /dev/sda2 2296 19456 137845732+ f W95 Ext'd (LBA) /dev/sda5 2296 4845 20482843+ 7 HPFS/NTFS /dev/sda6 4846 8669 30716248+ 7 HPFS/NTFS /dev/sda7 8670 16557 63360328+ 7 HPFS/NTFS /dev/sda8 * 16558 17361 6458098+ 83 Linux /dev/sda9 17362 19393 16322008+ 83 Linux /dev/sda10 19394 19456 506016 82 Linux swap / Solaris 就知道啟動分區是/dev/sda8 有人可能會有疑問,在Linux系統中是用sda8來表示這個啟動分區,而GRUB中則是用(hd0,7)表示,這是因為在新版的Ubuntu中系統將串口硬盤和並口硬盤都識別為sd,a表示第一硬盤,8表示第4個邏輯分區(1──4被分配給主分區,擴展分區裡的邏輯分區從5開始計算)。而Grub中則是用統一用hd代表硬盤,硬盤號與分區號都是從0開始計算的。 這部分是憑記憶寫的,可能不准確,請參考wiki。 PS: 看到有的帖子說Alterate CD可以在boot後輸入linux rescue來啟動救援盤,後面的操作則一樣。我因手頭沒有Alterate CD無法驗證。DVD雖說集成了Alterate CD與Desktop CD,但無法在以字符界面安裝時啟動救援盤。 感謝雕雕補充: 雕嘯長空 寫道: 補充一點,上面講的是在/boot下面的東西都還完好的,但如果RP不行,/boot都玩完了,可以試一下下面的: 生成/etc/mtab 代碼: sudo grep -v rootfs /proc/mounts >sudo tee /etc/mtab 安裝grub到mbr 代碼: grub-install --no-floppy /dev/hda 然後就自己搞定menu.lst了.
Copyright © Linux教程網 All Rights Reserved