Score:0

systemd RequiresMountsFor multiline syntax

vn flag

I know that this is a valid systemd unit configuration file syntax:

[Unit]
RequiresMountsFor=/mnt/foo /mnt/bar
...

Recently, I've seen a multiline variant of the above:

[Unit]
RequiresMountsFor=/mnt/foo
RequiresMountsFor=/mnt/bar
...

Are these two syntaxes semantically equivalent?

I checked the RequiresMountsFor option in the systemd.unit manpage, which explicitly states: "Takes a space-separated list of absolute paths." Also there's a hint on similarities with Requires and After options. The Requires option's documentation explicitly states that the single-line and multi-line syntaxes are equivalent (for the Requires option): "This option may be specified more than once or multiple space-separated units may be specified in one option in which case requirement dependencies for all listed names will be created." So I'd guess that the same applies to RequiresMountsFor.

Score:1
ma flag

Looks like it’s equivalent indeed:

# tee /run/systemd/system/serverfault-1085820.service >/dev/null << 'EOF'
[Unit]
RequiresMountsFor=/mnt/foo
RequiresMountsFor=/mnt/bar
[Service]
ExecStart=echo hi
EOF
# systemctl daemon-reload
# SYSTEMD_PAGER=cat systemctl show -p RequiresMountsFor serverfault-1085820.service 
RequiresMountsFor=/mnt/bar /mnt/foo

This should probably be documented better in the manpage; it’s not true for all directives, as systemd.syntax(7) points out:

Various settings are allowed to be specified more than once, in which case the interpretation depends on the setting. Often, multiple settings form a list, and setting to an empty value "resets", which means that previous assignments are ignored. When this is allowed, it is mentioned in the description of the setting.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.