Convert an fstab entry to a systemd mount unit on CoreOS

5,367

Solution 1

defaults is redundant. When any other options are in use, it can be omitted. It only exists to fill the relevant column in fstab.

And since auto is already a default, it too is redundant.

Solution 2

Yes, it is the proper way to create a mount unit using systemd.

Share:
5,367

Related videos on Youtube

hydrajump
Author by

hydrajump

Updated on September 18, 2022

Comments

  • hydrajump
    hydrajump over 1 year

    I want to convert the following fstab entry to a systemd mount unit on CoreOS,

    /dev/xvdb /data ext4 defaults,auto,noatime,noexec 0 0

    I created data.mount,

    [Unit]
    Description=MongoDB Data Directory
    
    [Mount]
    What=/dev/xvdb
    Where=/data
    Type=ext4
    Options=defaults,auto,noatime,noexec 0 0
    

    However, I had to remove 0 0 because the unit failed to start.

    [Unit]
    Description=MongoDB Data Directory
    
    [Mount]
    What=/dev/xvdb
    Where=/data
    Type=ext4
    Options=defaults,auto,noatime,noexec
    

    The unit above starts, but I'm not sure about the Options= string. Reading about the fstab options I wonder if some are redundant.

    According to Ubuntu Fstab - Community Help Wiki

    auto - The filesystem can be mounted automatically (at bootup, or when mount is passed the -a option). This is really unnecessary as this is the default action of mount -a anyway.

    defaults - Use default settings. Equivalent to rw, suid, dev, exec, auto, nouser, async.

    This leads me to the following unit,

    [Unit]
    Description=MongoDB Data Directory
    
    [Mount]
    What=/dev/xvdb
    Where=/data
    Type=ext4
    Options=defaults,noatime,noexec
    

    Is this the proper way to create a mount unit using systemd on CoreOS?