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
              search --no-floppy --fs-uuid --set=root 47d9205b-00a8-40e5-88d6-e8b9571799a7
            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.



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"
  • I think in your file, you should try hd0
    – PRATAP
    May 3, 2019 at 15:27
  • 1
    You 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.
    – oldfred
    May 3, 2019 at 15:41
  • have you read that? askubuntu.com/questions/171446/…
    – Comar
    May 3, 2019 at 16:15
  • You 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 and cat /etc/fstab.
    – heynnema
    May 3, 2019 at 21:30
  • @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
    May 4, 2019 at 0:37

5 Answers 5


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, then reboot
  • 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
  • yes, 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
    May 4, 2019 at 12:18

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:

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.

  • Thank you! This finally worked after switching drives.
    – JIV
    May 20, 2021 at 22:34

@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:

enter the BIOS boot menu and select SDA to boot from, or change the boot order to CD-ROM/SDA/SDB/etc.

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 ran sudo update-grub on that system, and it picked up the changes that had been made after running update-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.


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:

echo ""
echo "====================================================================="
echo "Making changes in: $TargetMnt/etc/fstab"
echo "        from UUID: $SourceUUID"
echo "          to UUID: $TargetUUID"
sed -i "s/$SourceUUID/$TargetUUID/g" "$TargetMnt"/etc/fstab

# Update /boot/grub/grub.cfg on clone partition with clone's UUID
echo ""
echo "====================================================================="
echo "Making changes in: $TargetMnt/boot/grub/grub.cfg"
echo "        from UUID: $SourceUUID"
echo "          to UUID: $TargetUUID"
echo "Also change 'quiet splash' to 'nosplash' for environmental awareness"
echo "Suggest first time booting clone you make wallpaper unique"
sed -i "s/$SourceUUID/$TargetUUID/g" "$TargetMnt"/boot/grub/grub.cfg
#sed -i "s/quiet splash/nosplash/g" "$TargetMnt"/boot/grub/grub.cfg
  • Note for your purposes you would want to comment out changes to grub's "quiet splash" by inserting # in front of sed 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:

TargetDev=/dev/sdaX # Replace `X`this with your actual number
mkdir -p "$TargetMnt"                       # '-p' directory may already exist
mount -t auto -v $TargetDev "$TargetMnt" > /dev/null

sed -i "s/$SourceUUID/$TargetUUID/g" "$TargetMnt"/etc/fstab
sed -i "s/$SourceUUID/$TargetUUID/g" "$TargetMnt"/boot/grub/grub.cfg
umount "$TargetMnt" -l              # Unmount the clone
rm  -d "$TargetMnt"                 # Remove clone directory

Mark it as executable chmod a+x /path/to/MyHackedScript and call it with root powers sudo /pathto/MyHackedScript.

Other differences to Clonezilla

  • You end up with two grub boot entries, one for HDD and one for SSD
  • You can run sudo update-grub after booting from either HDD or SSD
  • If you don't want HDD on your grub menu just boot from SSD and update grub
  • You can use the script to clone daily (full backups) in which case it's probably ~100 times faster because only files that have changed since yesterday are recloned. rsync which is extremely fast is used for (re)cloning process.
  • I did not try yours, as the other one has fixed it. Thank you all the same.
    – Xu Shijie
    May 5, 2019 at 1:06
  • I'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. May 5, 2019 at 1:39

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.