Lvm – Replacing BTRFS snapshots with XFS+LVM

btrfslvmxfs

I working on replacing an unstable btrfs snapshot based backup system. One of the option was to go ZFS but it's not natively in the kernel. XFS was reliable for me since 10 years but as my research shows it cannot do snapshots on it's own, people are using it in conjunction with LVM.

http://www.tecmint.com/take-snapshot-of-logical-volume-and-restore-in-lvm/

Now my biggest problem is that the snapshot (subvolumes) need a fix size also this seems to me that when you give 1G to a snapshot (no matter if it needs that much it will eat up unnecessarily that space).

Also if the snapshot size too small or the space on the xfs partition runs out I ran into all sorts of trouble:

  /dev/backup-vg/snap1: read failed after 0 of 4096 at 1073676288: Input/output error
  /dev/backup-vg/snap1: read failed after 0 of 4096 at 1073733632: Input/output error
  /dev/backup-vg/snap1: read failed after 0 of 4096 at 0: Input/output error
  /dev/backup-vg/snap1: read failed after 0 of 4096 at 4096: Input/output error
  /dev/backup-vg/snap2: read failed after 0 of 4096 at 1073676288: Input/output error
  /dev/backup-vg/snap2: read failed after 0 of 4096 at 1073733632: Input/output error
  /dev/backup-vg/snap2: read failed after 0 of 4096 at 0: Input/output error
  /dev/backup-vg/snap2: read failed after 0 of 4096 at 4096: Input/output error

How to solve this? Anyone knows a good case study/howto for implementing LVM based backup systems?

Best Answer

LVM thinly provisioned snapshots - lvmthin(7) - are dynamically allocated, so this might be an option. In my own benchmarks I found the performance of ext4+lvmthin to be considerably lower than btrfs for my backup applications.

Although XFS doesn't have native snapshots (yet?), it does now have reflink support (although this feature is still marked as experimental, it has been in the mainline kernel for over a year), so you may be able to put something together to similar effect using reflink copies (sub directory quotas may also help - depending on your use case) to create quick space-efficient backups.