1

I have the following mount and automount units enabled for my external USB drive.

Mount Unit:

[Unit]
Description=Time Machine Drive Mount Service

[Mount]
What=/dev/disk/by-uuid/some-uuid
Where=/media/timemachine
Type=hfsplus

[Install]
WantedBy=multi-user.target

Automount Unit:

[Unit]
Description=Time Machine Drive Automount Service

[Automount]
Where=/media/timemachine

[Install]
WantedBy=multi-user.target

How do I tell systemd to bind the mount point to another directory every time I plug in the drive?

0

This issue for the upstream project systemd would seem to indicate that what you're trying to do is not possible, and they aren't going to add it, mainly due to limitations with how the kernel works.

excerpt

please note that bind mounts after they have been made are entirely independent entry points to the same file system than the original mount used to create them. This means, after creating /opt/oh as bind mounts the fact that /mnt/sda is on an automount point is entirely irrelevant for its lifecycle: the new bind mounts point directly to the effective file system, they lose any automount magic. And that's a kernel design choice and is nothing systemd can do anything about it.

Sorry, but systemd can't do what you want to do, because the kernel simply doesn't work that way!

sorry!

At any rate, you're left with alternative methods, one of which is described in this U&L Q&A titled: Bind USB drive to home directory on demand.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.