#-----------------------------------------------------------
setup_tmp_tmpfs() {
- local fstab="/etc/fstab"
- if [[ -f "${fstab}" ]] ; then
+ echo -e "\e[0Ksection_start:$( date +%s ):ks_setup_tmp_tmpfs[collapsed=true]\r\e[0KSetting up /tmp as a tmpfs ..."
- echo -e "\e[0Ksection_start:$( date +%s ):ks_setup_tmp_tmpfs[collapsed=true]\r\e[0KSetting up /tmp as a tmpfs ..."
- echo
- echo "${HASH_LINE}"
- echo
- log "Setting up /tmp as a tmpfs in '${fstab}' ..."
+ local unit_file="/etc/systemd/system/tmp.mount"
+ echo
+ echo "Creating a systemd unit file '${unit_file}' providing a temp filesystem below /tmp"
- echo 'tmpfs /tmp tmpfs nosuid,size=10% 0 0' >>"${fstab}"
+ cat > "${unit_file}" <<-EOF
+ # Unit file for creating a temp filesystem below /tmp
- echo -e "\e[0Ksection_end:$( date +%s ):ks_setup_tmp_tmpfs\r\e[0K"
- fi
+ [Unit]
+ Description=Creating a temporary filesystem below /tmp
+ Before=local-fs.target
+
+ [Install]
+ WantedBy=local-fs.target
+
+ [Mount]
+ What=tmpfs
+ Where=/tmp
+ Type=tmpfs
+ Options=nosuid,size=10%%
+
+ EOF
+
+ echo
+ echo "Content of '${unit_file}':"
+ echo "---------- snip ----------"
+ cat "${unit_file}"
+ echo "---------- snip ----------"
+
+ echo -e "\e[0Ksection_end:$( date +%s ):ks_setup_tmp_tmpfs\r\e[0K"
}
setup_tmp_tmpfs