Yes, you can indeed combine the use of systemd units to mount a block device when detected with parameterized unit files. Systemd supports instantiating units, which allows you to pass parameters to unit files. This is particularly useful for mounting devices dynamically based on their UUID or any other identifying parameter. Here's how you can set this up:
-
Create a Parameterized Unit File: You need to create a systemd mount unit file that can take the UUID as a parameter. This file should be named following the pattern
extdrive@.mount
. Place this file under/etc/systemd/system/
.Here's an example of what the content might look like:
[Unit] Description=Mount External Drive at %i Requires=local-fs.target
After=local-fs.target