1

I have two disks each with two partitions, one SSD (/dev/sdb) which had the main boot partition and another HDD (/dev/sda) for backup.

Then I cloned the SSD's main partition (which had the boot) with dd, within a USB live environment, to a partition in the backup HDD:

dd if=/dev/sdb2 of=/dev/sda2

Now, after I rebooted, the system is starting/booting from the cloned partition /dev/sda2!!!

How do I set which partition the system should startup/boot? I want to startup with /dev/sdb2 and NOT /dev/sda2, because SSDs are much faster than HDDs.

Further info:

Relevant output of fdisk -l for both disks:

Disk /dev/sda: 1,84 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: WDC WD20EZAZ-00L
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 350C6598-6531-43D3-9303-26B80124EDDA

Device Start End Sectors Size Type /dev/sda1 2048 1953128447 1953126400 931,3G Linux filesystem /dev/sda2 1953128448 3907028991 1953900544 931,7G Linux filesystem

Disk /dev/sdb: 931,53 GiB, 1000204886016 bytes, 1953525168 sectors Disk model: Samsung SSD 870 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: 881AE800-FEC8-4EEA-B0C5-5CAE0E2B47F2

Device Start End Sectors Size Type /dev/sdb1 2048 1050623 1048576 512M EFI System /dev/sdb2 1050624 1953523711 1952473088 931G Linux filesystem

Relevant output of lsblk:

...
sda      8:0    0   1,8T  0 disk 
├─sda1   8:1    0 931,3G  0 part /mnt/backupA
└─sda2   8:2    0 931,7G  0 part /
sdb      8:16   0 931,5G  0 disk 
├─sdb1   8:17   0   512M  0 part /boot/efi
└─sdb2   8:18   0   931G  0 part 

1 Answers1

1

After a full morning around the issue (Linux is challenging :), and thanks to users that commented, and also to share info to other users, I share my conclusions:

  • since there are two exact copies of the same data in two different partitions (/dev/sda2 and /dev/sdb2) thus also having the same UUID, the system was starting always with /dev/sda2 as root /

  • apparently /etc/fstab root / mounting point is ignored except when UUID is set. I tried setting /dev/sdb2 / ... in /etc/fstab in both partitions (original and cloned) and the system was always starting with /dev/sda2 instead. Therefore don't use /dev/sdbx in /etc/fstab for the root mounting point / because it does not work.

  • after investigation, I realized the UUID of the root partition was appearing at least in 3 different locations:

    A) /boot/efi/EFI/ubuntu/grub.cfg
    B) /proc/cmdline
    C) /etc/fstab

  • Therefore the safest solution, as also suggested in the comments, was to change the UUID of the cloned partition.

What I did

  1. I started the computer in live environment with USB stick since the partition whose UUID was to be amended must be unmounted

  2. Then I ran tune2fs /dev/sda2 -U random to alter the UUID of /dev/sda2 (cloned partition). Before running tune2fs I had to run also e2fsck /dev/sda2 -f -p because tune2fs demanded so.

  3. Confirm it with sudo blkid.