How to modify the UUID of a Volume Group (VG) or Physical Volume (PV) in CentOS/RHEL?

UUID (Universally Unique IDentifier) should be unique, and its purpose is to identify storage devices on a Linux system. If you cloned a virtual machine from vCenter, the metadata containing UUID information for the filesystem would be identical for the original and cloned copy. Therefore the UUID is no longer unique in /etc/fstab.


The device node name of a disk (/dev/sda, /dev/hda, /dev/vda, etc.) may change in some situations. For example, after switching cables around or upgrading certain packages, sda & sdc could swap places. This causes problems when /etc/fstab references filesystems by the disk names. Instead, use filesystem UUIDs or labels. Either of these allows for identifying a filesystem without resorting to ephemeral block device names.

Note: UUIDs and labels are not required if a filesystem resides on an LVM logical volume, as in default RHEL installations.

 

To find the UUID of your partitions, you can use blkid command as shown.

# blkid|grep UUID

 

How to Change UUID of Your Filesystems

Changing UUID of a filesystem is an easier task, and you need to use tune2fs command. Right now, I will change the UUID on my second partition /dev/sdb1; yours may vary. Thus make sure you are changing the UUID of the desired filesystem.

 

The partition has to be unmounted prior apply the new UUID:

# umount /dev/sdb1
# tune2fs -U random /dev/sdb1 
# blkid | grep sdb11

 

WOW! The UUID has been changed successfully. Now you can mount the filesystem back again.

# mount /dev/sdb1

 

You can also update your /etc/fstab if needed with the new UUID.


Done.

Was this answer helpful? 0 Users Found This Useful (0 Votes)