I have an encrypted partition that I configured with crypttab like


name UUID=<THE_UUID> none luks,noauto

and /etc/fstab

UUID=<THE_UUID> /mnt/mountpoint ext4 defaults,noauto 0,0

Now, I want the unit nfs-server.service to start up automatically once I manually decrypted the partition using systemctl start [email protected]. With some advice on the #debian-Matrix-Channel I finally got

# systemctl edit nfs-server.service
[email protected]

With this setup I can start the nfs-server after decrypting manually. Still, I'd prefer systemd to automatically start nfs-server (which in turn should already auto-mount the then decrypted partition).

How do I need to edit the nfs-server.service (or maybe even another unit?) in order for systemd to start it automatically once I decrypted the partition? I guess I could similarly use the logic for other units to start automatically after the nfs-server.service?

1 Answer 1


You can alter the crypt service and add the weak dependency on the nfs server into it. It will try to start the nfs-server.service but won't fail if it fails to start. This is done with Wants= in the [Unit] section of the controlling service ([email protected]):


Then, it should try to start NFS server once you successfully run systemctl start [email protected].

It is wise to never alter original configuration files and only add custom configuration snippets into drop directories if it is possible. One big reason for that is that updates won't touch your add-on snippet files, another is that this helps to keep configuration clean and tidy, makes it easier to integrate configuration management like Ansible and so on.

It is possible in systemd with its overrides. In this case you can alter your [email protected] like this:

systemctl edit [email protected]

and only put the [Unit] section there as I described previously. (Under the hood it will create the drop directory /etc/systemd/system/[email protected] and put or edit the contents into override.conf file inside it.) I suggest also to move to the same way of management for nfs-server.service too.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .