# OpenZFS — Enterprise-Grade File System with Built-In Data Protection > OpenZFS is a combined file system and volume manager that provides copy-on-write semantics, built-in checksumming, snapshots, clones, compression, and RAID-Z data protection. It runs on Linux and FreeBSD with a focus on data integrity. ## Install Save in your project root: # OpenZFS — Enterprise-Grade File System with Built-In Data Protection ## Quick Use ```bash # Install on Ubuntu sudo apt install zfsutils-linux # Create a mirrored pool from two disks sudo zpool create mypool mirror /dev/sdb /dev/sdc # Create a dataset with compression sudo zfs create -o compression=zstd mypool/data # Take a snapshot sudo zfs snapshot mypool/data@backup1 # Check pool health sudo zpool status mypool ``` ## Introduction OpenZFS originated at Sun Microsystems and is now maintained by a cross-platform community. It fundamentally differs from traditional file systems by combining the file system and volume manager into one layer, providing end-to-end checksumming of all data and metadata. This design detects and corrects silent data corruption (bit rot) that other file systems cannot detect. ## What OpenZFS Does - Checksums every block of data and metadata to detect and repair silent corruption - Provides instant snapshots and clones with zero initial space overhead via copy-on-write - Implements software RAID (RAID-Z1/Z2/Z3) without requiring a hardware RAID controller - Compresses data transparently using LZ4, ZSTD, or GZIP at the dataset level - Supports native encryption (AES-256-GCM) with per-dataset keys ## Architecture Overview ZFS uses a layered architecture: the Storage Pool Allocator (SPA) manages physical devices, the Data Management Unit (DMU) provides a transactional object store, and the ZFS POSIX Layer (ZPL) implements the file system interface. All writes go through a copy-on-write transaction group (TXG) model, meaning the on-disk state is always consistent. The Adaptive Replacement Cache (ARC) provides intelligent read caching in RAM, while the L2ARC extends caching to SSDs. ## Self-Hosting & Configuration - Install via package manager: `apt install zfsutils-linux` on Debian/Ubuntu or `pkg install openzfs` on FreeBSD - Create pools with `zpool create` specifying mirror, raidz1, raidz2, or raidz3 topology - Set per-dataset properties: `zfs set compression=zstd recordsize=1M tank/data` - Configure automatic scrubbing via cron or systemd timers (recommended: monthly) - Enable native encryption: `zfs create -o encryption=aes-256-gcm -o keyformat=passphrase tank/secure` ## Key Features - Self-healing: when a checksum mismatch is detected, ZFS automatically repairs from a redundant copy - Send/receive replicates datasets across machines or data centers incrementally - Deduplication removes duplicate blocks across the pool (memory-intensive, use with caution) - Boot environments enable safe OS upgrades with instant rollback via snapshots - Delegated administration allows non-root users to manage specific datasets ## Comparison with Similar Tools - **Btrfs** — Btrfs offers similar features on Linux but has less mature RAID-Z equivalents and smaller production track record - **ext4** — ext4 is simpler and faster for basic use but lacks checksumming, snapshots, and built-in RAID - **XFS** — XFS excels at large-file sequential I/O but does not provide data integrity verification or snapshots - **LVM + mdraid** — This stack separates volume management and RAID; ZFS integrates both with end-to-end checksums - **Ceph** — Ceph is a distributed storage system; ZFS is a local file system (though ZFS send/receive enables replication) ## FAQ **Q: How much RAM does ZFS need?** A: ZFS works with 2 GB RAM minimum but benefits from more. The ARC cache uses available RAM and releases it under memory pressure. A common guideline is 1 GB RAM per TB of storage for dedup-free pools. **Q: Can ZFS expand an existing pool?** A: You can add new vdevs to a pool at any time. Expanding individual vdevs (replacing disks with larger ones) is supported via sequential disk replacement. **Q: Is ZFS safe for production use on Linux?** A: Yes. OpenZFS on Linux is mature and used in production by companies and NAS vendors including iXsystems (TrueNAS) and Proxmox. **Q: Does ZFS replace hardware RAID?** A: Yes. ZFS RAID-Z is generally preferred over hardware RAID because it provides end-to-end checksumming and avoids the write-hole problem. ## Sources - https://github.com/openzfs/zfs - https://openzfs.github.io/openzfs-docs - https://openzfs.org --- Source: https://tokrepo.com/en/workflows/asset-d312acc3 Author: AI Open Source