I have now a laptop with Ubuntu 18.04 and i love it. i have mounted /tmp as tmpfs via /etc/fstab
line as this:
tmpfs /tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777 0 0
now, i like to know how i can do this only with systemd
, i need only to activate a new systemd
service only (tmp.mount
related), or i need one more thing ? how i can replace my actual /etc/fstab
line with systemd
in my laptop on live mode?
Please note that using
/etc/fstab
is still the preferred approach with systemd!See the man page for systemd.mount which states:
systemd ships systemd-fstab-generator which converts those to mount units.
If you really want to turn that mount into a mount unit, my recommendation is to check its current exact configuration, with the following command:
Or:
Which will show you the dynamic unit created by systemd-fstab-generator, and should look similar to:
You could save these contents into
/etc/systemd/system/tmp.mount
and runsystemctl enable tmp.mount
to activate it. (You will need to add an[Install]
section and aWantedBy=local-fs.target
to be able to successfully enable it.)(Another option is to use the tmp.mount from the systemd sources. Some other distributions, like Fedora, are shipping and enabling that one.)
Don't forget to remove the one from
/etc/fstab
, otherwise they might conflict. (I believe the one in fstab would prevail, as I'd expect/run
to have priority over/etc
.)But, as said before, managing through
/etc/fstab
is still the preferred solution... So I'd probably recommend you still stick with that one.