Linux Tutorials

Fix XFS Filesystem Has Duplicate UUID on Linux

XFS refuses to mount a filesystem whose UUID matches one that is already mounted. Every block-level copy you make carries that UUID with it, whether it’s an LVM snapshot, a cloned VM disk or a dd image restored next to its source. The mount command only tells you “wrong fs type, bad option, bad superblock”, so the real message, Filesystem has duplicate UUID ... - can't mount, sits in dmesg where most people never look.

Original content from computingforgeeks.com - post 23844

Two fixes clear the XFS duplicate UUID error. Mount the copy with -o nouuid when you only need to read it, or give it a new UUID with xfs_admin -U generate when it stays. The second one fails on any copy of a running system, which is where xfs_repair -L gets suggested. In our lab it cost a directory. Every command here was run on Rocky Linux 10 and Ubuntu 26.04 LTS in November 2026.

Read the real error in dmesg

The mount error is generic, so check the kernel log first. XFS writes one line per refused mount, and that line names the device and the UUID that collided. That tells you which copy needs fixing, and it rules out real corruption before you reach for a repair tool. In our lab three kinds of copy produced it:

  • An LVM snapshot of a mounted logical volume (Rocky Linux 10)
  • GCP disks built from a snapshot of a busy data disk (Ubuntu 26.04)
  • A clone of the running boot disk attached to its own VM (Rocky Linux 10)

The kernel line is identical in all three, so the steps below apply whichever one you have. Only the recovery risk differs, and that depends on how the copy was taken.

Error: “mount: wrong fs type, bad option, bad superblock on /dev/mapper/vgdata-lvdata–snap”

This is what mount prints for any XFS mount the kernel refuses, and an LVM snapshot of a mounted volume is the quickest way to get it. On the Rocky Linux 10 box the origin is a 4 GB logical volume mounted at /srv/data. We took a 1 GB snapshot of it while it was in use.

sudo lvcreate -s -n lvdata-snap -L 1G /dev/vgdata/lvdata

Mounting the snapshot fails with exit code 32. Clear the kernel ring buffer first so you can spot the one line that matters, then try the mount and read the log.

sudo mkdir -p /mnt/snap
sudo dmesg -C
sudo mount /dev/vgdata/lvdata-snap /mnt/snap
sudo dmesg
sudo blkid /dev/vgdata/lvdata /dev/vgdata/lvdata-snap

The kernel log carries the line that matters, naming the snapshot’s device-mapper node and the UUID it collided on:

[  101.905860] XFS (dm-3): Filesystem has duplicate UUID e614b499-3877-4f8a-98f5-05ba29d0978e - can't mount

blkid shows why: both logical volumes report the same value, because a snapshot is a block-for-block view of the origin, superblock included.

XFS Filesystem has duplicate UUID error in dmesg after mounting an LVM snapshot on Rocky Linux 10

Nothing is wrong with the snapshot itself. Its superblock is intact and its data is fine, so xfs_repair is the wrong first move even though the mount message mentions a bad superblock. If you run a repair here, you risk turning a naming clash into real data loss, as the -L test further down shows.

Error: “XFS (sdc1): Filesystem has duplicate UUID b5feca22-0b90-4bb4-9332-f05bd2e5177a – can’t mount”

Cloud disk clones produce the same kernel line. On Ubuntu 26.04 we took a GCP snapshot of a 10 GB XFS data disk while a shell loop was writing small files to it. Two new disks were built from that one snapshot and attached back to the same VM. The first clone was refused exactly like the LVM snapshot, so the next step was to compare the identities.

sudo blkid /dev/sdb1 /dev/sdc1 /dev/sdd1
ls -l /dev/disk/by-uuid/b5feca22-0b90-4bb4-9332-f05bd2e5177a

Read the last line of this capture carefully. With three partitions sharing one UUID, udev pointed /dev/disk/by-uuid/b5feca22-... at sdd1, which is a clone, not the disk mounted at /srv/data:

blkid showing three XFS partitions with the same UUID and by-uuid symlink pointing at the clone on Ubuntu 26.04

Every UUID= line in /etc/fstab and every mount unit that names the UUID resolves through that symlink, so your next reboot can mount the copy in place of the original without any error at all. That is the real reason not to leave duplicates attached. The partition label and PARTUUID were cloned too, so switching your fstab to those does not help either.

Pick the fix that matches the copy

Use nouuid for a one-off read, xfs_admin -U generate for any copy that will be mounted again, and xfs_repair -L only when the log can’t be replayed at all. The table lists what each one did in the lab:

FixUse it whenSurvives a rebootLab result
mount -o nouuidYou need files off a snapshot or backup onceNo, unless you put nouuid in fstabReplayed the log, kept all 235,488 files
xfs_admin -U generateThe copy stays attached or becomes its own systemYesNew UUID instantly, but only after the log was clean
xfs_repair -LThe log is damaged and a nouuid mount failsYes, after the repairLost the busiest directory, 15,582 inodes in lost+found

The order matters more than the choice. A nouuid mount is also the step that makes xfs_admin work on a dirty copy, so on anything copied from a running system it’s the first command you run either way. Skipping it is how people end up at xfs_repair -L with a copy that never needed repairing.

Mount the copy with nouuid

The nouuid option tells XFS to skip the duplicate check for this one mount, and the kernel’s XFS admin guide names mounting LVM snapshot volumes as its use. Mount read-only when you only need to copy files off.

sudo mount -o nouuid,ro /dev/vgdata/lvdata-snap /mnt/snap

Read-only doesn’t mean untouched. On the Rocky snapshot the kernel logged Starting recovery and Ending recovery for that mount. XFS replayed the snapshot’s log and wrote to it even with ro, because the block device underneath was writable. If you need a mount that writes nothing, add norecovery, which the kernel only accepts together with ro. It only makes sense on a copy that hasn’t been replayed yet, so we tested it on a new snapshot:

sudo lvcreate -s -n lvdata-snap3 -L 1G /dev/vgdata/lvdata
sudo mount -o nouuid,ro,norecovery /dev/vgdata/lvdata-snap3 /mnt/snap

On a fresh snapshot the mount worked, and the kernel printed a warning you should take at its word:

[ 1662.504993] XFS (dm-5): Mounting V5 filesystem e614b499-3877-4f8a-98f5-05ba29d0978e in no-recovery mode. Filesystem will be inconsistent.

The log stayed dirty, so xfs_admin still refused that snapshot afterwards. Use norecovery for a quick look at a copy you’ll throw away, and a plain nouuid mount when you plan to change the UUID next. Keep nouuid out of a permanent fstab line as well. It hides the duplicate instead of removing it, and the by-uuid symlink still decides which disk your UUID= entry finds.

Give the copy a new UUID with xfs_admin

xfs_admin -U generate writes a random UUID into every superblock of an unmounted XFS filesystem, which removes the duplicate for good. Run it on the copy, never the original, because the original’s UUID is the one your fstab, your mount units and possibly your kernel command line already point at. Unmount the copy, then generate the new UUID.

sudo umount /mnt/snap
sudo xfs_admin -U generate /dev/vgdata/lvdata-snap

On the snapshot that a nouuid mount had already replayed, it cleared the log and set the UUID at once. blkid then shows two different values, and the snapshot mounts with no special option:

xfs_admin -U generate writing a new UUID to an LVM snapshot that then mounts cleanly on Rocky Linux 10

Ending clean mount in dmesg is the line you want to see, because it means no log replay was needed and the kernel found no other filesystem with that UUID. xfs_admin ships in the xfsprogs package on both distribution families, and both test images already had it installed, so you rarely need to add anything.

Error: “The filesystem has valuable metadata changes in a log which needs to be replayed”

xfs_admin prints this on any copy of a filesystem that was mounted when the copy was taken, which covers LVM snapshots, cloud snapshots and dd images of a live disk. We got it on both the LVM snapshot and the cloud disk clone in the lab. The fix is in the message itself. Mount with nouuid so XFS replays the log, unmount, then run xfs_admin again.

sudo mount -o nouuid /dev/vgdata/lvdata-snap /mnt/snap
sudo umount /mnt/snap
sudo xfs_admin -U generate /dev/vgdata/lvdata-snap

Watch the exit status if you script this. On Rocky Linux 10, xfs_admin returned 0 right after printing the error, so a script that checks $? carries on with the old UUID still in place. The capture shows the error, the exit code and the replay that fixed it.

xfs_admin refusing a dirty XFS log and mount -o nouuid replaying it on Rocky Linux 10

Check the result with blkid after every change instead of trusting the return code. The ro mount in that capture still ran recovery, which is why the next xfs_admin run succeeded. Had it been a norecovery mount, you’d have seen the same error again.

Error: “/dev/vgdata/lvdata: filesystem is mounted.”

xfs_admin will not modify a mounted filesystem, and this time it does exit with status 2. If you hit this on the copy, unmount it first. If you hit it on the original, stop, because you’re about to change the UUID that /etc/fstab uses for a live volume.

A new UUID on a current XFS filesystem doesn’t erase the old one, either. The metadata blocks keep the original value, which xfs_db prints as meta_uuid.

sudo xfs_db -r -c "sb 0" -c "p uuid meta_uuid" /dev/sdc2

On the cloned Rocky boot disk, after xfs_admin -U generate, the original root UUID was still there:

uuid = 0ad87e35-7383-48a4-9f50-e8c45bd70d7e
meta_uuid = 6f92a782-e687-4f77-80ae-64ec45a3ebd3

The xfs_admin man page explains the catch. On CRC-enabled filesystems the change also sets an incompatible feature flag, so kernels too old to know that flag cannot mount the volume. xfs_admin -U restore puts the original UUID back and clears the flag. The Rocky Linux 10 and Ubuntu 26.04 kernels mounted every renamed copy without complaint, so an old rescue image is the only place you are likely to notice.

Use xfs_repair -L only as a last resort

xfs_repair -L zeroes the log, so every metadata change still waiting in it is thrown away. The xfs_admin error only suggests it when the filesystem cannot be mounted, and the lab shows why. Both Ubuntu clones came from the same crash-consistent GCP snapshot, so they held identical bytes. We zeroed the log on one and mounted the other with nouuid.

sudo xfs_repair -L /dev/sdc1
sudo mkdir -p /mnt/clone-b
sudo mount -o nouuid /dev/sdd1 /mnt/clone-b

The repair printed about 19,400 lines, including 316 rmap tree errors, 3,539 unknown block states and 15,582 disconnected inodes moved to lost+found. When it finished, the inflight directory the write loop had been filling was gone, and the repaired clone used 303 MB against its twin’s 1.2 GB. The twin that went through a normal log replay kept that directory with all 235,488 files. The counts below were taken after both clones got new UUIDs and were mounted at /srv/restore (the replayed twin) and /srv/archive (the repaired one) in the next section:

xfs_repair -L destroying the log on a cloned XFS disk versus nouuid log replay keeping 235488 files on Ubuntu 26.04

The LVM snapshot on Rocky behaved differently. A dd copy of a snapshot taken during writes lost nothing to xfs_repair -L, with 347 files on both sides. LVM suspends the origin through device-mapper to create a snapshot, and the dmsetup man page says a suspend attempts to sync the filesystem first. That snapshot still needed a short log replay, but little was left waiting in it. Cloud snapshots and dd copies of a live disk get no such sync, and that is exactly where -L hurts. If a nouuid mount fails, try it on a second copy or take a fresh snapshot before you zero any log.

Update /etc/fstab and systemd mount units

A new UUID breaks every reference to the old one, so update /etc/fstab and any .mount unit that names the copy in the same change. If you leave fstab behind, the next boot waits for a device that no longer exists, as the error below shows. On the Ubuntu box both clones first got their own UUIDs, the replayed one directly and the repaired one after its xfs_repair:

sudo umount /mnt/clone-b
sudo xfs_admin -U generate /dev/sdd1
sudo xfs_admin -U generate /dev/sdc1

Read the new value with blkid:

sudo blkid -s UUID -o value /dev/sdd1

Then add or edit your fstab line. Clones and restore disks are the volumes most likely to be missing at the next boot, so give them nofail and a short device timeout.

sudo vim /etc/fstab

The line used for the restore clone on Ubuntu:

UUID=d7c891e5-47de-491d-96d0-902c238e3e0d /srv/restore xfs defaults,nofail,x-systemd.device-timeout=10s 0 0

With nofail, the systemd.mount rules make the mount wanted rather than required by local-fs.target, so the boot carries on if the disk is gone. Reload systemd so its fstab generator sees the change, let findmnt check the file, then start the mount:

sudo systemctl daemon-reload
sudo findmnt --verify
sudo systemctl start srv-restore.mount

If you’d rather keep a clone out of fstab, a native mount unit does the same job. The unit name has to match the mount point, so /srv/archive becomes srv-archive.mount, and systemd refuses to load a unit whose name and Where= disagree.

sudo vim /etc/systemd/system/srv-archive.mount

Point What= at the clone’s new by-uuid path, not at /dev/sdc1, because device names can change between boots when you attach or detach disks:

[Unit]
Description=Archive copy of /srv/data

[Mount]
What=/dev/disk/by-uuid/eeba7965-392c-4bfa-ba47-b30e787c2e88
Where=/srv/archive
Type=xfs
Options=defaults,nofail

[Install]
WantedBy=multi-user.target

Reload, then enable and start the unit in one step (the systemctl cheat sheet has the rest of the unit commands):

sudo systemctl daemon-reload
sudo systemctl enable --now srv-archive.mount

All three XFS filesystems then mounted from their own disks. findmnt with the UUID column is the quickest proof after a change like this, because each mount point gets one row and no UUID repeats:

fstab UUID entry and systemd mount unit mounting cloned XFS disks with new UUIDs on Ubuntu 26.04

The same pattern holds for an origin volume that you grow later. Our guides to creating, extending and snapshotting LVM volumes and resizing an XFS root partition without LVM both mount by UUID, and neither resize changes it.

Error: “Timed out waiting for device dev-disk-by\x2duuid-d7c891e5…”

systemd logs this at boot when fstab still names a UUID that no longer exists. We reproduced it by running xfs_admin -U generate on the restore clone a second time without touching fstab. findmnt --verify flagged the stale entry before the reboot, and after it the journal showed the 10-second device timeout followed by a failed dependency for srv-restore.mount:

findmnt --verify error and systemd Timed out waiting for device after an XFS UUID change left fstab stale

nofail is what kept that VM booting. On Ubuntu 26.04, local-fs.target carries OnFailure=emergency.target, so a required local mount that fails drops the machine to emergency mode. On a cloud VM without a console, that means a rescue job. Write the current UUID into fstab to fix it:

NEW=$(sudo blkid -s UUID -o value /dev/sdd1)
sudo sed -i "s/d7c891e5-47de-491d-96d0-902c238e3e0d/$NEW/" /etc/fstab
sudo systemctl daemon-reload
sudo findmnt --verify
sudo systemctl start srv-restore.mount

findmnt --verify then reported no errors, and the restore disk came back on /dev/sdd1 with its new UUID 408458bc-f447-4cc5-bb32-f8b2a257074c. A reboot test after any fstab edit is still worth the minute it takes, which is a habit the storage tasks in our RHCSA practice questions drill on every volume.

Keep cloned boot disks from colliding

Cloning a whole boot disk duplicates more than the XFS UUID. On Rocky Linux 10, a GCP clone of the boot disk carried the same root UUID, the same root label, the same EFI partition UUID and the same partition UUID as the disk the VM was running from:

Cloned Rocky Linux 10 boot disk with duplicate XFS root UUID, label and EFI UUID next to the original

That image boots with root=UUID=6f92a782-... on the kernel command line and mounts both / and /boot/efi by UUID in fstab. A clone attached to the same VM therefore leaves your next boot to whichever device udev links first. xfs_admin -U generate fixes only the XFS UUID, xfs_admin -L sets a new label, and the vfat and partition UUIDs need their own tools. If the clone has to boot on its own afterwards, its own fstab and boot loader entry need the new values too, and we did not boot-test that path here.

These habits kept every run in this lab clean:

  • Attach a clone to a different VM than its source
  • Detach clones and snapshots before rebooting the source
  • nouuid,ro for one-off reads, xfs_admin -U generate for anything kept
  • blkid and findmnt --verify after every change, not exit codes

virt-sysprep isn’t the shortcut it looks like for templates. Its fs-uuids operation is off by default, and the virt-sysprep man page warns that it does not update /etc/fstab or the boot loader and is more likely than not to leave the guest unbootable. For image builds, change the UUID and the fstab line in the same script, which virt-customize can run inside a qcow2 template. If you’re still choosing a filesystem for those templates, our ext4 vs XFS comparison is the place to start.

Keep reading

Configure Samba File Share on Debian 13 / 12 Debian Configure Samba File Share on Debian 13 / 12 Backup and Restore Linux Systems with Timeshift Debian Backup and Restore Linux Systems with Timeshift Best NAS Hard Drives for 2026: WD Red vs IronWolf, Price per TB Storage Best NAS Hard Drives for 2026: WD Red vs IronWolf, Price per TB OpenCloud vs ownCloud vs Nextcloud: Tested on Identical VMs Cloud OpenCloud vs ownCloud vs Nextcloud: Tested on Identical VMs Install Nextcloud on Ubuntu 26.04 LTS Cloud Install Nextcloud on Ubuntu 26.04 LTS CMR vs SMR Drives for NAS: Why SMR Wrecks RAID Rebuilds Storage CMR vs SMR Drives for NAS: Why SMR Wrecks RAID Rebuilds

2 thoughts on “Fix XFS Filesystem Has Duplicate UUID on Linux”

Leave a Comment

Press ESC to close