
因為我聽說 Windows 開機載入程式會覆蓋 GRUB,所以我該如何重新安裝 GRUB 開機載入程式呢?
答案1
在「嘗試 Ubuntu」模式下從 Live CD 或 Live USB 啟動。決定主分區的分區號。 GParted(預設應該已安裝在即時會話中)可以在這方面為您提供協助。我將在這個答案中假設它是 /dev/sda2,但請確保為您的系統使用正確的分區號碼!
Mount your partition:
sudo mount /dev/sda2 /mnt #Replace sda2 with your partition number
Bind mount some other necessary stuff:
for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done
chroot into your Ubuntu install:
sudo chroot /mnt
At this point, you're in your install, not the live session, and running as root. Update grub:
update-grub
If you get errors, go to step 7. (Otherwise, it is optional.)
Depending on your situation, you might have to reinstall grub:
grub-install /dev/sda
update-grub # I'm not sure if this is necessary, but it doesn't hurt.
If everything worked without errors, then you're all set:
exit
sudo reboot
At this point, you should be able to boot normally.
如果您無法正常啟動,且由於沒有錯誤訊息而未執行步驟 7,請重試步驟 7。
有時為 GRUB2 提供正確的分割配置是不夠的,您必須實際將其安裝(或重新安裝)到主引導記錄,步驟 7 就是這樣做的。幫助用戶聊天的經驗表明,即使沒有顯示錯誤訊息,有時也需要執行步驟 7
答案2
從 Ubuntu 安裝媒體啟動並選擇無需安裝即可嘗試 Ubuntu。進入 Ubuntu Live 桌面後,打開終端機並執行以下命令。
如果您的機器有UEFI BIOSWindows和Ubuntu皆以EFI模式安裝:
sudo mount /dev/sd*** /mnt
sudo mount /dev/sd** /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo chroot /mnt
grub-install /dev/sd*
update-grub
註:sd*
=磁碟| sd**
= efi 分區 | sd***
= 系統分區
萬一有傳統BIOSWindows 和 Ubuntu 以 MBR (msdos) 模式安裝:
sudo mount /dev/sd** /mnt
sudo grub-install --boot-directory=/mnt/boot /dev/sd*
註:sd*
=磁碟| sd**
= 系統分區
要識別可以使用的磁碟和分割區號格帕特- 它包含在安裝介質中。