Skip to content

Add templated [email protected] #17483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LunarLambda
Copy link

@LunarLambda LunarLambda commented Jun 24, 2025

Runs zfs mount -R <dataset> at boot, after zfs mount -a. Intended to replace mountpoint=legacy in certain mount setups.

Motivation and Context

If a pool has multiple ZFS root filesystems (canmount=noauto mountpoint=/) (or some other dual-booting setup that utilizes ZFS across multiple systems), and those in turn each have child datasets (e.g., canmount=on mountpoint=/var/lib/mysql), then problems arise as zfs-mount.service will execute zfs mount -a, attempting to mount multiple datasets to the same location.

The typical solution is to set mountpoint=legacy and set a mount entry in /etc/fstab. This is cumbersome and easy to mess up.

Instead, introduce a [email protected] which runs zfs mount -R <dataset>, to be used in conjunction with canmount=noauto mountpoint=/path/...

Description

[email protected] is essentially identical to zfs-mount.service, with the following two changes:

  1. It is ordered After=zfs-mount.service, yielding an intuitive precedence order.
  2. It executes zfs mount -R <dataset> instead of zfs mount -a.

The build/install files have been adjusted to install [email protected] where appropriate.

As far as I can tell, the documentation does not directly mention zfs-mount.service, so I have not added or modified any documentation.

How Has This Been Tested?

I have tested it on a personal machine. Being essentially identical to zfs-mount.service, I would not expect there to be any issues with the implementation. Being a template unit, it will never be enabled by default, so 50-zfs.preset was left unmodified (I did verify that template units without a DefaultInstance= setting do not need to be disabled explicitly)

The dracut and initramfs-tools modules both do not use zfs-mount.service, so they are left unmodified. zfs-mount-generator adds a Before=zfs-mount.service ordering, and with [email protected] being After=zfs-mount.service, a consistent ordering is preserved here too.

Beyond this, I did not see any test files that directly deal with systemd services, so nothing was modified there. No core ZFS code was modified.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Quality assurance (non-breaking change which makes the code more robust against bugs)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@LunarLambda
Copy link
Author

zloop check failure seems unrelated to my changes.

@amotin amotin added the Status: Code Review Needed Ready for review and testing label Jun 24, 2025
Runs `zfs mount -R <dataset>` at boot, after `zfs mount -a`.
Intended to replace `mountpoint=legacy` in certain mount setups.

Signed-off-by: Meriel Luna Mittelbach <[email protected]>
@LunarLambda LunarLambda force-pushed the zfs-mount-template-service branch from 02da4cd to 8946425 Compare June 30, 2025 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Code Review Needed Ready for review and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants