GRUB (GRand Unified Bootloader 縮寫) 是 linux 系統中常用的系統啟動軟體,另一個同功能的是 LILO (LInux LOader 縮寫),它的作用是接管 BIOS 交付控制權給作業系統時的第一個工作–把作業系統正確地從硬碟載入。通常一般使用者在用光碟裝完 linux 後,例如 ubuntu,系統就會自動裝好 GRUB,就像 Windows 系統一樣。然而如果有某種原因被毀損了,最常見的是在同個硬碟想有 dual system,先裝好 linux 再裝 Windows,Windows 會很不客氣毫不猶豫地直接蓋掉 GRUB,你的 linux 就此無法開機,這時就需要重建 GRUB 了…
如何重建 GRUB 的步驟如下:
- 使用原來的 linux 安裝光碟開機。現代的系統都是 live-cd,即開機光碟 boot 完就是可操作的系統。
- 開一個終端機程式,可以輸入命令。
- 執行
sudo grub
,回答密碼。 grub> find /boot/grub/stage1
,它會找原來裝 GRUB 的硬碟分區,例如 (hd1,0),即第二個硬碟的第一個分區。grub> root (hd1,0)
,告訴它 linux root 在哪裡。grub> setup (hd0)
,安裝 GRUB 在第一個硬碟的 MBR (Master Boot Record)。把 Windows 的 bootloader 蓋掉… 之後可以在 GRUB menu 中加入進 Windows 系統的選項,本文不討論這個。grub> quit
,結束,這樣就完成 GRUB rebuild,可以 reboot 了。
另一作法是把 GRUB 安裝在硬碟分區裡,例如 grub> setup (hd1,0)
,安裝 GRUB 在第二個硬碟的第一個分區,而不是 MBR。這種方法可以使用 Windows 的 boot loader 來作 dual system 啟動,我就是這麼作的,下回再來介紹。
Update — 12/8/2007
使用 Windows 的 boot loader 來作 dual system 啟動,請看 “使用 Windows bootloader 來 load Linux“。
(Visited 43,572 times, 1 visits today)
Pingback: 使用 Windows bootloader 來 load Linux
Pingback: [note] Ubuntu Linux 筆記 « 二師兄.看世界
天啊~~~好強!!
剛剛不小心毀了MBR,
本來要重灌SuSE的,
光碟都放進電腦了,
就是看你的文章救援回來,
真是太感謝你了。
Pingback: Linux Notes « 邊秋一雁聲
下了 grub> find /boot/grub/stage1 , 卻回應’ can not find the file ” !
卡在這裡了 , 連原來的 XP 也回不去了 — 開機進 GRUB 馬上 Error 22 !
why ?
“can not find the file” 那就是找不到了,可能是根本沒裝或是被蓋掉了,重裝吧。
XP 用 XP 光碟,到 rescue mode,在命令列用 fixmbr 試看看。
Pingback: 重建 GRUB (linux boot loader) « 風之過客-足跡
Pingback: CentOS Windows 7 Clonezilla grub | ↗☆奇☆↙的不隨手筆記~
Pingback: 使用 Windows bootloader 來 load Linux | 精神奕奕精神奕奕
Pingback: 使用GRUB2重建MBR | 精神奕奕精神奕奕