Page 1 of 1

[Solved] How to change UUID

Posted: Fri Apr 07, 2017 7:39 am
by Chemical_Ali
Good morning,

For backup purposes, I created clone of one of my internal HDD. However, whilst the internal HDD is mounted (it is automatically mounted on startup), I cannot mount the backup drive, because there are two identical UUIDs.

/dev/sdd: LABEL="Toshiba" UUID="f32c5394-5b1a-4111-9a5e-389cb8f7f16b" TYPE="ext4" PTUUID="08d1c1a2" PTTYPE="dos"
/dev/sdg: LABEL="blue" UUID="f32c5394-5b1a-4111-9a5e-389cb8f7f16b" TYPE="ext4"

I tried using uuidgen to generate a new UUID, then tune2fs to change UUID:

sudo tune2fs /dev/sdg -U 89b7abcb-3223-4383-9673-7a163326e8b

But, tune2fs keeps telling me to run e2fsck on the filesystem.

Any ideas? Thanks.

Re: How to change UUID

Posted: Fri Apr 07, 2017 7:55 am
by Cosmo.
There is an easy way to change the UUID with gparted in the context menu of the partition in gparted. The partition must not be mounted for this task.

Re: How to change UUID

Posted: Fri Apr 07, 2017 8:02 am
by Chemical_Ali
I tried Gparted. But it looks like Gparted also calls tune2fs, so I am getting the same error message.

Re: How to change UUID

Posted: Fri Apr 07, 2017 8:19 am
by Cosmo.
This sounds, as if the file system on this partition is corrupted. Run in the terminal fsck /dev/sdaX. You have to replace aX with the proper values. Important: The partitions must not be mounted! Alternatively you run in the terminal sudo touch /forcefsck; with the next reboot all partitions get checked.

Re: How to change UUID

Posted: Fri Apr 07, 2017 9:59 am
by Flemur
Chemical_Ali wrote:I tried using uuidgen to generate a new UUID, then tune2fs to change UUID:
sudo tune2fs /dev/sdg -U 89b7abcb-3223-4383-9673-7a163326e8b.
/dev/sdg is the whole disk. Try that command with the correct partition number, e.g. /dev/sdg1

Re: How to change UUID

Posted: Fri Apr 07, 2017 7:37 pm
by Chemical_Ali
Flemur wrote:/dev/sdg is the whole disk. Try that command with the correct partition number, e.g. /dev/sdg1
Yep. I am using a 6TB HDD that only has one partition.

Re: How to change UUID

Posted: Fri Apr 07, 2017 7:49 pm
by Chemical_Ali
Cosmo. wrote:This sounds, as if the file system on this partition is corrupted. Run in the terminal fsck /dev/sdaX. You have to replace aX with the proper values. Important: The partitions must not be mounted! Alternatively you run in the terminal sudo touch /forcefsck; with the next reboot all partitions get checked.
I tried the terminal command, which ran for a second and didn't report any errors. But, I was still unable to change the UUID using the terminal.

However, I ran 'Check' from GParted, which ran for a bit longer. Then I was able to change the UUID using GParted. Unfortunately, I forgot to copy and paste the log files, but there were no errors as far as I recall. Now I am able to mount both backup drive and internal drive without any issues.

It has been a good learning experience. Thank you and Flemur for your help. :)

Re: How to change UUID

Posted: Sat Apr 08, 2017 9:49 am
by Flemur
Chemical_Ali wrote:Yep. I am using a 6TB HDD that only has one partition.
That would be /dev/sdg1, NOT /dev/sdg.
However, I ran 'Check' from GParted, which ran for a bit longer. Then I was able to change the UUID using GParted.
Your terminal command was referencing the whole disk, not a partition. Partitions are what gets mounted; gparted assigned the UUID to the partition.