我在问如何更改uuid
,/boot/grub/grub.cfg
以便 grub 可以在指定的分区上加载操作系统。
我有两个磁盘:
- SSD /dev/sda1 与 uuid d7f0cf11-3edf-4859-b65a-3b5bc60ea7b9
- 硬盘 /dev/sdb1 与 uuid 47d9205b-00a8-40e5-88d6-e8b9571799a7
两个磁盘都包含相同的内容(一个 Ubuntu 根目录)但不同的分区 uuid sda1
,sdb1
因为clonezilla
问题是/boot/grub/grub.cfg
,它是自动生成的,包含:
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos1 --hint-efi=hd1,msdos1 --hint-baremetal=ahci1,msdos1 47d9205b-00a8-40e5-88d6-e8b9571799a7
else
search --no-floppy --fs-uuid --set=root 47d9205b-00a8-40e5-88d6-e8b9571799a7
fi
echo 'Loading Linux 4.4.0-146-generic ...'
linux /boot/vmlinuz-4.4.0-146-generic root=UUID=47d9205b-00a8-40e5-88d6-e8b9571799a7 ro quiet splash $vt_handoff
表明 grub 选择 Ubuntu rootsdb1
而不是sda1
,而我希望它选择sda1
.
我尝试直接替换所有47d9205b-00a8-40e5-88d6-e8b9571799a7
,d7f0cf11-3edf-4859-b65a-3b5bc60ea7b9
然后运行update-grub
,但随后一切都恢复了。
那么还有其他更好的解决方案吗?/boot/grub/grub.cfg
实际上是自动生成的。如果我分离了sdb1
,grub 将无法启动,因为它找不到sdb1
.
谢谢
更新:
shijiex@shijie:~$ cat /etc/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>
proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sda1 during installation
UUID=d7f0cf11-3edf-4859-b65a-3b5bc60ea7b9 / ext4 errors=remount-ro 0 1
#UUID=47d9205b-00a8-40e5-88d6-e8b9571799a7 /old_os ext4 errors=remount-ro 0 2
# /backup was on /dev/sda5 during installation
UUID=d36e69de-3af8-4302-a2b1-f32c2538493d /backup ext4 defaults 0 0
# /home was on /dev/sda7 during installation
UUID=95ffe5be-ed1c-4d2b-b745-e31ba62ca63d /home ext4 defaults 0 2
#UUID=e2ae897d-62b1-45d3-a17a-49e7a1b8fbe7 /home ext4 defaults 0 2
# /vm was on /dev/sda8 during installation
#UUID=222bf555-b2d3-4607-a856-f5fd785b1862 /vm ext4 defaults 0 2
# /opt was on /dev/sda8 during installation
UUID=ffbc1ea0-f426-4def-9349-a6f68b486b2f /opt ext4 defaults 0 0
# /other was on /dev/sda6 during installation
UUID=657778bc-fde8-4261-9fe6-4134c6a7fb3f /other ext4 defaults 0 0
# /other was on /dev/sda6 during installation
#UUID=6db98036-2350-4289-b9ef-8e0a2ae52eeb /win ext4 defaults 0 2
# swap was on /dev/sda9 during installation
UUID=71c498b2-3484-4d5b-b64a-270cc352841b none swap sw 0 0
#UUID=05f1ba29-4188-40d1-8597-de708b48ed50 /tmp swap sw 0 0
和blkid
:
shijiex@shijie:~$ sudo blkid
[sudo] password for shijiex:
/dev/sda1: UUID="d7f0cf11-3edf-4859-b65a-3b5bc60ea7b9" TYPE="ext4" PARTUUID="2fe05ff9-01"
/dev/sda3: UUID="95ffe5be-ed1c-4d2b-b745-e31ba62ca63d" TYPE="ext4" PARTUUID="2fe05ff9-03"
/dev/sda4: UUID="8d114eed-5ce4-4d6f-8a28-8a7092b01d46" TYPE="ext4" PARTUUID="2fe05ff9-04"
/dev/sda5: UUID="94b0fb65-f56d-426d-81f9-d05a8ac783eb" TYPE="ext4" PARTUUID="2fe05ff9-05"
/dev/sdb1: UUID="47d9205b-00a8-40e5-88d6-e8b9571799a7" TYPE="ext4" PARTUUID="0001c588-01"
/dev/sdb10: LABEL="New Volume" UUID="6db98036-2350-4289-b9ef-8e0a2ae52eeb" TYPE="ext4" PARTUUID="0001c588-0a"
/dev/sdb11: UUID="ffbc1ea0-f426-4def-9349-a6f68b486b2f" TYPE="ext4" PARTUUID="0001c588-0b"
/dev/sdb5: UUID="d36e69de-3af8-4302-a2b1-f32c2538493d" TYPE="ext4" PARTUUID="0001c588-05"
/dev/sdb6: UUID="657778bc-fde8-4261-9fe6-4134c6a7fb3f" TYPE="ext4" PARTUUID="0001c588-06"
/dev/sdb7: UUID="e2ae897d-62b1-45d3-a17a-49e7a1b8fbe7" TYPE="ext4" PARTUUID="0001c588-07"
/dev/sdb8: UUID="222bf555-b2d3-4607-a856-f5fd785b1862" TYPE="ext4" PARTUUID="0001c588-08"
/dev/sdb9: UUID="71c498b2-3484-4d5b-b64a-270cc352841b" TYPE="swap" PARTUUID="0001c588-09"
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"