I am asking how to change uuid
in /boot/grub/grub.cfg
, so that grub can load OS on a specified partition.
I have two disks:
- SSD /dev/sda1 with uuid d7f0cf11-3edf-4859-b65a-3b5bc60ea7b9
- HDD /dev/sdb1 with uuid 47d9205b-00a8-40e5-88d6-e8b9571799a7
Both disks contain the same content (a Ubuntu root) but different partition uuids, as content of sda1
is cloned from sdb1
by clonezilla
The problem is /boot/grub/grub.cfg
, which is automatically generated, contains:
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
indicating that grub chooses Ubuntu root from sdb1
instead of sda1
, while i want it to choose sda1
.
I tried replace all 47d9205b-00a8-40e5-88d6-e8b9571799a7
by d7f0cf11-3edf-4859-b65a-3b5bc60ea7b9
directly, and then run update-grub
, but then everything is reverted back.
So is there any other better solution? the /boot/grub/grub.cfg
is actually generated automatically. If I detached the sdb1
, grub was unable to launched, as it could not find the uuid of sdb1
.
Thanks
Updates:
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
and 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"
You indicated that you cloned your HDD to SDD. However when I look at
sudo blkid
andcat /etc/fstab
, not much of it correlates. Partitions don't match. UUID's don't match. I suspect that you've done more changes than just a clone and boot.Without knowing exactly what/how you did what you did, it's difficult to come up with a concise answer for you... but you can try this...
UUID=xxxx
at the beginning of that same lineUUID=xxxx
portion to/dev/sda1
sudo update-grub
, thenreboot
For anyone who comes across this in the future. This would be the correct way to change the root partition UUID config in grub. Before doing the following, ensure you have the correct UUID for the device you want to use as your root ( / ).
Edit your /etc/default/grub and add the following variable:
then run this:
This won't change the hint entry for search but that won't match anyway so it should work. If someone wants to research a way to alter that part, I would be curious to know.
Clonezilla limitations
I wrote a bash script to do what Clonezilla does without it's limitations:
Highlights from the script of what Clonezilla doesn't do for you:
#
in front ofsed
as shown on last line displayed above.Hacked version of script
I obviously haven't tested this but you could hack the script and create your own version run after booting from HDD. Place these commands in the hacked script:
Mark it as executable
chmod a+x /path/to/MyHackedScript
and call it with root powerssudo /pathto/MyHackedScript
.Other differences to Clonezilla
sudo update-grub
after booting from either HDD or SSDrsync
which is extremely fast is used for (re)cloning process.@heynnema's answer got me most of the way there, but didn't quite do it for me, because my BIOS menu wasn't showing a boot entry for this partition (not sure why). Anyway, I followed their steps as far as the one about selecting a disk from the boot menu:
I did not do this step, and instead I just continued on to grub like normal, and booted the entry corresponding with the original installation (so in @Xu's case, that would be
/dev/sdb1
). Once booted, I ransudo update-grub
on that system, and it picked up the changes that had been made after runningupdate-grub
on the new system. Now, when I choose the new entry from the grub menu, it boots into the correct system.Hope this helps someone else who isn't getting an entry in their BIOS menu.
You can directly change the UUID in
/boot/grub/grub.cfg
as you did./boot/grub/grub.cfg
is not updated automatically. However, if you want to preserve bootability you also need to change the UUID accordingly elsewhere, for example, with EFI/UEFI booting, in/boot/efi/EFI/ubuntu/grb.cfg
and/etc/fstab
.