30.6. Boot Integration and Troubleshooting

A ZFS pool is not useful if it does not come back after a reboot. Debian's ZFS packages install systemd units that load the module, import pools from a cache file, mount datasets, wait for zvol devices, and run the event daemon. Knowing which unit does what shortens the diagnosis when a pool is missing or an encrypted dataset is unavailable.

30.6.1. Pool Import, Dataset Mounts, and Service Dependencies

The ZFS units are enabled by the package installation:

# systemctl is-enabled zfs-import-cache.service zfs-import.target zfs-mount.service zfs.target zfs-zed.service
enabled
enabled
enabled
enabled
enabled

The running units show the dependency structure:

# systemctl list-units "zfs*" --all --no-pager
  UNIT                     LOAD   ACTIVE SUB     DESCRIPTION
  zfs-import-cache.service loaded active exited  Import ZFS pools by cache file
  zfs-load-module.service  loaded active exited  Install ZFS kernel module
  zfs-mount.service        loaded active exited  Mount ZFS filesystems
  zfs-share.service        loaded active exited  ZFS file system shares
  zfs-volume-wait.service  loaded active exited  Wait for ZFS Volume (zvol) links in /dev
  zfs-zed.service          loaded active running ZFS Event Daemon (zed)
  zfs-import.target        loaded active active  ZFS pool import target
  zfs-volumes.target       loaded active active  ZFS volumes are ready
  zfs.target               loaded active active  ZFS startup target

Legend: LOAD   → Reflects whether the unit definition was properly loaded.
        ACTIVE → The high-level unit activation state, i.e. generalization of SUB.
        SUB    → The low-level unit activation state, values depend on unit type.

9 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.

The roles are:

Unit Role
zfs-load-module.service Loads the ZFS kernel module before import
zfs-import-cache.service Imports pools listed in /etc/zfs/zpool.cache
zfs-import-scan.service Alternative import by device scan; usually disabled when cache import is used
zfs-import.target Synchronization point after pool import
zfs-mount.service Runs zfs mount -a after pools are imported
zfs-volume-wait.service Waits for zvol device links under /dev/zvol
zfs-volumes.target Synchronization point for zvol consumers
zfs-zed.service Runs the ZFS Event Daemon for health events
zfs.target Overall target that orders ZFS startup

The import service's command line shows the cache file and the -N flag:

# systemctl status zfs-import-cache.service --no-pager | sed -n '1,10p'
● zfs-import-cache.service - Import ZFS pools by cache file
     Loaded: loaded (/usr/lib/systemd/system/zfs-import-cache.service; enabled; preset: enabled)
     Active: active (exited) since Tue 2026-11-24 15:03:03 UTC; 17s ago
 Invocation: df53c7e13d954456a22720c7b1403194
       Docs: man:zpool(8)
    Process: 474 ExecStart=/usr/sbin/zpool import -c /etc/zfs/zpool.cache -aN $ZPOOL_IMPORT_OPTS (code=exited, status=0/SUCCESS)
   Main PID: 474 (code=exited, status=0/SUCCESS)
   Mem peak: 2.8M
        CPU: 72ms

-c reads the cache file, -a imports all pools listed there, and -N imports without mounting so that zfs-mount.service can perform mounts in a controlled order. The mount service's command is zfs mount -a:

# systemctl status zfs-mount.service --no-pager | sed -n '1,10p'
● zfs-mount.service - Mount ZFS filesystems
     Loaded: loaded (/usr/lib/systemd/system/zfs-mount.service; enabled; preset: enabled)
     Active: active (exited) since Tue 2026-11-24 15:03:03 UTC; 19s ago
 Invocation: 510f84f391c849d8b38131427a12aa7d
       Docs: man:zfs(8)
    Process: 719 ExecStart=/usr/sbin/zfs mount -a (code=exited, status=0/SUCCESS)
   Main PID: 719 (code=exited, status=0/SUCCESS)
   Mem peak: 3.2M
        CPU: 71ms

The exited sub-state is normal for a oneshot service that has finished its work. active (exited) means the unit succeeded; it does not mean a daemon is still running. zfs-zed.service is the long-running exception.

The pool's cachefile property often shows the default rather than a path:

# zpool get cachefile tank
NAME  PROPERTY   VALUE      SOURCE
tank  cachefile  -          default

The default cache file still exists on disk:

# ls -l /etc/zfs/zpool.cache
-rw-r--r-- 1 root root 4852 Nov 24 15:02 /etc/zfs/zpool.cache

Setting the property explicitly to the default path does not change the reported source. The zpool set command is silent:

# zpool set cachefile=/etc/zfs/zpool.cache tank
# zpool get cachefile tank
NAME  PROPERTY   VALUE      SOURCE
tank  cachefile  -          default

This is expected: the default cachefile location is /etc/zfs/zpool.cache, so the explicit value is recognized as the default. A pool with cachefile=none is not imported by zfs-import-cache.service; that is useful for pools that should be imported manually, but it means the pool will not be available after boot unless another unit or administrator imports it.

After a reboot, verify the pools and mounts rather than assuming the units succeeded:

# zpool list
NAME       SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
raidpool  2.88G  1.43M  2.87G        -         -     3%     0%  1.00x    ONLINE  -
tank       960M   319M   641M        -         -    14%    33%  1.00x    ONLINE  -
# zfs list -o name,mounted,mountpoint tank/data/docs
NAME            MOUNTED  MOUNTPOINT
tank/data/docs  yes      /tank/data/docs

The import and mount service statuses shown earlier in this section were captured seconds after a boot: the Active: lines carry the boot's timestamp, and status=0/SUCCESS on both units is the result to expect at every start.

Encrypted datasets need an extra step after boot. The pool is imported and the dataset metadata is visible, but the key is not loaded automatically for a file-based key:

# zfs get -o property,value keystatus,mounted tank/secure
PROPERTY   VALUE
keystatus  unavailable
mounted    no

Load all available keys and mount all datasets:

# zfs load-key -a
1 / 1 key(s) successfully loaded
# zfs mount -a

The mount command is silent. The dataset is now available:

# zfs get -o property,value keystatus,mounted tank/secure
PROPERTY   VALUE
keystatus  available
mounted    yes

zfs load-key -a only loads keys whose keylocation is accessible. A keylocation=prompt dataset requires an interactive prompt and cannot be loaded by a noninteractive boot service. zpool import -l requests keys during import for datasets it would mount, but it still needs the key source. If the key is on an encrypted filesystem that is not yet mounted, the boot sequence has a circular dependency; store the key on a separate unencrypted volume, a TPM-backed mechanism, or a network key service with a documented recovery path.

Zvol consumers have their own ordering. zfs-volume-wait.service waits for /dev/zvol links, but a virtual machine or iSCSI target still needs a unit ordering that starts it after zfs-volumes.target. If a zvol is missing after boot, check zfs list -o name,volmode,mounted, ls -l /dev/zvol/<pool>/, and the consumer's own unit status before recreating the zvol; recreating it would destroy its data.

30.6.2. Recovering After a Kernel Module Build Failure

A DKMS build failure usually appears during a kernel package upgrade, not at runtime. The old module may still be loaded, so the system keeps working until the next reboot. Check the recorded state:

# dkms status
zfs/2.3.9, 6.12.118+deb13-amd64, x86_64: installed

If the running kernel has a module, modinfo shows its location and version:

# modinfo zfs | grep -E '^(version|filename):'
filename:       /lib/modules/6.12.118+deb13-amd64/updates/dkms/zfs.ko.xz
version:        2.3.9-0+deb13u1

A module reload is a useful test after a rebuild, but it requires exporting all pools and stopping the event daemon. On zfs1, as root:

# zpool export tank
# zpool export raidpool
# systemctl stop zfs-zed.service
# modprobe -r zfs
# modprobe zfs
# systemctl start zfs-zed.service

The export, service, and module commands are silent on success. Import the pools again and verify the data:

# zpool import -a
# zpool list
NAME       SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
raidpool  2.88G  1.43M  2.87G        -         -     4%     0%  1.00x    ONLINE  -
tank       960M   319M   641M        -         -    13%    33%  1.00x    ONLINE  -

Encrypted datasets are unavailable after the re-import until their keys are loaded:

# zfs get -o property,value keystatus,mounted tank/secure
PROPERTY   VALUE
keystatus  unavailable
mounted    no
# zfs load-key -a
1 / 1 key(s) successfully loaded
# zfs mount -a

The load-key command reports the count; the mount is silent. The dataset is available again:

# zfs get -o property,value keystatus,mounted tank/secure
PROPERTY   VALUE
keystatus  available
mounted    yes

Stopping zfs-zed before modprobe -r is important because the daemon holds /dev/zfs open. Without stopping it, the module may report that it is in use. Exporting the pools first prevents the module from being unloaded while pools are active. This sequence is appropriate for a planned module test, not for a busy production host; a production reload needs a maintenance window and a tested recovery path.

A successful no-op rebuild is silent:

# dkms autoinstall

dkms autoinstall builds and installs modules for all installed kernels that need them. If everything is current, it prints nothing and exits zero. If it fails, the exit status is nonzero and the build log under /var/lib/dkms/zfs/<version>/build/make.log contains the compiler error. Check dkms status after the command; a kernel with no installed line still lacks a module.

The common causes of a failed build are a missing or mismatched headers package, a compiler update that is incompatible with the module source, and a kernel whose configuration is newer than the OpenZFS release. Recover by booting a kernel that still has a working module, installing the matching headers, and rebuilding:

# apt install linux-headers-$(uname -r)

The apt install is interactive; answer its prompt and let it finish before continuing. The header package name must match the running kernel exactly. uname -r expands to the version, so the command installs the headers for the kernel you booted, not for a different kernel that happens to be newest. If the headers are already installed, check that the build symlink /lib/modules/$(uname -r)/build points to a valid directory. A missing symlink usually means the headers package is absent or incomplete.

Rebuild the module and check its recorded state:

# dkms autoinstall

The command prints nothing when every installed kernel already has a module. After a successful rebuild, dkms status shows the installed module:

# dkms status
zfs/2.3.9, 6.12.118+deb13-amd64, x86_64: installed

If the line for the running kernel is missing or reports an error, read the build log before rebooting. A kernel with no installed line will not load ZFS after the next boot.

If the system boots from ZFS, rebuild the initramfs after the module is installed:

# update-initramfs -u -k all

This command is normally chatty and prints the kernel versions for which it builds images; that output is omitted here. Do not run it as a substitute for fixing the DKMS build; an initramfs without the ZFS module cannot import a ZFS root. On a data-only ZFS host, the initramfs does not need ZFS, but rebuilding it after a kernel change is still good practice.

If the new kernel has no module and cannot be fixed immediately, boot the previous kernel from the boot loader, keep the pools exported or imported as needed, and schedule the repair. Do not run zpool upgrade or enable new features while the only working module is older; the pool may become unreadable by the module you can actually boot. Secure Boot systems add one more step: if the DKMS key was regenerated, enroll the new certificate before expecting the module to load. Section 30.1.3 describes that flow.

30.6.3. Import Conflicts, Host Identity, and Preventing Concurrent Imports

Importing a pool that is already imported fails before any data is touched:

# zpool import tank
cannot import 'tank': a pool with that name already exists
use the form 'zpool import <pool | id> <newpool>' to give it a new name

On a single host, this usually means the pool is already active; use zpool list and zpool status rather than forcing a second import. On shared storage, it can mean another host has the pool. The multihost property uses the on-disk host ID to detect that situation and prevent concurrent writers.

Check the host identity:

# hostid
12345678

The value is stored in /etc/hostid:

# ls -l /etc/hostid
-rw-r--r-- 1 root root 4 Nov 24 14:48 /etc/hostid

The host ID is a four-byte value. zgenhostid creates or replaces /etc/hostid:

# zgenhostid -f 0x12345678

The command is silent. Verify the value:

# hostid
12345678

hostid prints the value. Use a unique value per host that may share storage. Do not copy /etc/hostid between hosts in a cluster; the identity is what distinguishes them. On a system with a firmware-provided host ID, zgenhostid may not be necessary, but the file can still exist from an earlier installation.

Enable multihost protection on the pool:

# zpool set multihost=on tank
# zpool get multihost tank
NAME  PROPERTY   VALUE      SOURCE
tank  multihost  on         local

The zpool set command is silent; the query shows the new value. The property is stored in the pool and travels with it. When a host imports a multihost pool, ZFS records that host's ID and checks it on subsequent imports. If another host tries to import the pool while it is active, or if the host ID does not match the recorded owner, the import is refused or warns. The exact message depends on the state and the OpenZFS version; the safe response is to stop and determine which host owns the pool, not to pass -f automatically.

Export and re-import the pool to exercise the normal path with multihost enabled:

# zpool export tank
# zpool import tank
# zpool status -x
all pools are healthy

The export and import are silent; the status query confirms health. Disable the property when it is no longer needed:

# zpool set multihost=off tank

The command is silent. Leave multihost enabled on any pool whose devices can be seen by more than one host, including SAN LUNs, shared SAS enclosures, and virtual disks attached to more than one guest. The property does not replace physical access control: a host that can write the disks can still damage the pool if an administrator forces an import.

The import safety properties are:

Property or option Effect
multihost=on Records the importing host ID and detects concurrent imports
cachefile=/etc/zfs/zpool.cache Controls which pools are imported at boot
cachefile=none Leaves the pool out of the boot cache; import it manually
failmode=wait Suspends I/O when the pool becomes unavailable; the default for most pools
failmode=continue Returns errors to applications instead of waiting; can cause data loss
failmode=panic Panics the host on pool loss; useful only for tightly controlled clusters
zpool import -f Forces import of a pool that appears active; verify the other host first
zpool import -N Imports without mounting, for inspection or recovery
zpool import -l Loads encryption keys during import
zpool import -d /dev/disk/by-id Searches a specific device directory

failmode=continue is dangerous for a pool with a missing top-level vdev: the pool cannot provide the data, and returning errors to every application can turn a temporary outage into inconsistent files. Leave the default wait on general-purpose systems. A clustered application that can tolerate failed I/O may choose continue only with application-level fencing and testing.

30.6.4. Feature Upgrades and Recovery-System Compatibility

New pools use feature flags rather than a numeric pool version:

# zpool get version tank
NAME  PROPERTY  VALUE    SOURCE
tank  version   -        default

The - means the pool is feature-flag based, not that it has no version. An upgrade check reports whether any supported feature is still disabled:

# zpool upgrade tank
This system supports ZFS pool feature flags.

Pool 'tank' already has all supported and requested features enabled.

This is a healthy result, not an error. zpool upgrade enables every feature the running module supports that is not already enabled. It is a one-way operation: an older module or rescue system that does not know a newly enabled feature may be unable to import the pool, or may import it read-only. Run it only after confirming that every system that might need the pool supports the new features.

The list of supported features and their compatibility is:

# zpool upgrade -v | sed -n '1,18p'
This system supports ZFS pool feature flags.

The following features are supported:

FEAT DESCRIPTION
-------------------------------------------------------------
async_destroy                         (read-only compatible)
     Destroy filesystems asynchronously.
empty_bpobj                           (read-only compatible)
     Snapshots use less space.
lz4_compress                         
     LZ4 compression algorithm support.
multi_vdev_crash_dump                
     Crash dumps to multiple vdev pools.
spacemap_histogram                    (read-only compatible)
     Spacemaps maintain space histograms.
enabled_txg                           (read-only compatible)
     Record txg at which a feature is enabled

The (read-only compatible) marker means an older implementation that does not support the feature can still import the pool read-only, but cannot write it. Features without that marker can prevent import entirely. The legacy filesystem versions are listed separately:

# zfs upgrade -v | sed -n '1,18p'
The following filesystem versions are supported:

VER  DESCRIPTION
---  --------------------------------------------------------
 1   Initial ZFS filesystem version
 2   Enhanced directory entries
 3   Case insensitive and filesystem user identifier (FUID)
 4   userquota, groupquota properties
 5   System attributes

For more information on a particular version, including supported releases,
see the ZFS Administration Guide.

Feature flags replaced the old filesystem versions for new pools, but the legacy zfs upgrade command remains for old datasets. A dataset that reports an old version can be upgraded with zfs upgrade; a feature-flagged dataset reports no version number.

The state of specific features on a pool is visible in its properties:

# zpool get all tank | grep -E "feature@(encryption|raidz_expansion|bookmark_v2|embedded_data)"
tank  feature@embedded_data          active                         local
tank  feature@encryption             active                         local
tank  feature@bookmark_v2            enabled                        local
tank  feature@raidz_expansion        enabled                        local

enabled means the pool allows the feature to be used; active means it has actually been used and the pool now depends on it. Enabling a feature is not reversible by disabling it. Even a feature that is only enabled may already have changed the on-disk format enough to matter to an older implementation.

Feature compatibility is a recovery-planning problem. Keep a rescue image whose OpenZFS version is at least as new as the pools it may need to import. After a zpool upgrade, test that the rescue image can import the pool read-only before declaring the upgrade complete. If the rescue image is older, either upgrade it or delay the pool upgrade until it is. A backup stream is not a substitute for a compatible rescue environment: restoring a stream also requires a host that can receive it.

The compatibility pool property, available in current OpenZFS releases, can restrict which features a pool enables for a named compatibility set. It is useful when a pool must remain readable by an older release, but the exact feature sets and property syntax depend on the OpenZFS version. Check zpool get compatibility <pool> and the installed manual before relying on it; do not assume that a set name from another distribution exists on Debian.

30.6.5. ZFS Root Installations and Their Additional Boot and Recovery Requirements

A data pool can be imported after the system boots from ext4 or another root filesystem. A ZFS root is different: the boot loader must load a kernel and an initramfs that can import the root pool before the system can mount /. Debian supports this layout, but it adds packages and failure modes that a data-only host does not have.

The additional pieces are:

Component Requirement
zfs-initramfs Adds the ZFS module and import/mount logic to the initramfs
zfsutils-linux Provides zpool, zfs, and zgenhostid in the early boot environment
zfs-dkms Builds the module for each kernel used at boot
Boot loader support GRUB must be able to read the kernel and initramfs from the boot medium
Boot pool or /boot filesystem Many layouts keep /boot on a small pool or partition that the boot loader reads reliably
bootfs property Tells the pool which dataset contains the root filesystem
Kernel command line Uses the distribution's ZFS root syntax, commonly root=ZFS=<pool>/<dataset>
Recovery media Must support the pool's feature flags and the encryption/key layout if used

On a data-only host the package is not installed:

$ apt-cache policy zfs-initramfs
zfs-initramfs:
  Installed: (none)
  Candidate: 2.3.9-0+deb13u1
  Version table:
     2.4.4-1~bpo13+1 100
        100 https://deb.debian.org/debian trixie-backports/contrib amd64 Packages
     2.3.9-0+deb13u1 500
        500 https://deb.debian.org/debian trixie/contrib amd64 Packages
     2.3.5-2~bpo13+1 100
        100 https://deb.debian.org/debian trixie-backports/contrib amd64 Packages
$ dpkg -s zfs-initramfs
dpkg-query: package 'zfs-initramfs' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.

The current initramfs therefore contains no ZFS userspace or module:

# lsinitramfs /boot/initrd.img-$(uname -r) | grep zfs | wc -l
0

A zero count is expected on a host that boots from a non-ZFS filesystem and has not installed the package. On a ZFS-root system the same command should list ZFS binaries, libraries, and configuration. If it returns zero after installing zfs-initramfs, the initramfs was not rebuilt or the package's hook did not run; do not reboot until the image contains the ZFS components.

A typical ZFS-root installation creates a pool for the root filesystem and sets its bootfs property. The boot loader configuration points at the kernel and initramfs, and the initramfs imports the pool by ID or cache file, loads keys if needed, and mounts the root dataset. The exact layout varies by installer and by whether /boot is on ZFS, a separate ext4 partition, or a small boot pool. The firmware and boot loader must be able to read the kernel and initramfs; many layouts keep them on a filesystem or boot pool that the boot loader handles reliably, while GRUB builds with ZFS support can read a ZFS /boot. Once the kernel starts, the initramfs can import the root pool.

For recovery, boot a rescue environment with a compatible OpenZFS version and import the root pool without mounting it over the rescue system's own root. In the rescue environment, as root:

# zpool import -N -R /mnt <pool>
# zfs mount <pool>/<root-dataset>
# zfs mount -a

The import and mount commands normally print nothing when they succeed. The -R /mnt alternate root makes the pool's datasets appear under /mnt rather than at their normal mountpoints. -N imports without mounting so that you control the order. After mounting, bind the virtual filesystems, chroot into /mnt, and repair the module, initramfs, or boot loader. If the pool is encrypted, load the key before mounting. If the rescue environment's OpenZFS is older than the pool's features, it may refuse the import; use a newer rescue image rather than forcing the import with an incompatible module.

A ZFS root also changes snapshot and rollback planning, and recovery media are discussed in Chapter 16. A snapshot of the root dataset can restore the operating system to an earlier state, but it also rolls back /etc, package databases, and application data on that dataset. Keep separate datasets for /var, /home, and application data so that a root rollback does not discard user or service data. Test a root rollback in a virtual machine before relying on it in production, and keep a rescue image that can import the pool if the boot loader or initramfs is broken.

The procedures in this section assume a data-only ZFS host that boots from another filesystem. A ZFS root adds the boot, initramfs, key-loading, and recovery requirements above; test those steps on the target hardware before committing a production system.