I used to use the fstab file for mounting drives. This time i wanted to use Units instead and created a .mount file. However i wonder how i would set a file system check option and umask settings there.
For example in a fstab file you would do that by adding (just as an example)
umask=000 0 1
I'm not sure if i can just use the same options in a .mount file?
- 13
- 2
-
Check the `DirectoryMode=` option, mentioned in `man systemd.mount`. – ajgringo619 Aug 06 '23 at 16:34
1 Answers
To start with, umask=000 0 1 is not a mount option; it's three separate fields, only the first of which contains mount options.
The
umask=000part is the actual option list; it usually can be directly used in systemd'sOptions=parameter. All options that would be passed to the filesystem work the same way as they do in fstab. The only exception are pseudo-options such asuserorX-mount.mkdirthat would make sense to the 'mount' program rather than the filesystem itself.[Mount] Options=rw,fmask=0133,dmask=022The
0that follows it is the "dump" field, an indicator for the ancient dump(8) backup tool. It is not used when mounting (rather, 'dump' reads fstab on its own), so there is no systemd equivalent.The final
1is the "fsck pass" field, used to activate fsck for this filesystem. The systemd equivalent for this is an explicit dependency on the fsck service instance:[Unit] Requires=systemd-fsck@dev-disk-by\x2dpartlabel-EFI.service After=systemd-fsck@dev-disk-by\x2dpartlabel-EFI.serviceUse
systemd-escape --path [email protected] /dev/footo conveniently generate the correct unit name for your device.
If in doubt, add an fstab entry, reload systemd, then use systemctl cat to look at the .mount unit that systemd generated for you. (And then continue just using that fstab entry.)
# echo "/dev/sdz1 /mnt/movies ext4 umask=077 0 0" >> /etc/fstab
# systemctl daemon-reload
# systemctl cat mnt-movies.mount
- 4,580
- 20
- 27