sudo update-grub 不起作用

sudo update-grub 不起作用

我最近在一台 Windows 10 计算机上安装了 Ubuntu 来实现双启动,但是由于我在安装过程中最初遇到了一些问题,导致分区变得有些混乱。

无论如何,现在 Ubuntu 可以正常启动,但我没有得到 grub 屏幕来选择使用哪个操作系统(换句话说,我被锁定在 Windows 之外)。

在一些教程中搜索后,我尝试写入sudo update-grub,但出现以下错误:

error: invalid volume.
grub-probe: error: cannot find a GRUB drive for /dev/sdb1.  Check your device.map.

没有任何内容涉及 Windows。

此外,sdb1 是我的硬盘(没有操作系统),而 windows 安装在 sda2 上(见下文)

另一方面,我仍然可以看到 上sudo fdisk -l或 下的Windows 分区Other Locations > SSD

有什么建议么?


更新:

这是我的分区:

Number  Start   End    Size    Type      File system     Flags
 1      1049kB  577MB  576MB   primary   ntfs
 2      577MB   167GB  166GB   primary   ntfs
 3      167GB   168GB  1024MB  primary   fat32           boot, esp
 4      168GB   254GB  86,0GB  extended
 5      168GB   174GB  5999MB  logical   linux-swap(v1)
 6      174GB   254GB  80,0GB  logical   ext4

列表配置 常规设置 外观设置

我也尝试添加

menuentry "Windows 10 (loader)"{
    insmod part_gpt
    search --set=root --file /EFI/Microsoft/Boot/bootmgfw.efi --fs-uuid DA02-12A2
    chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}

看这里,但我Error: invalid EFI file path在启动时得到了(/EFI/Microsoft/Boot/bootmgfw.efi实际上并不存在)。


更新2:

sudo fdisk-l:

Disk /dev/loop0: 93,94 MiB, 98484224 bytes, 192352 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop1: 9,7 MiB, 9510912 bytes, 18576 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop2: 54,97 MiB, 57614336 bytes, 112528 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop3: 242,43 MiB, 254193664 bytes, 496472 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop4: 54,97 MiB, 57618432 bytes, 112536 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop5: 240,82 MiB, 252493824 bytes, 493152 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop6: 160,16 MiB, 167931904 bytes, 327992 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop7: 49,8 MiB, 52203520 bytes, 101960 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sda: 238,49 GiB, 256060514304 bytes, 500118192 sectors
Disk model: ADATA SU800     
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0a7e098f

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sda1            2048   1126399   1124352  549M  7 HPFS/NTFS/exFAT
/dev/sda2         1126400 326035455 324909056  155G  7 HPFS/NTFS/exFAT
/dev/sda3  *    326035456 328036351   2000896  977M ef EFI (FAT-12/16/32)
/dev/sda4       328038398 496005119 167966722 80,1G  5 Extended
/dev/sda5       328038400 339755007  11716608  5,6G 82 Linux swap / Solaris
/dev/sda6       339757056 496005119 156248064 74,5G 83 Linux


Disk /dev/sdb: 931,53 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: WDC WD10EZEX-60W
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x9dba35c9

Device     Boot Start        End    Sectors   Size Id Type
/dev/sdb1          63 1953523119 1953523057 931,5G 42 SFS

Partition 1 does not start on physical sector boundary.




Disk /dev/loop8: 62,9 MiB, 65105920 bytes, 127160 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop9: 27,9 MiB, 28405760 bytes, 55480 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

答案1

修复无法看到 grub 菜单的问题

最新版本的 GRUB 隐藏了超时时间。您可以在启动时按住left-shift以显示该消息,或者编辑/boot/grub/grub.conf并删除hiddenmeu并将默认值设置为 10 秒左右timeout=10

对于 grub2,编辑该/etc/default/grub文件并做以下更改:

#GRUB_HIDDEN_TIMEOUT=0
GRUB_TIMEOUT=10

注意:#符号将注释掉GRUB_HIDDEN_TIMEOUT并启用菜单

完成更改后,运行sudo update-grub以应用更改。

在我看来,这就是它的样子/etc/default/grub

# If you change this file, run 'update-grub' afterwards to update

# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT="0"
GRUB_TIMEOUT_STYLE="hidden"
GRUB_TIMEOUT="5"
GRUB_DISTRIBUTOR="`lsb_release -i -s 2> /dev/null || echo Debian`"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL="console"

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE="640x480"

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID="true"

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

GRUB_SAVEDEFAULT="false"
export GRUB_COLOR_NORMAL="light-gray/black"
export GRUB_COLOR_HIGHLIGHT="magenta/black"  

您还可以尝试使用 GUI 编辑这些值“grub 定制器”可以从 Ubuntu 软件中心下载的软件。

Grub 定制器

修复在 grub 菜单中看不到 Windows 启动管理器的问题。

另外,你似乎已经在UEFI模式和 Windows传统 BIOS。您有 2 个选择。将 Windows 更改为UEFI或者将 Ubuntu 更改为传统 BIOS。建议将 Windows 更改为UEFI因为UEFI比更好、更先进传统 BIOS

1)将Windows更改为UEFI: 您可以通过重新安装 Windows 来实现这一点,或者您可以尝试执行这里无论您做什么,请让用户知道您有一个备份,以防万一。

2)将 Ubuntu 更改为传统 BIOS: 你可以通过重新安装 Ubuntu 来实现这一点,但请确保你没有选择UEFI选项。(UEFI选项将有“UEFI:“在安装介质名称之前。请注意UEFI选择权和传统 BIOS选项可能有所不同。欲了解更多信息,请阅读评论中的聊天内容。

相关内容