启动 ubuntu 无需启动分区

启动 ubuntu 无需启动分区

我最近使用 将文件系统分区从 HDD 克隆到 SSD dd。我很确定克隆成功了(因为我正在使用它),但我忘记克隆启动分区了。由于启动分区不存在于 SSD 中,因此除非我也插入旧 HDD,否则我无法启动它。基本上,我正在使用 SSD,但安装的启动分区来自 HDD。我最初很惊讶,因为我预计会启动旧的文件系统分区,但文件系统分区的 UUID 相同,所以我猜第一个找到的是来自 SSD 的 UUID。

目前的情况是: 硬盘概述 这里唯一挂载的分区是sdb1打开的/boot/efi(在图片中,我在做一些测试时手动卸载了它)。

SSD 概述

我还尝试从实时 USB 启动,然后插入 SSD 并运行,boot-repair但它甚至没有显示Recommended repair选项。这是生成的启动信息:

boot-repair-4ppa2056                                              [20230427_1948]

============================== Boot Info Summary ===============================


sda: ___________________________________________________________________________

    File system:       ext4
    Boot sector type:  -
    Boot sector info: 
    Operating System:  Ubuntu 22.04.2 LTS
    Boot files:        /boot/grub/grub.cfg /etc/fstab /etc/default/grub

sdb: ___________________________________________________________________________

    File system:       iso9660
    Boot sector type:  Grub2 (v1.99-2.00)
    Boot sector info:  Grub2 (v1.99-2.00) is installed in the boot sector of 
                       sdb and looks at sector 0 of the same hard drive for 
                       core.img, but core.img can not be found at this 
                       location.
    Mounting failed:   mount: /mnt/BootInfo/FD/sdb: /dev/sdb already mounted or mount point busy.


================================ 0 OS detected =================================


================================ Host/Hardware =================================

CPU architecture: 64-bit
Video: Skylake GT2 [HD Graphics 520] Sun XT [Radeon HD 8670A/8670M/8690M / R5 M330 / M430 / Radeon 520 Mobile] from Intel Corporation Advanced Micro Devices, Inc. [AMD/ATI]
Live-session OS is Ubuntu 64-bit (Ubuntu 22.04.2 LTS, jammy, x86_64)

===================================== UEFI =====================================

BIOS/UEFI firmware: F.21(15.33) from Insyde
The firmware is EFI-compatible, and is set in EFI-mode for this live-session.
SecureBoot disabled (confirmed by mokutil).
BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 2001,2002,2004
Boot0000* USB Hard Drive (UEFI) - General UDisk PciRoot(0x0)/Pci(0x14,0x0)/USB(0,0)/HD(2,GPT,a0891d7e-b930-4513-94db-f629dbd637b2,0x92b094,0x2754)RC
Boot2001* EFI USB Device    RC
Boot2002* EFI DVD/CDROM RC


============================= Drive/Partition Info =============================

Disks info: ____________________________________________________________________


Partitions info (1/3): _________________________________________________________


Partitions info (2/3): _________________________________________________________


Partitions info (3/3): _________________________________________________________


fdisk -l (filtered): ___________________________________________________________

Disk sda: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk sdb: 7.5 GiB, 8053063680 bytes, 15728640 sectors
Disk identifier: A0891D7E-B930-4513-94D9-F629DBD637B2
        Start      End Sectors  Size Type
sdb1       64  9613459 9613396  4.6G Microsoft basic data
sdb2  9613460  9623527   10068  4.9M EFI System
sdb3  9623528  9624127     600  300K Microsoft basic data
sdb4  9625600 15728576 6102977  2.9G Linux filesystem

parted -lm (filtered): _________________________________________________________

sda:500GB:scsi:512:4096:loop:ATA CT500MX500SSD1:;
1:0.00B:500GB:500GB:ext4::;
sdb:8053MB:scsi:512:512:gpt:General UDisk:;
1:32.8kB:4922MB:4922MB::ISO9660:hidden, msftdata;
2:4922MB:4927MB:5155kB::Appended2:boot, esp;
3:4927MB:4928MB:307kB::Gap1:hidden, msftdata;
4:4928MB:8053MB:3125MB:ext4::;

blkid (filtered): ______________________________________________________________

NAME   FSTYPE   UUID                                 PARTUUID                             LABEL                    PARTLABEL
sda    ext4     f8f87223-9d26-4ba6-a4ae-6447cf61605c                                                               
sdb    iso9660  2023-02-23-04-13-44-00                                                    Ubuntu 22.04.2 LTS amd64 
├─sdb1 iso9660  2023-02-23-04-13-44-00               a0891d7e-b930-4513-94d8-f629dbd637b2 Ubuntu 22.04.2 LTS amd64 ISO9660
├─sdb2 vfat     F7DB-4D56                            a0891d7e-b930-4513-94db-f629dbd637b2 ESP                      Appended2
├─sdb3                                               a0891d7e-b930-4513-94da-f629dbd637b2                          Gap1
└─sdb4 ext4     20f8183f-4ae7-41e8-a7e7-399cf0b70ff1 a3019bbf-abed-b74d-9444-ac9ebb99d47c writable                 

Mount points (filtered): _______________________________________________________

                                                               Avail Use% Mounted on
/dev/disk/by-label/writable[/install-logs-2023-04-27.0/crash]   2.6G   0% /var/crash
/dev/disk/by-label/writable[/install-logs-2023-04-27.0/log]     2.6G   0% /var/log
/dev/sdb1                                                          0 100% /cdrom

Mount options (filtered): ______________________________________________________


====================== sda/boot/grub/grub.cfg (filtered) =======================

Ubuntu   f8f87223-9d26-4ba6-a4ae-6447cf61605c
Ubuntu, with Linux 5.19.0-41-generic   f8f87223-9d26-4ba6-a4ae-6447cf61605c
Ubuntu, with Linux 5.19.0-40-generic   f8f87223-9d26-4ba6-a4ae-6447cf61605c
Ubuntu, with Linux 5.15.0-71-generic   f8f87223-9d26-4ba6-a4ae-6447cf61605c
### END /etc/grub.d/30_os-prober ###
UEFI Firmware Settings   uefi-firmware
### END /etc/grub.d/30_uefi-firmware ###

=========================== sda/etc/fstab (filtered) ===========================

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda2 during installation
UUID=f8f87223-9d26-4ba6-a4ae-6447cf61605c /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sda1 during installation
UUID=965C-26BF  /boot/efi       vfat    umask=0077      0       1
/swapfile                                 none            swap    sw              0       0

======================= sda/etc/default/grub (filtered) ========================

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

==================== sda: Location of files loaded by Grub =====================

           GiB - GB             File                                 Fragment(s)
 183.869487762 = 197.428359168  boot/grub/grub.cfg                             1
 158.846710205 = 170.560356352  boot/vmlinuz                                   2
 158.846710205 = 170.560356352  boot/vmlinuz-5.15.0-71-generic                 2
 411.003543854 = 441.311694848  boot/vmlinuz-5.19.0-40-generic                 1
 133.370731354 = 143.205732352  boot/vmlinuz-5.19.0-41-generic                 1
 133.370731354 = 143.205732352  boot/vmlinuz.old                               1
 154.984371185 = 166.413201408  boot/initrd.img                                4
 154.984371185 = 166.413201408  boot/initrd.img-5.15.0-71-generic              4
  74.997768402 = 80.528240640   boot/initrd.img-5.19.0-40-generic              2
 159.107086182 = 170.839932928  boot/initrd.img-5.19.0-41-generic              1
 159.107086182 = 170.839932928  boot/initrd.img.old                            1

====================== sda: ls -l /etc/grub.d/ (filtered) ======================

-rwxr-xr-x 1 root root 18683 Apr 15  2022 10_linux
-rwxr-xr-x 1 root root 43031 Apr 15  2022 10_linux_zfs
-rwxr-xr-x 1 root root 14180 Apr 15  2022 20_linux_xen
-rwxr-xr-x 1 root root 13369 Apr 15  2022 30_os-prober
-rwxr-xr-x 1 root root  1372 Apr 15  2022 30_uefi-firmware
-rwxr-xr-x 1 root root   700 Feb 21  2022 35_fwupd
-rwxr-xr-x 1 root root   214 Apr 15  2020 40_custom
-rwxr-xr-x 1 root root   215 Apr 15  2022 41_custom



Suggested repair: ______________________________________________________________

The default repair of the Boot-Repair utility would not act on the boot.

正如您从这段文字中读到的Suggested repairboot-repair无法帮助我。问题是:我不克隆启动分区就能解决这个问题吗?我读到启动分区不是必需的,但将文件从启动分区直接复制到 ssd/boot/efi文件夹并不能解决问题。这可能是一个愚蠢的想法,这就是我发布新问题的原因:我找到了很多关于这个主题的文章/讨论,但我现在完全不知所措。我是否应该重新开始并创建一个新的分区,以便从 HDD 克隆启动分区?这样做可行吗?引导加载程序会找到它吗?或者我可以轻松(安全地)解决这个问题吗?

答案1

最终,我按照@user68186的建议重新开始。以下是对我有用的程序:

  • 格式化卷(如果可能,使用磁盘应用程序)并删除内容。格式类型并不重要
  • 安装 GParted ( sudo apt install gparted),打开它并将卷格式化为“已清除”。应用更改
  • 在清除的卷上创建一个新的分区表,因此转到设备->创建分区表...并选择通用运输
  • 现在创建两个分区:
    • 第二个分区位于第一个分区之后,格式为ext4。此分区将包含整个文件系统,在我的情况下,它占用了 SSD 中所有剩余的空间。

现在将旧分区克隆到新分区中:我使用了dd,但还有许多其他(可能更安全)的方法。这是我使用的命令:

dd if=/dev/sda_old of=/dev/sdb_new bs=64K conv=sync,noerror status=progress

其中sda_old是旧分区,sdb_new是新分区。我对FAT32ext4分区都运行此命令,最终完成了硬盘的完整克隆。

我重启了电脑,它运行正常(启动时显示一些奇怪的日志,但仍然启动)。如果您碰巧遇到任何类型的错误,请尝试使用 Live USB 运行 ubuntu 并安装boot-repair,如评论中所建议。


在此之后,我遇到了一些与包管理器命令有关的问题。特别是这个错误:

dpkg: error processing package grub-efi-amd64-signed (--configure):
 installed grub-efi-amd64-signed package post-installation script subprocess returned error exit status 32
dpkg: dependency problems prevent configuration of shim-signed:
 shim-signed depends on grub-efi-amd64-signed (>= 1.187.2~) | grub-efi-arm64-signed (>= 1.187.2~); however:
  Package grub-efi-amd64-signed is not configured yet.
  Package grub-efi-arm64-signed is not installed.

要解决此问题,请按照此程序

相关内容