How to Completely Disable the ‘zfs-mount’ Service in Ubuntu Server

In Ubuntu Server environments utilizing the ZFS file system, the zfs-mount.service is a critical systemd unit responsible for automatically mounting all configured ZFS datasets during the boot process. While this automatic mounting behavior is essential for standard deployments, it can be highly undesirable in specific high-availability clustering, failover, or disaster recovery scenarios. For example, if a passive standby server automatically imports a zpool and mounts its datasets before the active server has relinquished control, it can lead to severe data corruption. In these specialized edge cases, administrators require strict manual control over when and where ZFS datasets are mounted.

This guide explains how to completely disable the zfs-mount.service in Ubuntu Server, preventing datasets from mounting automatically on boot.

Stop and Mask the zfs-mount Service

To ensure systemd completely ignores the automatic mount directive while still leaving the core ZFS kernel modules intact for manual operation, we must aggressively disable and mask the service.

  1. Log into your Ubuntu Server via SSH using an account with sudo privileges.
  2. First, stop the service if it is currently running (though its primary action is usually at boot):
    sudo systemctl stop zfs-mount.service
  3. Next, disable the service to prevent it from hooking into the default boot sequence:
    sudo systemctl disable zfs-mount.service
  4. Finally, to guarantee that the service cannot be accidentally triggered by another ZFS dependency or administrative script, mask it entirely:
    sudo systemctl mask zfs-mount.service

Verify the Service Lockdown

By masking the service, you have instructed systemd to symlink the unit file to /dev/null, effectively treating it as a black hole. The ZFS datasets will still exist, and the pool can still be imported, but the datasets will not mount to the filesystem tree automatically.

To verify the lockdown is successful, run the following command to check the status of the service:

systemctl status zfs-mount.service

The output will clearly state that the service is masked. If you reboot the server, you will find that running zfs list shows the datasets, but checking df -h will confirm they are not mounted to their respective mount points. You must now rely on sudo zfs mount -a or cluster management software to mount the datasets manually.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.