Introduction
UUID stands for Universally Unique IDentifier of a partition. This ID used in few different places to identify the partition. Most commonly this would be /etc/fstab.
Note : UUIDs and labels are not required if a filesystem resides on an LVM logical volume, as in default RHEL/CentOS installations.
Find UUID of your Partition
To find the UUID of your partitions, you can use blkid command as shown below:
blkid | grep UUID
Check the current UUID of the filesystem
1. To find of the current UUID of the filesystem you can use either of the below commands.
[root@unixcop ~]# blkid /dev/sdb1
/dev/sda1: UUID="b6a7ec7c-531c-4bab-b808-b1ad10c9d402" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="77a4c760-01"
[root@unixcop ~]#
# dumpe2fs /dev/sdb1 | grep UUID
dumpe2fs 1.45.6 (20-Mar-2020)
Filesystem UUID: b6a7ec7c-531c-4bab-b808-b1ad10c9d402
You can also view the UUID in the file /etc/fstab, if there is an entry done manually for the filesyste.
# grep boot /etc/fstab
Change UUID of your Partition
We are going to use tune2fs. I will change the UUID on the partition /dev/sdb1.
Note: The partition has to be unmounted .
umount /dev/sdb1
tune2fs -U random /dev/sdb1
blkid | grep sdb1
Now the UUID successfully changed. Now you can mount the filesystem again .
mount /dev/sdb1
You can also update your /etc/fstab , with the new UUID.
Conclusion
In this guide, we shew how to change the UUID of a Linux partition. This can help you in a less likely to happen scenario when the UUID of two partitions are the same.