How to change UUID in the /boot/grub/grub.cfg
Solution 1
You indicated that you cloned your HDD to SDD. However when I look at sudo blkid
and cat /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...
- turn on your machine, and get to the GRUB menu
- hit the e key to enter edit mode
- use the arrow keys to locate "quiet splash"
- find the
UUID=xxxx
at the beginning of that same line - change the entire
UUID=xxxx
portion to/dev/sda1
- control+x or F10 to continue to boot after the edit
- once booted,
sudo update-grub
, thenreboot
- enter the BIOS boot menu and select SDA to boot from, or change the boot order to CD-ROM/SDA/SDB/etc.
- at the GRUB menu, select the proper disk to boot from
Solution 2
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:
GRUB_DEVICE_UUID=***INSERT NEW UUID HERE***
then run this:
sudo update-grub
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.
Related videos on Youtube
Xu Shijie
Updated on September 18, 2022Comments
-
Xu Shijie over 1 year
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 fromsdb1
byclonezilla
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 ofsda1
, while i want it to choosesda1
.I tried replace all
47d9205b-00a8-40e5-88d6-e8b9571799a7
byd7f0cf11-3edf-4859-b65a-3b5bc60ea7b9
directly, and then runupdate-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 thesdb1
, grub was unable to launched, as it could not find the uuid ofsdb1
.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"
-
UnKNOWn about 5 yearsI think in your file, you should try hd0
-
oldfred about 5 yearsYou do not normally edit grub.cfg. Boot into system you want as default and install its grub to MBR (if BIOS) or to UEFi drive if UEFI. Since clone, you have duplicates in fstab and grub.cfg which both need to be changed/edited. This is why a clean install copy copy of /home & installed apts is often easier. Be careful booting when both have same UUIDs in settings wrong system may get some updates and get out of sync. First edit fstabs to match install. Then run totally reinstall grub from each install into MBR of same drive if BIOS/MBR. Often easier with Boot-Repair's advanced mode.
-
Comar about 5 yearshave you read that? askubuntu.com/questions/171446/…
-
Boris Hamanov about 5 yearsYou cloned the HDD to the SSD, correct? Is this a desktop machine? Are you intending to have both the SSD and HDD connected at the same time, in their current configuration... or will you be changing the HDD at a later date? Edit your question and show me
sudo blkid
andcat /etc/fstab
. -
Xu Shijie about 5 years@heynnema Yes, Clone partitition from HDD to SSD on my Thinkpad. The HDD is attached to CDRom, and will still be used for storage. No plan to make changes on the HDD.
-
Xu Shijie about 5 yearsyes, I did some changes: re-generate UUID for some SSD's partitions, and modify fstab accordingly. Previously, both uuids from HDD and SSD were the same.
-
Xu Shijie about 5 yearsI did not try yours, as the other one has fixed it. Thank you all the same.
-
WinEunuuchs2Unix about 5 yearsI'll leave the answer here just in case it's helpful to others. The other answer is good and I'm glad it worked. I've upvoted both your question and the other answer because it could help other Clonezilla users.
-
JIV almost 3 yearsThank you! This finally worked after switching drives.