How to Change UUID in Linux

Written by: Linuxopsys   |   Last updated: June 26, 2022

It is essential to use UUID to mount storage device if the system uses many disks which are very regularly switched or moved. UUID is integrated with the filesystem and it helps uniquely identify drives.

UUID's normally changed when formatting or repartition a drive or any time when the filesystem is affected for some reason.

In this guide shows how to change UUID of a disk in Linux.

Change UUID in Linux

Based on the filesystem type we have few tools to change UUID. Linux utilities such as tune2fs (for ext2 or ext3 or ext3), xfs_admin (for xfs), btrfstune (for btrfs) can be used to change UUID.

In this example, I have used disk /dev/sdb to change the UUID and will use tune2fs command.

There are few ways to check the UUID of the storage device. Here we will use blkid command to find UUID.

First find UUID of the disk, type:

blkid /dev/sdb
/dev/sdb: UUID="f2cf4598-c725-4ef1-8ab6-e2cdc6028a33" TYPE="ext4"

To change the UUID of the filesystem, you need to unmount it.

Here the partition /dev/sdb is mounted at /mnt/data. To umount, type:

umount /mnt/data

Once the device is unmounted, use tune2fs command followed by -U flag to generate random UUID.

tune2fs -U random /dev/sdb
tune2fs 1.45.5 (07-Jan-2020)
Setting the UUID on this filesystem could take some time.
Proceed anyway (or wait 5 seconds to proceed) ? (y,N) y

Once the UUID is changed, run the following command to verify the changes.

blkid | grep sdb


dev/sdb: UUID="af406bcd-cddb-4095-8456-fdf8dfe37665" TYPE="ext4"

After changing the existing UUID, make sure to update any references to the old labels in /etc/fstab file.

vi /etc/fstab

UUID="af406bcd-cddb-4095-8456-fdf8dfe37665"   /mnt/data  ext4 defaults  0 2 

Now mount the unmounted filesystem back.

mount /mnt/data


In this guide, we learned how to change UUID in Linux using tune2fs command.



Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment