Linux – ZFS *file* backed zpool for snapshots… safe in production

linuxzfs

Are there any disadvantages of single file vdev zpool other than absence of fault tolerance which make it dangerous or impractical for production use?

e.g performance or stability concerns?

The man page only warns of absence of fault tolerance:

 file    A regular file.  The use of files as a backing store is strongly
         discouraged.  It is designed primarily for experimental purposes,
         as the fault tolerance of a file is only as good as the file sys‐
         tem of which it is a part.  A file must be specified by a full
         path.

My use case is for snapshoting a database on a Linux server before syncing it to an offsite backup-server which uses a real disk backed mirrored zpool. The only purpose of using ZFS on the database server is to gain fast atomic snapshots which vastly reduce the time the database has to remain locked.

My aim is to keep the setup for the database server as automated as possible. This is intended to be set up on top of standard VPS images, where re-partitioning the main volume cannot be easily automated, and adding extra block devices is wasteful in this case.

Alternatively is there a better way to allocate a portion of the underlying ext4 partition to a zpool without partitioning it or in a way which can be automated without the need to delve into a VPS manager?

Best Answer

ZFS is perfectly happy using a single file for a pool. You may not be, however. There are a few disadvantages.

  1. Performance. All ZFS iops are now translated to vnode ops, so ZFS is now sitting on top of a few more layers than it's used to. This comes with a significant performance impact.
  2. Reliability. ZFS ensures the atomicity of its transactions by writing its root node, called the "uberblock", with a single I/O issued to the uberblock's 4 locations. ZFS issues an fsync on the file after writing the uberblocks, but that turns out to be not 100% reliable.
  3. Redundancy. A single file (or a single disk for that matter) means that one of ZFS's better features, repairing read errors on the fly, is turned off. You may want to consider using a pair of files in a RAID1 (ZFS "mirror") config just to be a bit safer.
Related Question