AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 785281
Accepted
A.L
A.L
Asked: 2024-10-18 21:02:22 +0800 CST2024-10-18 21:02:22 +0800 CST 2024-10-18 21:02:22 +0800 CST

安装在 USB 密钥上的 Debian 12.7 可以在 Intel CPU 上运行,但不能在 AMD 上运行:grub 从未加载

  • 772

我使用带有 Intel CPU( Core i7 3770K )的计算机在 USB 密钥上安装了 Debian 12(amd64因为我使用的是 arch ) 。我将“BIOS”配置为仅 UEFI。debian-12.7.0-amd64-DVD-1.iso

我可以毫无问题地在此系统上启动 Debian:我看到 GRUB,它在启动 Debian 之前超时,然后系统启动。

但是,当我将此 USB 密钥插入带有 AMD CPU( Ryzen 7 5800X )的计算机时,它从未启动:我可以从启动菜单中选择该 Debian 实例,但当我按 Enter 时,它会返回到该屏幕。 2 次尝试后,它只显示黑屏。 它从未到达 GRUB 屏幕。

两个系统都配置为仅 UEFI,并且安全启动被禁用。

缺少一些驱动程序吗?据我所知,Debian(和 Linux)是可移植的:我们可以将带有 Linux 系统的存储移动到另一台计算机并启动它,只要它们具有相同的架构,就不会出现任何问题。

使用 Intel CPU 进行测试

启动菜单:

在此处输入图片描述

存储和分区:

root@serveur:~# fdisk -l
Disk /dev/sda: 7.46 GiB, 8014528512 bytes, 15653376 sectors
Disk model: Freecom Databar 
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: gpt
Disk identifier: F3F8597A-E3A9-4340-B561-976463C941D7

Device       Start      End  Sectors  Size Type
/dev/sda1     2048  1050623  1048576  512M EFI System
/dev/sda2  1050624 13941248 12890625  6.1G Linux filesystem

root@serveur:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.6G     0  7.6G   0% /dev
tmpfs           1.6G  724K  1.6G   1% /run
/dev/sda2       6.0G  2.0G  3.7G  35% /
tmpfs           7.6G     0  7.6G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/sda1       511M  5.9M  506M   2% /boot/efi
tmpfs           1.6G     0  1.6G   0% /run/user/1000

root@serveur:~# tree /boot/efi/
/boot/efi/
└── EFI
    └── debian
        ├── BOOTX64.CSV
        ├── fbx64.efi
        ├── grub.cfg
        ├── grubx64.efi
        ├── mmx64.efi
        └── shimx64.efi

3 directories, 6 files

root@serveur:~# ls -lh /boot/efi/EFI/debian/
total 5.9M
-rwx------ 1 root root  108 Oct 16 21:58 BOOTX64.CSV
-rwx------ 1 root root  86K Oct 16 21:58 fbx64.efi
-rwx------ 1 root root  126 Oct 16 21:58 grub.cfg
-rwx------ 1 root root 4.1M Oct 16 21:58 grubx64.efi
-rwx------ 1 root root 831K Oct 16 21:58 mmx64.efi
-rwx------ 1 root root 938K Oct 16 21:58 shimx64.efi

root@serveur:~# efibootmgr -v 
BootCurrent: 0000
Timeout: 1 seconds
BootOrder: 0000
Boot0000* debian    HD(1,GPT,84ba4a07-f69b-4768-a2c6-841363bcaa45,0x800,0x100000)/File(\EFI\debian\shimx64.efi)

root@serveur:~$ cat /etc/fstab
[…]
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sdb2 during installation
UUID=ce54e770-e3ba-44a0-8dd1-5b9308e18eac /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sdb1 during installation
UUID=B2A6-2FC0  /boot/efi       vfat    umask=0077      0       1

root@serveur:~# lsblk -o name,mountpoint,label,size,uuid 
NAME   MOUNTPOINT LABEL  SIZE UUID
sda                      7,5G 
├─sda1 /boot/efi  BOOT   512M B2A6-2FC0
└─sda2 /                 6,1G ce54e770-e3ba-44a0-8dd1-5b9308e18eac

检查是否使用了 UEFI 模式:

root@serveur:~# ls -lh /sys/firmware/efi
total 0
-r--r--r--  1 root root 4.0K Oct 18 19:25 config_table
drwxr-xr-x  2 root root    0 Aug 25 19:35 efivars
-r--r--r--  1 root root 4.0K Oct 18 19:25 fw_platform_size
-r--r--r--  1 root root 4.0K Oct 18 19:25 fw_vendor
drwxr-xr-x  2 root root    0 Oct 18 19:25 mok-variables
-r--r--r--  1 root root 4.0K Oct 18 19:25 runtime
drwxr-xr-x 16 root root    0 Oct 18 19:25 runtime-map
-r--------  1 root root 4.0K Oct 18 19:25 systab

使用 AMD CPU 进行测试

启动菜单:

在此处输入图片描述

由于某种原因,Debian 条目以 开头UEFI: 。

突出显示选择不起作用:它返回到该屏幕。

但是,有一件有趣的事情:我sudo update-grub从我的主要安装(安装在这台计算机上的 Ubuntu 24.04,如上所示,它位于 NVMe SSD 上)运行:

$ sudo update-grub
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.8.0-47-generic
Found initrd image: /boot/initrd.img-6.8.0-47-generic
Found linux image: /boot/vmlinuz-6.8.0-45-generic
Found initrd image: /boot/initrd.img-6.8.0-45-generic
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Windows Boot Manager on /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi
Found Debian GNU/Linux 12 (bookworm) on /dev/sda2
Adding boot menu entry for UEFI Firmware Settings ...
done

它检测到 Debian 12 并向我的主 GRUB(而不是 USB 记忆棒上的 GRUB)添加了一个条目,我能够从这个 GRUB 菜单毫无问题地启动 Debian 12。

因此,看起来 USB 上的 GRUB 只能在 Intel 计算机上使用。而 Debian 本身在通过 SSD 上的 GRUB 启动时没有问题。

debian
  • 2 2 个回答
  • 68 Views

2 个回答

  • Voted
  1. Best Answer
    td211
    2024-10-23T19:33:35+08:002024-10-23T19:33:35+08:00

    默认情况下,Debian 安装程序(可能还有其他安装程序)安装 GRUB 时不考虑可移动驱动器。您只需使用该--removable标志重新安装 GRUB,即可使其在其他 PC 上轻松启动。

    这与 Intel 或 AMD CPU 无关(无论如何都是 x86_64)。

    • 2
  2. telcoM
    2024-10-24T14:28:52+08:002024-10-24T14:28:52+08:00

    当您在 UEFI 模式下安装 Debian 12 时,安装程​​序会执行grub-install写入/boot/efi/EFI/debian/grubx64.efi(并且/boot/efi/EFI/debian/shimx64.efi如果安装了安全启动支持)USB 密钥的 ESP 分区的操作。

    但它所做的还不止这些。它还使用 UEFI 运行时服务将一些信息(称为UEFI 引导变量)存储到系统 NVRAM:BIOS 设置也存储在这里。您可以以efibootmgr -vroot 身份使用命令或通过访问efivarfs上的虚拟文件系统来查看这些 UEFI 引导变量/sys/firmware/efi/efivars/。

    UEFI 启动变量包含以下信息:

    • 启动项的名称,debian在你的情况下是
    • 包含 UEFI 引导加载程序的 EFI 系统分区 (ESP) 的 PARTUUID
    • 一些用于识别 ESP 的冗余信息(磁盘号、分区起始偏移量、分区长度),以防 PARTUUID 识别不成功
    • ESP 上的引导加载程序文件的路径名(\EFI\debian\shimx64.efi如果使用安全启动支持,则为,\EFI\debian\grubx64.efi否则为)

    对于普通硬盘和固态硬盘来说,这没问题。但对于可移动介质(如 USB 密钥),当 USB 密钥从一个系统移动到另一个系统时,这些信息就会被遗留。

    一旦将 USB 密钥插入 AMD 系统,该系统就会发现密钥显然包含有效的 ESP 分区,因此它会显示UEFI: <product name of the USB key>, Partition 1在启动菜单中。但由于 UEFI 启动变量数据未从 Intel 系统传输过来,因此系统无法知道它应该加载shimx64.efi还是grubx64.efi从EFI/debianESP 分区的目录中加载。

    对于可移动介质(以及 NVRAM 数据丢失的情况),UEFI 规范定义了特定于体系结构的可移动介质/后备启动路径,当系统看到看似有效的 ESP 分区但没有引用它的 UEFI 启动变量时,可以使用该路径。对于 x86_64 体系结构,此启动路径\EFI\boot\bootx64.efi由固件表示,或者/boot/efi/EFI/boot/bootx64.efi如您在 Debian 中看到的那样。

    换句话说,要使可移动媒体不仅在其创建时的系统上可 UEFI 启动,而且在其可能插入的所有 UEFI 系统中均可启动,引导加载程序文件必须具有该特定路径名。当然grub-install可以做到这一点……但前提是您使用或选项明确要求这样做。前一个选项将引导加载程序文件仅放置在可移动媒体/后备路径中;后一个选项以正常方式设置引导加载程序的一个副本,然后在后备路径中创建另一个副本。--removable--force-extra-removable

    不幸的是,Debian 12 安装程序不会自动检测到操作系统正在安装到可移动磁盘,也不会突出显示将 UEFI 引导加载程序安装到可移动媒体/后备路径的选项。如果您要将 UEFI 可引导的 Debian 12 安装到可移动媒体,则必须了解这一点并在主安装完成后自行执行。

    在英特尔系统上从 USB 密钥成功启动后,您只需一个命令即可纠正此缺陷:

    grub-install --removable
    
    • 2

相关问题

  • GRUB 配置以识别同一 Linux 发行版的不同桌面环境(安装)

  • astyle 不会更改源文件格式

  • 接收有关全新 Debian 的电子邮件

  • Debian Stretch:libgs_plugin_systemd-updates.so 中的 gnome-software 段错误

  • 如何在拼音输入法中输入ü?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve