首先,我有几个战略问题:
- 即使我想在外部 SSD 上安装 grub2,Ubuntu 安装程序也会在 UEFI 硬件上自动以 UEFI 模式调用 grub-install。我可以避免这种情况吗,即使用旧版 BIOS/MBR 模式 grub2 启动?就我而言,Ubuntu 2019.04 在 UEFI 笔记本电脑上以 MBR 模式安装在外部 SSD 上,并将 EFI 分区指向 Windows 的 GPT EFI 分区 (/dev/sdb1),这样我只能在同一台笔记本电脑或具有相同 Windows GPT EFI 分区的 PC 上启动 Ubuntu。
- grub2 能否完美处理由 gdisk 转换为 GPT 且未为 EFI 或 grub2 分区保留空间的 MBR 分区表?是否需要移动现有分区以在磁盘开头为 UEFI 或 grub2 分区腾出空间?如何告诉 grub2 将 Windows UEFI 分区的内容以改编形式复制到(外部)SSD 磁盘,以便它可以在没有 Windows 的其他 PC/笔记本电脑上作为外部 SSD 独立启动?到目前为止,使用 cp、tar 或 dd 复制分区并调用 grub-install 对我来说不起作用 - 导致以下错误。SSD 必须使用标志 --removable 吗?
理想情况下,我希望创建一个多启动系统,其中包含 Windows 10 和不同的 Linux 变体 - 全部可通过 grub2 启动。我该如何做才能尽可能顺利地运行?
a) 在安装 Windows 10 之前我应该做什么?我应该为 grub2 创建一个小的 GPT 分区并将其标记为这样吗?我应该为 Windows 和不同的 Linux 变体创建不同的 EFI 分区吗?
b) 我应该先安装 Windows 10 还是先安装 Linux?
c) 是否可以将 EFI 分区放入 MBR SSD 上的逻辑分区空间,例如 /dev/sda5?
d) EFI 分区或 grub2 的小 GPT 分区必须是磁盘/SSD 上的第一个分区(正如一些矛盾的来源所声称的那样)?
e) 有没有一种简单的方法可以将 /boot 分区重新集成到主 Linux 安装中并告知 grub2?我认为困难的方法(一旦 grub2 安装成功)是相应地调整 grub.cfg 文件并将文件一起复制到一个分区中。
我正在尝试使用任何最新的 Ubuntu 版本修复 /dev/sdb 中损坏的 grub2 启动:我准备了以下语句:配置:/boot = /dev/sdb1,/ = /dev/sdb3,UEFI = /dev/sdb4(由此脚本创建)
sudo fdisk /dev/sdb # possibly convert to GPT; create partition 4 of type EFI: code ef
sudo gdisk /dev/sdb # create partition 4 of type EFI: code ef00
sudo partprobe
sudo mkdir -p /tmp/lin1/mnt/boot
sudo mount -o nouuid /dev/sdb3 /tmp/lin1
sudo mount -o nouuid /dev/sdb1 /tmp/lin1/boot
sudo mkdir /tmp/lin1/mnt/boot
sudo mkfs.fat /dev/sdb4
sudo mkdir -p /tmp/lin1/mnt/efi
sudo mount -o nouuid /dev/sdb4 /tmp/lin1/mnt/efi
sudo mount -o nouuid /dev/sdb1 /tmp/lin1/boot
sudo bash -c 'for i in /dev /dev/pts /proc /sys /run /sys/firmware/efi/efivars /bin /usr /var /etc; do mkdir -p /tmp/lin1$i; done'
sudo bash -c 'for i in /dev /dev/pts /proc /sys /run /sys/firmware/efi/efivars /bin /usr /var /etc; do mount -o nouuid -B $i /tmp/lin1$i; done'
sudo chroot /tmp/lin1/
sudo grub-install --efi-directory=/tmp/lin1/mnt/efi --boot-directory=/tmp/lin1/boot --target=x86_64-efi /dev/sdb
sudo bash -c 'for i in /dev /dev/pts /proc /sys /run /sys/firmware/efi/efivars /bin /usr /var /etc; do umount /tmp/lin1$i; done'
sudo umount /tmp/lin1/mnt/boot
sudo umount /tmp/lin1/boot
sudo umount /tmp/lin1/
sudo sync
sudo hdparm -Y /dev/sdb
我遇到了以下 7 个问题(这些问题都是在与上面显示的几乎相同的 grub-install 之后偶尔发生的,具体取决于主机系统、Ubuntu 版本、是否存在额外的 Windows10 UEFI 分区以及 SSD 是内部连接还是外部连接):
在启动时:正在为 /dev/disk/by-uuid/... 运行启动作业。(在调整 /etc/fstab 中的块 ID 之后也是如此)
Ubuntu systemd:从 PID(plymouthd)收到 SIGRTMIN+20**
Ubuntu 内核:ucsi_ccg 0-0008:无法重置 PPM!
- Ubuntu 内核:ucsi_ccg 0-0008:PPM 初始化失败(-110)
- Grub:错误:未找到文件‘/grub2/i386-pc/normal.mod’-进入救援模式(正常的 Ubuntu 2019.04 x64 EFI 安装目录是 /grub/x86_64-efi)
Grub 启动:**
/dev/disk/by-uuid/CA82-D0E8 上的文件系统检查依赖项失败 /boot/efi 上的依赖项失败
chroot:无法运行命令‘/usr/bin/bash’:没有此文件或目录:
有问题的部分:
soc1@soc1-MS-7B17:/bin$ sudo chroot /tmp/lin1/ /usr/bin/bash
chroot: failed to run command ‘/usr/bin/bash’: No such file or directory
soc1@soc1-MS-7B17:/bin$ ll /usr/bin/bash
-rwxr-xr-x 1 root root 1113504 Nov 20 20:00 /usr/bin/bash*
soc1@soc1-MS-7B17:/bin$ ll /bin/bash
-rwxr-xr-x 1 root root 1113504 Jun 7 00:28 /bin/bash*
诊断输出:
soc1@soc1-MS-7B17:/bin$ strace -f chroot /tmp/lin1 /usr/bin/bash 2>&1
execve("/usr/sbin/chroot", ["chroot", "/tmp/lin1", "/usr/bin/bash"], 0x7fffe4c6c0f8 /* 62 vars */) = 0
brk(NULL) = 0x558749ead000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=74469, ...}) = 0
mmap(NULL, 74469, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fdf1d749000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260\34\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2030544, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fdf1d747000
mmap(NULL, 4131552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fdf1d144000
mprotect(0x7fdf1d32b000, 2097152, PROT_NONE) = 0
mmap(0x7fdf1d52b000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e7000) = 0x7fdf1d52b000
mmap(0x7fdf1d531000, 15072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fdf1d531000
close(3) = 0
arch_prctl(ARCH_SET_FS, 0x7fdf1d748540) = 0
mprotect(0x7fdf1d52b000, 16384, PROT_READ) = 0
mprotect(0x55874974a000, 4096, PROT_READ) = 0
mprotect(0x7fdf1d75c000, 4096, PROT_READ) = 0
munmap(0x7fdf1d749000, 74469) = 0
brk(NULL) = 0x558749ead000
brk(0x558749ece000) = 0x558749ece000
openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=10281936, ...}) = 0
mmap(NULL, 10281936, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fdf1c775000
close(3) = 0
lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
lstat("/tmp/lin1", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
chroot("/tmp/lin1") = -1 EPERM (Operation not permitted)
openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2995, ...}) = 0
read(3, "# Locale name alias data base.\n#"..., 4096) = 2995
read(3, "", 4096) = 0
close(3) = 0
openat(AT_FDCWD, "/usr/share/locale/en_US.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_US.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en_US.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en_US.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=578, ...}) = 0
mmap(NULL, 578, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fdf1d75b000
close(3) = 0
write(2, "chroot: ", 8chroot: ) = 8
write(2, "cannot change root directory to "..., 43cannot change root directory to '/tmp/lin1') = 43
openat(AT_FDCWD, "/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": Operation not permitted", 25: Operation not permitted) = 25
write(2, "\n", 1
) = 1
close(1) = 0
close(2) = 0
exit_group(125) = ?
+++ exited with 125 +++