Top Nav

How-to Change UUID Of A Disk

When cloning or restoring disk volumes is possible to run into problem which conflicting UUID values. Each disk volume needs to be assigned a unique UUID. The UUID is store on the volume. A cloned or restored disk will have the same UUID as volume from which it was generated.

By default you are not allowed to mount two volumes with the same UUID. This can overcome with the “nouuid” mount option:

Often a server will be configured to select the root partition on boot by UUID. This makes is easy to ensure that the right volume is selected as the root. But if you have two volumes with the same UUID then the kernel will randomly select which volume to mount. This situation can occur when you’ve mounted a cloned or restored copy of the root volume and then reboot without removing the clone.

To list the UUID of all devices use the “blkid” command:

A new unique UUID can be generated with the “uuidgen” command:

The UUID of an XFS volume can be changed with:

Or let xfs_admin handle generating the new UUID:

For ext2/3/4 the tune2fs command can be used:

Or in a single line:

WARNING: Changing the UUID of an actively mounted disk volume can have unpredictable effects. Always work on unmounted volumes.

,