(注意命令間的空格,特別是mnt前面有空格)
補充/首先應該sudo fdisk -l 找到id=83的選項,如,我的是:
Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xbbc20dd6
Device Boot Start End Blocks Id System
/dev/sda1 * 1 3891 31254426 7 HPFS/NTFS
/dev/sda2 3892 6261 19028992 83 Linux
/dev/sda3 6261 38914 262282241 f W95 Ext'd (LBA)
/dev/sda4 6504 11727 41953280 7 HPFS/NTFS
/dev/sda5 6261 6504 1952768 82 Linux swap / Solaris
/dev/sda6 11727 24794 104960000 7 HPFS/NTFS
/dev/sda7 24794 38914 113414144 7 HPFS/NTFS
,這樣獲取自己ubuntu分區在/dev/sda2。
然後再按照以下去做
1. sudo -i
2. mount /dev/sda2 /mnt
3. mount /dev/sda2 /mnt/boot 這一步是有給 /boot 單獨分區的命令,若沒單獨分區跳過這步
4. grub-install --root-directory=/mnt/ /dev/sda
5. 重啓
6. 機子重啓後就進了grub界面,但沒進grub菜單,所以又有下面的步驟,在grub>提示符下輸入:
7. find /boot/grub/core.img (若boot單獨分區則:find /grub/core.ima)
此命令會得到個結果:(hdx,y)
8. root (hdx,y)
9. kernel /boot/grub/core.img
(boot單獨分區則:kernel /grub/core.img)
10. boot
執行該命令後就轉入到GRUB菜單,此時選擇進入Ubuntu
11. 在ubuntu下啓動終端
12. sudo grub-install /dev/sda
此命令用作修復grub,
經過上面的步驟就就能恢復到原來的雙系統。