Change The Partition UUID in Linux Filesystem

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.

Qadry
unixcop Admin

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

You might also likeRELATED

How to Count Number of Files and Sub-directories inside a Directory

Hi guys, In this article we will show you how to count the number of files and sub-directories in a directory using a tree command. Count number...

Find Top 10 IP Addresses Accessing Your Apache Web Server

In this post, you will learn how to Find Top 10 IP Addresses Accessing Your Apache Web Server- The monitoring access to your web server...

How to Install MongoDB in CentOS 8

Introduction MongoDB is a source-available cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas. MongoDB is developed by MongoDB Inc. and licensed under the Server Side Public License (SSPL). MongoDB is a...