Sanoid fails to create zfs snapshot: invalid user/group sanoid

Sanoid has been working fine for the most part, but suddenly I noticed that silently there haven’t been zfs snapshots made automatically for some days now.

2026-04-03T19:32:21+02:00 systemd[1]: Started Sanoid snapshot service.
2026-04-03T19:32:21+02:00 sanoid[697691]: ignored key 'recursive' from user-defined default template.
2026-04-03T19:32:21+02:00 sanoid[697691]: ignored key 'recursive' from 'default' template.
2026-04-03T19:32:22+02:00 sanoid[697712]: cannot create snapshots : permission denied
2026-04-03T19:32:22+02:00 sanoid[697691]: CRITICAL ERROR: zfs snapshot failed, 256 at /nix/store/y7i6annfadz6sz9rn4slc51kx2crv7v1-sanoid-2.3.0/bin/.sanoid-wrapped line 705.
2026-04-03T19:32:22+02:00 sanoid[697714]: cannot create snapshots : permission denied
2026-04-03T19:32:22+02:00 sanoid[697691]: CRITICAL ERROR: zfs snapshot failed, 256 at /nix/store/y7i6annfadz6sz9rn4slc51kx2crv7v1-sanoid-2.3.0/bin/.sanoid-wrapped line 705.
2026-04-03T19:32:22+02:00 sanoid[697717]: cannot destroy snapshots: permission denied
2026-04-03T19:32:22+02:00 sanoid[697691]: could not remove : 256 at /nix/store/y7i6annfadz6sz9rn4slc51kx2crv7v1-sanoid-2.3.0/bin/.sanoid-wrapped line 413.
2026-04-03T19:32:22+02:00 zfs[697719]: Usage:         unallow [-rldug] <"everyone"|user|group>[,...]
...
2026-04-03T19:32:22+02:00 zfs[697719]: zfs: error: invalid user/group sanoid

In the nixos module, the service config sets DynamicUser = true, so I would expect this to work.

The relevant part from the generated service’s Service section:

DynamicUser=true
ExecStart=/nix/store/y7i6annfadz6sz9rn4slc51kx2crv7v1-sanoid-2.3.0/bin/sanoid --cron --configdir /nix/store/24dcynd6kng2vamb9j1yrvvpvpz281s9-sanoid.conf
ExecStartPre=-+/run/booted-system/sw/bin/zfs allow sanoid snapshot,mount,destroy zroot/keep
ExecStopPost=-+/run/booted-system/sw/bin/zfs unallow sanoid snapshot,mount,destroy zroot/keep
Group=sanoid
RuntimeDirectory=sanoid
User=sanoid

So it seems the ExecStartPre’s execution of zfs can’t resolve the user/group sanoid.

I found something similar in nixos/glance: glance-start-pre: install: invalid user 'glance' · Issue #409348 · NixOS/nixpkgs · GitHub, but restarting the service does not work for me.

Also Seeking advice on how to fix ddclient service dependencies

Does anybody else have this issue?

1 Like

Is there a reason why you both use a dynamic user and also try to set the user. If I recall correctly the user and group are only created when the service is started and removed when the service is stopped. Might be the reason it does not exist.

This is the generated service config when using upstream sanoid as a module, I did not write it.

Then also per systemd.exec, these go together. So at the start of the service, a user and group will be created with the names specified by User= and Group=, when using DynamicUser=.

I’ve got the same (similar) config and generated service file as you, but I’m not seeing any issues on multiple machines. You might want to go check your zfs datasets and snapshots and make sure there’s no weird permission issues going on.