Under /etc/systemd/system the mount unit file was created with name “test.mount”. The mount point directory created is /home/test. Under the mount unit file options in the “Where=” the mount point configured is /home/test. The device where the filesystem will be mounted is /dev/xvdb1 and it was defined under “What=” option. When configuring mount unit file to mount a filesystem, it fails with the following error:
# systemctl start test.mount Failed to start test.mount: Unit is not loaded properly: Invalid argument. See system logs and 'systemctl status test.mount' for details.
# systemctl status test.mount ● test.mount - Test Mount Units Loaded: error (Reason: Invalid argument) Active: inactive (dead) Where: /home/test What: /dev/xvdb1
The /var/log/messages file shows the same errors:
Mar 20 15:34:19 [vm_name] systemd: test.mount's Where= setting doesn't match unit name. Refusing.
The mount unit under /etc/systemd/system has the incorrect mount unit file name. As per systemd.mount man page:
# man systemd.mount ... Where= Takes an absolute path of a directory of the mount point. If the mount point does not exist at the time of mounting, it is created. This string must be reflected in the unit filename. (See above.) This option is mandatory.
Above section in man pages shows – Mount units must be named after the mount point directories they control. Example: the mount point /home/john must be configured in a unit file home-john.mount. Important note the character “/” should change like “-”
Change the name of the mount file unit to correct name from: test.mount to home-test.mount. Test again to mount the mount unit.
# systemctl start home-test.mount # mount | grep test /dev/xvdb1 on /home/test type ext4 (rw,relatime,seclabel,data=ordered)