轉載:重裝Windows后恢復Ubuntu 9.10中的Grub2
原文地址: http://cookiebear.info/archives/353
在已經安裝了Ubuntu和Windows雙啟動的一個硬盤上重新安裝Windows,會將Windows的引導代碼寫入硬盤的MBR,覆蓋原本的Grub2。
這時候要恢復Grub2的多重啟動,唯有重新安裝Grub2了。
首先用Ubuntu Live CD啟動機器,然后打開終端輸入:
sudo -i |
[stextbox id="alert"]注意,以下的操作一定要再三確認,哪怕是一個字符的輸入錯誤都可能導致破壞Ubuntu的系統。[/stextbox]
接著我們要看一下硬盤的文件系統配置方式。
mint ~ # fdisk -l Disk /dev/sda: 250.1 GB, 250059350016 bytes 255 heads, 63 sectors/track, 30401 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0xd25ad25a Device Boot Start End Blocks Id System /dev/sda1 * 1 6527 52428096 7 HPFS/NTFS /dev/sda2 6528 30401 191767905 f W95 Ext'd (LBA) /dev/sda5 6528 18464 95882240 7 HPFS/NTFS /dev/sda6 18465 29910 91939963+ 83 Linux /dev/sda7 29911 30401 3943926 82 Linux swap / Solaris |
由這里看到,我的整個Ubuntu安裝在/dev/sda6上,沒有劃分出boot區和root區。這也是Ubuntu的默認安裝模式。
如果你單獨劃分了boot區,那么請在這一步記住boot的設備名稱。
然后執行下面的幾步,把之前記住的設備mount出來。
(由于我的系統是基于Ubuntu 9.10的Linux Mint 8,所以命令行提示符有些不一樣,但是原理是完全一致的。)
mint ~ # mkdir /media/root mint ~ # mount /dev/sda6 /media/root mint ~ # ls /media/root/ bin dev initrd.img media proc selinux tmp vmlinuz boot etc lib mnt root srv usr cdrom home lost+found opt sbin sys var mint ~ # ls /media/root/boot/ abi-2.6.31-14-generic initrd.img-2.6.31-14-generic boot memtest86+.bin config-2.6.31-14-generic System.map-2.6.31-14-generic gfxmenu vmcoreinfo-2.6.31-14-generic grub vmlinuz-2.6.31-14-generic |
mount完畢后確認/medai/root/目錄和/media/root/boot/確實和上面的輸出一致或者近似。
確認無誤后,執行下面的步驟重新安裝Grub2。
mint ~ # sudo grub-install --root-directory=/media/root /dev/sda Installation finished. No error reported. This is the contents of the device map /media/root/boot/grub/device.map. Check if this is correct or not. If any of the lines is incorrect, fix it and re-run the script `grub-install'. (hd0) /dev/sda |
完成了上面一步,并且沒有錯誤報告的話,Grub2就安裝成功了。
重新啟動一下機器,Grub2的多重啟動應該已經奏效了。如果你和我一樣是對Windows進行了升級,例如從Windows Vista -> Windows 7。
那么在重新進入Ubuntu之后可以在終端下執行:
sudo update-grub |
Grub2會自動識別出Windows的版本,并更新啟動菜單的顯示信息。
在整個操作過程中一定要反復檢查輸入是否有錯誤,并且牢記從Ubuntu 9.10開始,由于使用了Grub2。
以往重新安裝Grub的老辦法不一定適用。
萬一,在安裝Grub2時遇到了問題,進不了任何一個系統。
請冷靜下來,起碼你還有Ubuntu Live CD,用它啟動系統,進入這個鏈接尋找適當的解決辦法
posted on 2011-02-27 09:48 daning 閱讀(2124) 評論(0) 編輯 收藏 所屬分類: others