How to Install ZFS on Ubuntu 26.04

This tutorial explains how to install ZFS on Ubuntu 26.04 Resolute Raccoon. ZFS (Zettabyte File System) is an advanced filesystem that combines volume management with a robust file system, offering features like data integrity verification, snapshots, cloning, and RAID-Z support. By following this guide, you will learn to install ZFS on Ubuntu 26.04 and configure basic storage pools for your system.

In this tutorial you will learn:

  • How to install ZFS packages on Ubuntu 26.04
  • How to verify ZFS kernel module is loaded
  • How to create and manage ZFS storage pools
  • Basic ZFS filesystem operations
  • How to check ZFS pool status and health
Abstract representation of ZFS filesystem data storage with interconnected blocks on Ubuntu 26.04
Installing and configuring ZFS filesystem on Ubuntu 26.04 Resolute Raccoon

Software Requirements

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu 26.04 Resolute Raccoon
Software zfsutils-linux, zfs-dkms (optional for custom kernels)
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user
TL;DR
To install ZFS on Ubuntu 26.04, use the apt package manager to install the zfsutils-linux package.

Quick Steps to Install ZFS on Ubuntu 26.04
Step Command/Action
1. Update package list sudo apt update
2. Install ZFS utilities sudo apt install zfsutils-linux
3. Verify installation zfs --version
4. Check kernel module lsmod | grep zfs

Installing ZFS on Ubuntu 26.04

The ZFS filesystem is available directly from the Ubuntu repositories, making the installation process straightforward. Ubuntu 26.04 includes OpenZFS packages that are pre-built for the distribution’s kernel, so you do not need to compile anything from source.

  1. Update the package repository: Before installing any new software, ensure your package lists are current.
    $ sudo apt update

    This command refreshes the local package index with the latest available versions from the Ubuntu repositories.

  2. Install the ZFS utilities package: The zfsutils-linux package provides all necessary tools to create and manage ZFS pools and filesystems.
    $ sudo apt install zfsutils-linux

    During installation, the system automatically loads the ZFS kernel module and configures the necessary services. This package includes command-line tools like zpool and zfs that you will use to manage your storage.

NOTE ABOUT LICENSING
ZFS is distributed under the CDDL license, which is incompatible with the GPL. Consequently, ZFS cannot be included directly in the Linux kernel and is instead provided as a separate kernel module. Ubuntu distributes pre-built ZFS modules that match each kernel version.

Verifying the ZFS Install on Ubuntu 26.04

After installation completes, you should verify that ZFS is properly configured and the kernel module is loaded. This verification step ensures everything is working correctly before you begin creating storage pools.

  1. Check the ZFS version: Confirm that the ZFS utilities are installed and accessible.
    $ zfs --version

    You should see output displaying the OpenZFS version number, confirming the installation was successful.

  2. Verify the kernel module is loaded: The ZFS kernel module must be active for ZFS to function.
    $ lsmod | grep zfs

    This command filters the list of loaded kernel modules to show ZFS-related entries. You should see zfs along with its dependencies like spl, znvpair, and zavl.

  3. Check ZFS service status: Ubuntu uses systemd services to manage ZFS mounts and imports at boot time.
    $ systemctl status zfs-import-cache.service zfs-mount.service

    Both services should show as loaded. The import service handles automatic pool imports during boot, while the mount service manages automatic mounting of ZFS filesystems.

Image Metadata:ALT: Terminal output showing ZFS version 2.3.5, loaded kernel modules, and systemd service status on Ubuntu 26.04
Checking ZFS version, kernel modules, and service status after installation

Creating Your First ZFS Pool

With ZFS installed, you can now create storage pools. A ZFS pool (zpool) is a collection of one or more storage devices that ZFS manages as a single unit. Understanding how to create and manage pools is fundamental to using the ZFS filesystem effectively.

WARNING
Creating a ZFS pool will format the specified disks. Ensure you have backed up any data on the target devices before proceeding. Double-check device names using lsblk to avoid data loss.

  1. Identify available disks: List all block devices on your system to find suitable disks for your pool.
    $ lsblk

    Look for disks that are not currently mounted or in use. For this example, we will use /dev/sdb as our target device.

  2. Create a simple ZFS pool: Use the zpool create command to create a new storage pool.
    $ sudo zpool create linuxconfigpool /dev/sdb

    This command creates a pool named linuxconfigpool using the entire disk /dev/sdb. ZFS automatically creates a filesystem with the same name and mounts it at /linuxconfigpool.

  3. Verify pool creation: Confirm the pool was created successfully.
    $ zpool status

    The output displays your new pool’s configuration, including its health status and the devices it contains.

Terminal showing ZFS pool creation with lsblk, zpool create, and zpool status commands on Ubuntu 26.04
Creating and verifying a ZFS storage pool named linuxconfigpool on a 10GB disk

For redundant storage configurations, ZFS supports mirror and RAID-Z layouts. To create a mirrored pool with two disks:

$ sudo zpool create linuxconfigpool mirror /dev/sdb /dev/sdc

For a RAID-Z pool with three or more disks (similar to RAID-5):

$ sudo zpool create linuxconfigpool raidz /dev/sdb /dev/sdc /dev/sdd

TIP
Use meaningful pool names that reflect their purpose, such as datapool or backup. Avoid generic names like pool1 as they become confusing when managing multiple pools.

Basic ZFS Commands

Once you have ZFS installed on Ubuntu 26.04, you will regularly use several commands for day-to-day management. This section covers essential operations for working with pools and filesystems.

Pool Management Commands

  1. List all pools: Display all ZFS pools on the system.
    $ zpool list

    Shows pool name, size, allocation, free space, and health status.

  2. Check pool health: View detailed status information for all pools.
    $ zpool status -v

    The -v flag provides verbose output including any errors detected on the disks.

  3. Export a pool: Prepare a pool for removal or transport to another system.
    $ sudo zpool export linuxconfigpool

    Exporting unmounts all filesystems and removes the pool from the system without destroying data.

  4. Import a pool: Bring an exported pool back online.
    $ sudo zpool import linuxconfigpool

    ZFS scans available devices and imports the specified pool.

Filesystem Management Commands

  1. Create a filesystem: Add a new filesystem within an existing pool.
    $ sudo zfs create linuxconfigpool/documents

    This creates a filesystem at /linuxconfigpool/documents that inherits properties from the parent pool.

  2. List filesystems: Display all ZFS filesystems.
    $ zfs list

    Shows filesystem name, used space, available space, and mount point.

  3. Create a snapshot: Capture the current state of a filesystem.
    $ sudo zfs snapshot linuxconfigpool/documents@backup1

    Snapshots are instantaneous and space-efficient, consuming only the space needed to track changes.

  4. Destroy a filesystem: Remove a filesystem and its data permanently.
    $ sudo zfs destroy linuxconfigpool/documents

    Use this command with caution as it permanently deletes all data in the filesystem.

For those planning to use ZFS as their primary filesystem, consider exploring how to install Ubuntu 26.04 on ZFS root for a fully integrated experience.

Image Metadata:ALT: Terminal displaying zpool list, zpool status, zfs create, and zfs list commands showing pool and filesystem management on Ubuntu 26.04
Listing ZFS pools and creating a documents filesystem within linuxconfigpool

Conclusion

You have successfully learned how to install ZFS on Ubuntu 26.04 and perform basic pool and filesystem operations. ZFS provides powerful features like data integrity protection through checksumming, efficient snapshots, and flexible storage pool management. These capabilities make it an excellent choice for servers, NAS systems, and workstations requiring reliable data storage. As you become more familiar with ZFS, explore advanced features such as compression, deduplication, and automated scrubbing to maximize the benefits of this filesystem. For comprehensive information about ZFS features and best practices, consult the official OpenZFS documentation.

Frequently Asked Questions

  1. What are the minimum hardware requirements for ZFS on Ubuntu 26.04? ZFS recommends a minimum of 2 GB RAM for basic usage, though 8 GB or more is advisable for production systems using deduplication. ZFS can run on any x86_64 processor supported by Ubuntu. Storage requirements depend on your pool configuration, but ZFS performs best with dedicated disks rather than partitions.
  2. Can I add more disks to an existing ZFS pool? Yes, you can expand a ZFS pool by adding new vdevs (virtual devices) using zpool add poolname /dev/sdX. However, you cannot add individual disks to existing mirror or RAID-Z vdevs. Plan your pool layout carefully during initial creation, as changing vdev types requires recreating the pool.
  3. How do I automatically mount ZFS pools at boot? Ubuntu 26.04 automatically mounts ZFS pools at boot through the zfs-import-cache.service and zfs-mount.service systemd services. These services are enabled by default when you install ZFS. If pools are not mounting automatically, ensure these services are enabled with sudo systemctl enable zfs-import-cache zfs-mount.
  4. Is ZFS compatible with other operating systems? Yes, ZFS pools created on Ubuntu can be imported on other operating systems running OpenZFS, including FreeBSD, other Linux distributions, and even macOS with appropriate software. Export the pool before moving disks to another system using zpool export poolname.


Comments and Discussions
Linux Forum