将 Ubuntu 20.04 从 m.2 SSD 克隆到 nvme SSD。克隆后,nvme 上的 UUID 新生成。两者都在工作,但有以下限制:
nvme ubuntu 的 fstab 中的 UUID 必须是 SSD ubuntu 的 UUID,否则会出现错误“无法启动重新安装根和内核文件系统”。
但是两个 Ubuntu 分区都在独立工作,因为 nvme 版本从最初的 20.04.01 更新为 20.04.03。SSD 上的版本仍然是 20.04.01。
如果在 fstab 中输入相应的 UUID,则两个分区都无法启动。
我使用的是旧式启动 BIOS,并使用在两个磁盘上都有 GPT fs 的 Clover 引导加载程序。
$ 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
SSD 上的 ubuntu 20.04 的 fstab
#/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
NVME 上 20.04 版 ubuntu 的 fstab
#/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
通过查看下面答案中的更新#1解决了问题。
答案1
克隆磁盘时,一切被克隆,包括磁盘和分区 UUID。当两个磁盘同时连接到系统时,这就会成为一个问题。
您需要更改原始磁盘或克隆磁盘上的 UUID。但是,如果您更改原始磁盘上的 UUID,则还必须编辑 /etc/fstab。如果您更改克隆磁盘上的 UUID,则无需编辑 /etc/fstab(除非克隆磁盘最终安装到系统中,代替原始磁盘,然后需要使用新 UUID 或 /dev/sdaX 设备名称更新 /etc/fstab)。
笔记:没有必要通过对 /etc/fstab 进行额外编辑来同时挂载原始磁盘和克隆磁盘。克隆磁盘通常用于创建备份,或从较小的原始磁盘转移到较大的克隆磁盘,然后在系统中进行交换。
笔记:克隆磁盘启动问题通常可以通过使用来修复boot-repair
。
进行 UUID 更改需要两个命令。请参阅以下手册页...
man uuidgen
man tune2fs
用户名
例子:uuidgen -r
或者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
例子: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.
更新#1:
修正了 NVME 上 20.04 版 ubuntu 的 fstab
笔记:fstab 中不应有 TABS,只有空格
#/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