LVM Snapshots and XFS

Small note for everyone planing to use Linux LVM snapshots and using XFS at the same time. XFS has UUIDs which are unique identifiers of the filesystem. Two file systems with same UUID can not be mounted on the same server. Now, if we know that a snapshot of a logical volume represents a point-in-time copy of the original logical volume it doesn't take much time to realize that the filesystem on the snapshot is also a copy, thus it will have the same UUID as the filesystem on the original logical volume. So here is what happens when you try to mount the snapshot:

[root@server ~]# df -hT /var/lib/mysql_backup/
Filesystem    Type    Size  Used Avail Use% Mounted on
              xfs    25G   19G  6.3G  76% /var/lib/mysql_backup
[root@server ~]# lvcreate -s -n bkp-snap -L1G /dev/sys/mysql_backup
  Logical volume "bkp-snap" created
[root@server ~]# mount /dev/sys/bkp-snap /mnt/misc/
mount: wrong fs type, bad option, bad superblock on /dev/sys/bkp-snap,
       missing codepage or other
       In some cases useful info is found in syslog - try
       dmesg | tail or so
[root@server ~]# dmesg | tail -1
XFS: Filesystem dm-9 has duplicate UUID - can't mount

It doesn't look very good. There are two solution for this problem. One is to use nouuid option for mount command.

[root@server ~]# mount -o nouuid /dev/sys/bkp-snap /mnt/misc/
[root@server ~]# dmesg | tail -3
XFS mounting filesystem dm-9
Starting XFS recovery on filesystem: dm-9 (logdev: internal)
Ending XFS recovery on filesystem: dm-9 (logdev: internal)

Another option would be to change UUID of the filesystem on the snapshot using xfs_admin command.

[root@server ~]# xfs_admin -U generate /dev/sys/bkp-snap
Clearing log and setting UUID
writing all SBs
new UUID = 1bdcf6e1-62fb-47f2-83e4-dc398bb7a1cd
[root@server ~]# dmesg | tail -2
XFS mounting filesystem dm-9
Ending clean XFS mount for filesystem: dm-9

I am in favour of the first option (mount -o nouuid) since it does not perform any modification on the filesystem. It just feels safer, that's all... :)

2 Responses to “LVM Snapshots and XFS”

  1. 1 Stephane Nov 17th, 2009 at 10:25 am


    Can you explain the benefits of using XFS in your situation ? I’m just curious, there are so many filesystems around that it is sometimes complex to pick a choice !

    Thanks in advance


  2. 2 miljan Nov 17th, 2009 at 11:24 am

    Hi Stephane,

    XFS was a default choice for many years in the company when I arrived here. Some of the reasons are very good handling of big files (important for DB servers for example), fast recovery and possibility of online resize (ext3 was not able to do this at the time).

    But there are some downsides as well. For example XFS is very prone to fragmentation so from time time defragmentation is necessary (although this can be done online). Also it is not a “standard” filesystem, so many backup solutions do not work with XFS (although they support reiserfs, blah!). We are having a big problem finding good online system backup solution for our servers. I would be grateful for recommendations! :-)

Comments are currently closed.