Home Explore Blog Models CI



nixpkgs

1st chunk of `nixos/doc/manual/administration/zfs-state.section.md`
b386a59b31ea3a89dbbf870ecd40b106de36e34b46f1670e0000000100000335
# ZFS {#sec-zfs-state}

When using ZFS, `/etc/zfs/zpool.cache` should be persistent (or a symlink to a persistent
location) as it is the default value for the `cachefile` [property](man:zpoolprops(7)).

This cachefile is used on system startup to discover ZFS pools, so ZFS pools
holding the `rootfs` and/or early-boot datasets such as `/nix` can be set to
`cachefile=none`.

In principle, if there are no other pools attached to the system, `zpool.cache`
does not need to be persisted; it is however *strongly recommended* to persist
it, in case additional pools are added later on, temporarily or permanently:

While mishandling the cachefile does not lead to data loss by itself, it may
cause zpools not to be imported during boot, and services may then write to a
location where a dataset was expected to be mounted.

Title: ZFS Cachefile Persistence
Summary
This section discusses the importance of persisting the ZFS `zpool.cache` file, typically located at `/etc/zfs/zpool.cache`. This file is crucial for discovering ZFS pools during system startup. While pools holding the `rootfs` or early-boot datasets can be configured with `cachefile=none`, it is strongly recommended to persist `zpool.cache` for all other scenarios, especially considering potential future additions of ZFS pools. Failure to persist this cachefile can lead to pools not being imported during boot, which may cause services to write data to incorrect locations, although it does not directly cause data loss.