Unable to mount XFS filesystem due to `duplicate UUID` error

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 10
  • Red Hat Enterprise Linux 9
  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 7
  • XFS Filesystem

Issue

  • Unable to mount the XFS filesystem. Duplicate UUID errors are logged in dmesg:

    # dmesg | tail
    kernel: XFS (vdb1): Filesystem has duplicate UUID c4e2eef9-c744-4c64-8ebc-044373f84ddc - can't mount
    kernel: XFS (vdb1): Filesystem has duplicate UUID c4e2eef9-c744-4c64-8ebc-044373f84ddc - can't mount
    
  • How to change UUID of the XFS filesystem?

  • Unable to mount LVM snapshot of a XFS file-system:

    # mount /dev/vg_snap/lv_snap /snap
    mount: wrong fs type, bad option, bad superblock on /dev/vg_snap/lv_snap,
       missing codepage or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so
    

Resolution

  • Generate unique and new UUID for the affected XFS filesystem using xfs_admin utility:

    #  xfs_admin -U generate /dev/vdb1
    Clearing log and setting UUID
    writing all SBs
    new UUID = 9e1c84e4-b33f-4138-9992-c38b25b84237
    
  • It is possible to specify custom UUID using the xfs_admin utility, as well:

    # xfs_admin -U 9e1c84e4-b33f-4138-9992-c38b25b84237 /dev/vdb1
    
  • If the UUID of boot or root partition is changed, rebuilding the grub is required:

    # grub2-mkconfig -o /boot/grub2/grub.cfg
    

    On UEFI-based machines, enter:

    # grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
    
  • As a workaround, mount the filesystem with the nouuid option:

    # mount -o nouuid /dev/vdb1 /mnt
    
  • Please refer to article for changing UUID of ext* filesystem.

Root Cause

  • The XFS filesystem has an unique identifier, and two filesystems containing same UUID can not be mounted on the same system.

  • If the backing storage of filesystem is cloned or replicated, the metadata that contains UUID information for filesystem will be identical on both filesystems.

  • LVM snapshots will have same UUID as original filesystem.

Diagnostic Steps

  • Check /var/log/messages or journal or dmesg while mounting the filesystem:

    #  tail -f /var/log/messages
    kernel: XFS (vdb1): Filesystem has duplicate UUID c4e2eef9-c744-4c64-8ebc-044373f84ddc - can't mount
    kernel: XFS (vdb1): Filesystem has duplicate UUID c4e2eef9-c744-4c64-8ebc-044373f84ddc - can't mount
    
  • Mount the filesystem using nouuid option to check integrity of the filesystem:

    # mount -o nouuid /dev/vdb1 /mnt
    

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments