Resolving Duplicate UUIDs

This guide covers the identification and resolution of duplicate Universally Unique Identifiers (UUIDs) across various Linux file systems and Volume Managers. Duplicate UUIDs often occur after cloning disks or partitions and can cause major mounting conflicts.

1. Identification

Before making changes, identify which partitions are sharing the same UUID.

  • Quick View: lsblk -f

  • Detailed View: blkid

Look for matching strings in the UUID column for different device names (e.g., /dev/sda1 and /dev/sdb1 having the same ID).


2. File System Specific Fixes

EXT4 File Systems

For EXT2, EXT3, or EXT4 partitions, you can generate a new random UUID while the drive is live or unmounted.

Bash

# Syntax: sudo tune2fs -U random /dev/sdX#
sudo tune2fs -U random /dev/sdb1

XFS File Systems

Warning: The partition must be unmounted before changing the UUID on XFS.

Bash

# 1. Unmount the partition
sudo umount /dev/sdX#

# 2. Generate a new UUID
sudo xfs_admin -U generate /dev/sdX#

3. Logical Volume Management (LVM)

LVM uses UUIDs for Physical Volumes (PV) and names for Volume Groups (VG). Cloning an LVM disk creates duplicates of both.

Step A: Identify LVM Duplicates

Use these commands to check for "Duplicate PV" warnings:

  • pvs (Physical Volumes)

  • vgs (Volume Groups)

  • pvdisplay

Step B: Assign New PV UUID

If two Physical Volumes have the same UUID, change one of them:

Bash

sudo pvchange -u /dev/sdX2

Step C: Rename Duplicate Volume Groups

If two Volume Groups have the same name, use the VG UUID (found in vgs) to rename one of them to avoid conflicts.

Bash

# sudo vgrename [VG_UUID] [new_vg_name]
sudo vgrename a1b2c3-d4e5-f6g7-h8i9 new_vg_name

4. Post-Change Configuration (Critical)

Changing a UUID will break your automatic mounting if the system is looking for the old ID.

Update /etc/fstab

  1. Run blkid to copy the new UUID.

  2. Open the fstab file:

    Bash

    sudo nano /etc/fstab
    
  3. Replace the old UUID string with the new one for the respective mount point.

Update Bootloader (If System Partition)

If you changed the UUID of your root (/) or boot partition, you must update your GRUB configuration:

Bash

sudo update-grub

5. Verification

Finalize the process by testing the mounts and rebooting.

  1. Test Mounts: sudo mount -a (If no errors appear, your fstab is correct).

  2. Reboot: sudo reboot

  3. Confirm: After rebooting, run lsblk -f one last time to ensure all IDs are unique and mounted correctly.

Updated on