2

I have recently cloned the filesystem partition from an HDD to an SSD using dd. I am quite sure the cloning was successful (because I am using it), but I forgot to clone the boot partition. Since the boot partition does not exist in the SSD, I cannot boot it unless I plug the old HDD as well. Basically, I am using the SSD but the boot partition mounted comes from the HDD. I was initially surprised because I expected to boot the old filesystem partition, but the filesystem partitions' UUIDs are the same, so I guess the first found is the one from the SSD.

The current situation is: hdd overview Here the only mounted partition is sdb1 on /boot/efi (In the picture I manually unmounted it while doing some tests).

ssd overview

I also tried to boot from a live USB, then I plugged the SSD and run boot-repair but it does not even show the Recommended repair option. This is the boot info generated:

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&gt; /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.

As you can read from the Suggested repair paragraph, boot-repair cannot help me. The question is: Can I solve this without cloning the boot partition? I read that the boot partition is not necessary, but copying the files from the boot partition directly into the ssd /boot/efi folder did not solve the issue. It is probably a silly idea, which is the reason I am posting a new question: I have found many articles/discussions on this topic, but I am completely lost right now. Should I start over and create a new partition where I can clone the boot partition from the HDD? Would that work and would the boot loader find it? Or can I solve this easily (and safely)?

  • 1
    You are confusing ESP with boot partition. ESP is the (U)EFI System Partition. While boot partition usually refers to the partition for Linux refers to the partition mounted as /boot mount point. Unless you opt for full disk encryption, Ubuntu desktop installation does not create a /boot/ partition. It looks like your HDD didn't have a /boot partition to begin with. ESP is part of the UEFI, what used to be called the BIOS. You need at least one ESP in your computer. It need not be in the the SSD, but files in the ESP should refer to the SSD so that booting can continue from it. – user68186 Apr 27 '23 at 23:09
  • 1
    Thanks @user68186 , so I need to create an ESP partition right? Could you please share some links on how to do that in this specific case? Thanks – Marco Luzzara Apr 27 '23 at 23:18
  • 2
    The trouble is when you cloned the Ubuntu partition / from your HDD to SDD, it looks like it didn't create a partition inside the SDD.. Normally one should have a single partition say /dev/sda1 spanning the whole SSD. If that was the case, you could have shrunk the partition and created another smaller partition for ESP. You can't do this now, as your whole SSD (in other words /dev/sda is directly formatted as ext4. I suggest you start over again by formatting the SSD first and by that process create o big partition. Shrink it to make pace for the ESP partition. – user68186 Apr 28 '23 at 02:03
  • 1
    Then clone the ESP and Ubuntu partitions in those empty partitions. Finally disconnect the HDD and boot from a Live Ubuntu installation USB with the Try Ubuntu option and run boot-repair to fix the remaining problems. I have no idea if that will work or not. – user68186 Apr 28 '23 at 02:06
  • 2
  • 3
    You will need to create a partition table of the type GPT when you start over and before you start creating partitions. – user68186 Apr 28 '23 at 02:19
  • Thank you very much @user68186 ! I followed your advices and it works – Marco Luzzara Apr 28 '23 at 21:30

1 Answers1

2

Eventually I started over, as suggested by @user68186 . Here is the procedure that worked for me:

  • Format the volume (with the Disks app if possible) and erase the content. The format type is not important
  • Install GParted (sudo apt install gparted), open it and format the volume as "cleared". Apply the changes
  • Create a new partition table on the cleared volume, so go to Device -> Create Partition Table... and select gpt.
  • Now create two partitions:
    • The second one is placed immediately after the first partition and is formatted as ext4. This partition will contain the entire filesystem, and in my case it occupies all the remaining space in the SSD.

Now clone the old partitions into the new ones: I have used dd, but there are many other (probably safer) approaches. This is the command I have used:

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

where sda_old is the old partition and sdb_new is the new one. I run this command for both the FAT32 and ext4 partitions, ending up with a full-fledged cloning of my HDD.

I rebooted my computer and it worked (showing some weird logs at startup but it still booted). If you happen to get an error of any kind, try running ubuntu with a Live USB and install boot-repair, as suggested in the comments.


After this, I have encountered some issues with the package manager commands. In particular, this error:

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.

To fix this, follow this procedure.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. – Community Apr 29 '23 at 08:45