
當我對 Ubuntu 22.04 LTS 驅動器進行分割以新增 Windows 11 時,我的問題就開始了(我使用 Ubuntu 可啟動分割區對磁碟機進行分割)。
安裝 Windows 11 後,我的電腦開始啟動 Windows 11,而不是顯示 grub 選單。我透過進入 BIOS 並將 Ubuntu 移到頂部來修復此問題。我的電腦現在啟動進入 Ubuntu,但我仍然沒有看到 grub 選單。
看了這篇貼文後,為什麼啟動電腦時不顯示 Grub 選單?,我能夠再次顯示我的 grub 選單(@Akalgnotum)。但Windows 11並未包含在選單中。
在這篇文章的指導下,GRUB 未偵測到 Windows我跑了:
sudo os-prober
它回來了/dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi:Windows Boot Manager:Windows:efi
。然後我跑了,sudo update-grub
這給了我這個「警告」:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.0-46-generic
Found initrd image: /boot/initrd.img-5.15.0-46-generic
Found linux image: /boot/vmlinuz-5.15.0-43-generic
Found initrd image: /boot/initrd.img-5.15.0-43-generic
Memtest86+ needs a 16-bit boot, that is not available on EFI, exiting
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done
據我所知,Windows 不會被添加,sudo update-grub
因為它不會運行並使用 os-prober 提供的資訊。
我不知道如何解決這個問題。任何建議都會非常有幫助。如果需要更多信息,我很樂意提供。
謝謝!
答案1
在網路上查了好幾天,終於找到答案了!
所有功勞都歸功於這篇文章:https://askubuntu.com/a/977251/1191399。我只是重申一下。
sudo fdisk -l
您應該得到一個很長的回報,其中包括如下內容:
Device Start End Sectors Size Type
/dev/nvme0n1p1 2048 1050623 1048576 512M EFI System
/dev/nvme0n1p2 1050624 874729471 873678848 416.6G Linux filesystem
/dev/nvme0n1p3 874729472 874762239 32768 16M Microsoft reserved
/dev/nvme0n1p4 874762240 1000214527 125452288 59.8G Microsoft basic data
- 取得UUIDEFI分割區
sudo blkid /dev/nvme0n1p1
(將 nvme0n1p1 替換為適合您的正確分割區)
返回:
dev/nvme0n1p1: UUID="3C26-6A4C" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="3b64b43f-e7eb-4ac8-a32c-9af2edf64d0d"
授予自己對 /etc/grub.d 中「40_custom」檔案的寫入權限
開啟終端機 (ctrl+alt+t) 並執行下列命令:
cd /etc/grub.d
sudo chmod o+w 40_custom
開啟40_custom文件
open ./40_custom
在文件底部寫入以下內容,並將 3C26-6A4C 替換為正確的 UUID:
menuentry 'Windows 11' {
search --fs-uuid --no-floppy --set=root 3C26-6A4C
chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi
}
儲存檔案並關閉編輯器。
返回終端,刪除寫入權限。
sudo chmod o-w 40_custom
使用更新 GRUB
sudo update-grub
(可選)您可以透過前往 /boot/grub/grub.cfg 並檢查第 243-251 行來確認變更是否成功。它應該反映您在 40_custom 檔案中的編輯
重新啟動計算機
reboot
答案2
Grub 2.06 關閉 /etc/default/grub 中的 os-prober。
https://www.phoronix.com/news/Ubuntu-22.04-Multi-Boot-Changes
它掃描所有分割區以查找其他系統,存在某種安全性問題。您可以在 /etc/default/grub 中開啟/關閉。
最好只運行一次,然後將 Windows 啟動節複製到 40_custom 中。還可以使所有未來的更新更快,特別是如果您有很多分割區需要掃描。
sudoedit /etc/default/grub
然後根據需要更改為 true/false。真實推薦。
GRUB_DISABLE_OS_PROBER=true
您可以輕鬆地將引導節複製到 40_custom。
修復描述的一種方法是將 Windows 條目移至 40_custom 並隨意編輯。
從中複製條目:
sudo cp -a /boot/grub/grub.cfg /boot/grub/grub.cfg.backup
sudoedit /boot/grub/grub.cfg
將它們複製到並編輯以僅包含您想要的條目:
sudoedit /etc/grub.d/40_custom
對 grub 或 grub 腳本進行任何更改後,您必須更新 grub 選單。
sudo update-grub
Windows 10 和 Ubuntu 14.04 的 Grub 選單
os-prober 概括的典型 UEFI Windows 啟動節。每個 ESP - 都有一個唯一的 UUID 和 partUUID。 boot 節中的 UUID 是 ESP 的 UUID。
### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows Boot Manager (on /dev/nvme0n1p1)' --class windows --class os $menuentry_id_option 'osprober-efi-F8FD-D8E5' {
insmod part_gpt
insmod fat
search --no-floppy --fs-uuid --set=root F8FD-D8E5
chainloader /efi/Microsoft/Boot/bootmgfw.efi
}
如果使用上面的節,您必須更新到您的 UUID,並且不需要使用 os-prober 的註解。查看 ESP 的 UUID。
lsblk -f
注意:Grub 僅啟動工作 Windows。且 UEFI 安全啟動必須關閉。 Windows 通常會透過更新重新開啟 Windows 快速啟動。因此,您必須使用 UEFI 一次性啟動鍵直接啟動 Windows,通常是 f12,但因供應商而異。
答案3
1. 列出磁碟和分割區
lsblk
2. 識別包含 Windows 分割區的磁碟。
sudo cfdisk /dev/sd<YOUR DISK LETTER (NO NUMBER)>
- 使用垂直箭頭鍵循環瀏覽您的裝置。
- EFI 分割區將是類型為「EFI System」的設備。
- 複製 EFI 設備的「檔案系統 UUID」。 (XXXX-XXXX)
[ Quit ]
使用鍵盤的箭頭鍵進行選擇。按 Enter 鍵退出 cfdisk。
3. 打開 /etc/grub.d/40_custom
在您最喜歡的編輯器中 ( nano
, vim
, code
)
sudo nano /etc/grub.d/40_custom
4. 在評論下方新增您的選單項目。
menuentry 'Windows 11' {
search --fs-uuid --no-floppy --set=root <YOUR "File system UUID">
chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi
}
5. 更新您的 grub 設定。
sudo grub-mkconfig -o /boot/grub/grub.cfg
完成與sudo reboot
答案4
至少對我來說,這就是解決問題的方法。作業系統探測器已停用。我使用的是 Ubuntu 22.04
sudo nano /etc/default/grub
放GRUB_DISABLE_OS_PROBER=false
然後運行
sudo update-grub