UUID conflict of two disks having same Ubuntu 20.04
Cloned Ubuntu 20.04 from m.2 SSD to nvme SSD. UUID on nvme newly generated after cloning. Both are working but with following rider :
The UUID in fstab of nvme ubuntu must be the UUID of SSD ubuntu otherwise gives error " Failed to start Remount Root and Kernel Filesystems".
But both Ubuntu partitions are working independently as the nvme version version is updated to 20.04.03 from 20.04.01 originally. The version on SSD is still 20.04.01.
If the respective UUID entered in fstab then both partitions are not booting up.
I am having legacy boot BIOS and using Clover bootloader having GPT fs on both the disks.
$ lsblk -o name,size,fstype,label,uuid,mountpoint,model|sed 's/ *$//';
NAME SIZE FSTYPE LABEL UUID MOUNTPOINT MODEL
loop0 185.4M squashfs /snap/audacity/920
loop1 185.3M squashfs /snap/audacity/922
loop2 4K squashfs /snap/bare/5
loop3 99.4M squashfs /snap/core/11993
loop4 61.9M squashfs /snap/core20/1169
loop5 99.5M squashfs /snap/core/11798
loop6 55.4M squashfs /snap/core18/2128
loop7 219M squashfs /snap/gnome-3-34-1804/66
loop8 55.5M squashfs /snap/core18/2246
loop9 61.8M squashfs /snap/core20/1081
loop10 140K squashfs /snap/gtk2-common-themes/13
loop11 65.2M squashfs /snap/gtk-common-themes/1519
loop12 219M squashfs /snap/gnome-3-34-1804/72
loop13 32.4M squashfs /snap/snapd/13270
loop14 51M squashfs /snap/snap-store/542
loop15 65.1M squashfs /snap/gtk-common-themes/1515
loop16 42.2M squashfs /snap/snapd/13831
loop17 164.8M squashfs /snap/gnome-3-28-1804/161
loop18 51M squashfs /snap/snap-store/547
loop19 162.9M squashfs /snap/gnome-3-28-1804/145
sda 119.2G LS_128GB_M300
├─sda1 24G ext4 U20.04 64bit SSD 11bb7e9e-49c9-4e44-bc97-2b501f358e2b
├─sda2 555M vfat EFI-SSD 864B-9B3E
├─sda3 45G ntfs F894575794571788
├─sda4 102.9M vfat BDU-SSD 64BD-803B
├─sda5 500M ext4 2a2cb9ea-cb10-4154-ac48-8c8513559de3
└─sda6 49.2G ntfs 6C7A63467A630BE0
sdb 29G Storage_Device
├─sdb1 200M vfat BDU 7CCC-3457 /boot/efi
└─sdb2 28.8G
nvme0n1 232.9G Samsung SSD 970 EVO Plus 250GB
├─nvme0n1p1 100M vfat BDU-NVME 4860-509F
├─nvme0n1p2 46.5G ext4 U20.04 64bit SSD 5d01e76f-5114-4416-b810-5de33dafa914 /
└─nvme0n1p3 49.6G ext4 U18 NVME fd23fb07-2a0d-4b9c-962f-1d86f17e32df
fstab of ubuntu 20.04 on SSD
#/etc/fstab: static file system information.
#Use 'blkid' to print the universally unique identifier for a
#device; this may be used with UUID= as a more robust way to name devices
#that works even if disks are added and removed. See fstab(5).
#<file system> <mount point> <type> <options> <dump> <pass>
#/ was on /dev/sda1 during installation
#UUID=5d01e76f-5114-4416-b810-5de33dafa914 / ext4 errors=remount-ro 0 1
UUID=11bb7e9e-49c9-4e44-bc97-2b501f358e2b / ext4 errors=remount-ro 0 1 /swapfile
none swap sw 0 0
#UUID=4860-509F /boot/efi vfat defaults 0 1
#UUID=4860-509F /boot/efi vfat defaults 0 1
#UUID=4860-509F /boot/efi vfat defaults 0 1
#UUID=4860-509F /boot/efi vfat defaults 0 1
#UUID=B092-D69A /boot/efi vfat defaults 0 1
#UUID=864B-9B3E /boot/efi vfat defaults 0 1
#UUID=864B-9B3E /boot/efi vfat defaults 0 1
UUID=864B-9B3E /boot/efi vfat defaults 0 1
fstab of ubuntu of 20.04 on NVME
#/etc/fstab: static file system information.
#Use 'blkid' to print the universally unique identifier for a
#device; this may be used with UUID= as a more robust way to name devices
#That works even if disks are added and removed. See fstab(5).
#<file system> <mount point> <type> <options> <dump> <pass>
#/ was on /dev/sda1 during installation
UUID=11bb7e9e-49c9-4e44-bc97-2b501f358e2b / ext4 errors=remount-ro 0 1
#UUID=5d01e76f-5114-4416-b810-5de33dafa314 / ext4 errors=remount-ro 0 1
/swapfile none swap sw 0 0
UUID=4860-509F /boot/efi vfat defaults 0 1
Issue resolved by going through the Update #1 in the answer below.
Solution 1:
When you clone a disk, everything gets cloned, including the disk and partition UUIDs. That becomes a problem when both disks are connected to the system at the same time.
You need to change the UUID on the original disk, or the clone disk. However, if you change the UUID on the original disk, you'll have to also edit /etc/fstab. If you change the UUID on the clone disk, no /etc/fstab edits are required (unless the clone disk is eventually installed into the system, in place of the original disk, and then /etc/fstab will need to be updated with the new UUID, or /dev/sdaX device name).
Note: There should be no reason to mount both the original disk, and the cloned disk, by additional edits to /etc/fstab. A clone disk is normally used to create a backup, or to transfer from a smaller original disk, to a larger clone disk, and then exchanged in the system.
Note: Clone disk booting issues can normally be fixed by the use of boot-repair
.
There are two commands required to make UUID changes. See the following man pages...
man uuidgen
man tune2fs
uuidgen
example: uuidgen -r
or uuidgen -t
-r, --random
Generate a random-based UUID. This method creates a UUID con‐
sisting mostly of random bits. It requires that the operating
system have a high quality random number generator, such as
/dev/random.
-t, --time
Generate a time-based UUID. This method creates a UUID based on
the system clock plus the system's ethernet hardware address, if
present.
tune2fs
example: sudo tune2fs -U new_UUID /dev/sdbX
-U UUID
Set the universally unique identifier (UUID) of the filesystem
to UUID. The format of the UUID is a series of hex digits sepa‐
rated by hyphens, like this:
"c1b9d5a2-f162-11cf-9ece-0020afc76f16". The UUID parameter may
also be one of the following:
clear clear the filesystem UUID
random generate a new randomly-generated UUID
time generate a new time-based UUID
The UUID may be used by mount(8), fsck(8), and /etc/fstab(5)
(and possibly others) by specifying UUID=uuid instead of a block
special device name like /dev/hda1.
See uuidgen(8) for more information. If the system does not
have a good random number generator such as /dev/random or
/dev/urandom, tune2fs will automatically use a time-based UUID
instead of a randomly-generated UUID.
Update #1:
corrected fstab of ubuntu of 20.04 on NVME
Note: there should be no TABS in fstab, only spaces
#/etc/fstab: static file system information.
#Use 'blkid' to print the universally unique identifier for a
#device; this may be used with UUID= as a more robust way to name devices
#That works even if disks are added and removed. See fstab(5).
#<file system> <mount point> <type> <options> <dump> <pass>
#/ was on /dev/nvme0n1p2 during installation
UUID=5d01e76f-5114-4416-b810-5de33dafa914 / ext4 errors=remount-ro 0 1
/swapfile none swap sw 0 0
UUID=4860-509F /boot/efi vfat defaults 0 1