尝试挂载快照 LVM(XFS 文件系统)时出错

Mar*_*n29 6 linux backup lvm

我有以下逻辑卷:

  --- Logical volume ---
  LV Path                /dev/wd1/mongodb
  LV Name                mongodb
  VG Name                wd1
  LV UUID                xxxx
  LV Write Access        read/write
  LV Creation host, time xxxx
  LV snapshot status     source of
                         mongodbSnap [active]
  LV Status              available
  # open                 1
  LV Size                8.00 GiB
  Current LE             2048
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3
Run Code Online (Sandbox Code Playgroud)

我使用了命令:

lvcreate --size 100M --snapshot --name mongodbSnap /dev/wd1/mongodb
Run Code Online (Sandbox Code Playgroud)

创建以下快照:

  --- Logical volume ---
  LV Path                /dev/wd1/mongodbSnap
  LV Name                mongodbSnap
  VG Name                wd1
  LV UUID                xxx
  LV Write Access        read/write
  LV Creation host, time xxx
  LV snapshot status     active destination for mongodb
  LV Status              available
  # open                 0
  LV Size                8.00 GiB
  Current LE             2048
  COW-table size         100.00 MiB
  COW-table LE           25
  Allocated to snapshot  0.18%
  Snapshot chunk size    4.00 KiB
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:7
Run Code Online (Sandbox Code Playgroud)

在这一点上,一切看起来都很好。但是,当我尝试使用以下内容安装 snap lv 卷时:

mount -t xfs /dev/wd1/mongodbSnap /mnt

我收到以下错误:

mount: wrong fs type, bad option, bad superblock on /dev/mapper/wd1-mongodbSnap,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.
Run Code Online (Sandbox Code Playgroud)

更新

日志消息包含以下错误:

[2424239.516667] XFS (dm-7): Filesystem has duplicate UUID xxxxxx - can't mount
Run Code Online (Sandbox Code Playgroud)

为什么快照会包含与原始 lv 相同的 UUID,我该如何解决这个问题?这样做的全部目的是使用 dd 命令备份驱动器...

解决方案是使用 nouuid 选项挂载文件系统

mount -o nouuid <source> <dest>
Run Code Online (Sandbox Code Playgroud)

Tuo*_*mas 1

  1. 使用 dd 进行备份时无需安装它。尽管不建议将 dd 用于 XFS(原因见下文),但如果您坚持使用 dd,只需使用快照 LV 设备作为输入参数 ( if):

    dd if=/dev/wd1/mongodbSnap of=/path/backup_of_mongodb_$(date -I).img
    
    Run Code Online (Sandbox Code Playgroud)
  2. UUID 是文件系统的唯一标识符,存储在文件系统元数据中。当您拍摄 LV 的快照时,此元数据也与快照 LV 中的原始 LV 相同,因此它们具有相同的 UUID。但是,请注意 XFS 的手册页(本地man xfs或在线,例如此处)关于其 UUID 的说明:

      Each XFS filesystem is labeled with a Universal Unique Identifier
      (UUID).  The UUID is stored in every allocation group header  and
      is  used  to  help  distinguish  one XFS filesystem from another,
      therefore you should avoid using dd(1)  or  other  block-by-block
      copying programs to copy XFS filesystems.  If two XFS filesystems
      on the same machine have the same  UUID,  xfsdump(8)  may  become
      confused  when  doing  incremental and resumed dumps.  xfsdump(8)
      and xfsrestore(8)  are  recommended  for  making  copies  of  XFS
      filesystems.
    
    Run Code Online (Sandbox Code Playgroud)

    TLDR:最好使用 xfsdump 和 xfsrestore。

  3. 使用 xfsdump 备份:

    • 安装 xfsdump。例如,在 Ubuntu 中,可以从软件包中安装这些工具xfsdump
      Each XFS filesystem is labeled with a Universal Unique Identifier
      (UUID).  The UUID is stored in every allocation group header  and
      is  used  to  help  distinguish  one XFS filesystem from another,
      therefore you should avoid using dd(1)  or  other  block-by-block
      copying programs to copy XFS filesystems.  If two XFS filesystems
      on the same machine have the same  UUID,  xfsdump(8)  may  become
      confused  when  doing  incremental and resumed dumps.  xfsdump(8)
      and xfsrestore(8)  are  recommended  for  making  copies  of  XFS
      filesystems.
    
    Run Code Online (Sandbox Code Playgroud)
    • 转储:
    apt install xfsdump
    
    Run Code Online (Sandbox Code Playgroud)