首先,我有一些策略問題:
- 即使我想在外部 SSD 上安裝 grub2,Ubuntu 安裝程式也會自動在 UEFI 硬體上以 UEFI 模式呼叫 grub-install。我可以避免這種情況,即使用舊版 BIOS/MBR 模式 grub2 開機嗎?就我而言,Ubuntu 2019.04 在UEFI 筆記型電腦上以MBR 模式安裝在外部SSD 上,並將EFI 分割區指向Windows 的GPT EFI 分割區(/dev/sdb1),這樣我只能在同一台筆記型電腦或PC 上啟動Ubuntu具有相同的 Windows GPT EFI 分割區。
- 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 分割區並將其標記為這樣嗎?我是否應該建立不同的 EFI 分割區,例如針對 Windows 和不同的 Linux 變體?
b) 我應該先安裝 Windows 10 再安裝 Linux,還是反之亦然?
c) 是否可以將EFI 分割區放入MBR SSD 上的邏輯分割區空間,例如/dev/sda5?
d) grub2 的 EFI 分割區或小型 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 安裝之後偶爾發生的,具體取決於主機系統、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 +++