In Linux, each disk and partition is assigned a unique identifier called a UUID (Universally Unique Identifier). These UUIDs help the system mount disks and partitions reliably, especially when device names change. The UUID is listed in files like fstab to ensure that partitions or disks are correctly mounted during boot.
There are situations where you may need to change the UUID of a disk or partition. This could happen if you clone a disk or if two disks or partitions have identical UUIDs, causing conflicts. Changing the UUID ensures the system recognizes and mounts the correct disk or partition without any issues.
Changing the UUID involves simple steps using terminal commands. You can generate a new UUID, apply it to a disk or partition, and update the system configuration to reflect the changes. The process is straightforward, but must be done carefully to avoid unmountable filesystems.
Steps to change disk or partition UUID in Linux:
- Open the terminal application.
- Generate a new UUID by running the uuidgen command.
$ uuidgen 39ea80c4-e748-47eb-835c-64025de53e26
uuidgen is normally installed by default in most Linux systems.
You can also get UUID from /proc/sys/kernel/random/uuid.
$ cat /proc/sys/kernel/random/uuid 5c27b2b3-58f4-4469-a717-45865f517400
- Unmount the disk or partition where you want to assign the new UUID.
$ sudo umount /dev/sdb1
Replace sdb1 with the actual disk or partition identifier you are working with.
- Check the filesystem on the disk or partition to ensure its integrity.
$ sudo e2fsck -f /dev/sdb1 e2fsck 1.44.6 (5-Mar-2019) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/sdb1: 11/1310720 files (0.0% non-contiguous), 126322/5242624 blocks
This step ensures there are no filesystem errors before making changes.
- Assign the new UUID to the disk or partition.
$ sudo tune2fs /dev/sdb1 -U 39ea80c4-e748-47eb-835c-64025de53e26 tune2fs 1.44.6 (5-Mar-2019) Setting the UUID on this filesystem could take some time. Proceed anyway (or wait 5 seconds to proceed) ? (y,N) y
Use the new UUID you generated here.
- Verify that the new UUID has been successfully applied.
$ sudo blkid /dev/sdb1 /dev/sdb1: UUID="39ea80c4-e748-47eb-835c-64025de53e26" TYPE="ext4" PARTUUID="2c6a7a3a-01"

Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
Comment anonymously. Login not required.