1

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?

1
  • Check the DirectoryMode= option, mentioned in man systemd.mount. Commented Aug 6, 2023 at 16:34

1 Answer 1

1

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.

  1. The umask=000 part is the actual option list; it usually can be directly used in systemd's Options= 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 as user or X-mount.mkdir that would make sense to the 'mount' program rather than the filesystem itself.

    [Mount]
    Options=rw,fmask=0133,dmask=022
    
  2. The 0 that 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.

  3. The final 1 is 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.service
    

    Use systemd-escape --path [email protected] /dev/foo to 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

You must log in to answer this question.

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