#-----------------------------------------------------------
setup_tmp_tmpfs() {
- local fstab="/etc/fstab"
- if [[ -f "${fstab}" ]] ; then
+ echo -e "\e[0Ksection_start:$( date +%s ):ks_setup_tmp_tmpfs\r\e[0KSetting up /tmp as a tmpfs ..."
+ echo
+ echo "${HASH_LINE}"
+ echo
+ log "Setting up /tmp as a tmpfs by a systemd mount unit ..."
+ echo
+ mkdir --parents --verbose /etc/systemd/system/tmp.mount.d
+ cat > /etc/systemd/system/tmp.mount.d/mount_options.conf <<-EOF
+ [Mount]
+ Options=mode=1777,strictatime,nosuid,nodev,size=10%%,nr_inodes=1m
+ EOF
- 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}' ..."
+ echo
+ echo "Generated /etc/systemd/system/tmp.mount.d/mount_options.conf:"
+ echo "---------- snip -----------"
+ cat /etc/systemd/system/tmp.mount.d/mount_options.conf
+ echo "---------- snip -----------"
- echo 'tmpfs /tmp tmpfs nosuid,size=10% 0 0' >>"${fstab}"
+ echo
+ echo "Enabling unit tmp.mount ..."
+ systemctl enable tmp.mount
- echo -e "\e[0Ksection_end:$( date +%s ):ks_setup_tmp_tmpfs\r\e[0K"
- fi
+ echo -e "\e[0Ksection_end:$( date +%s ):ks_setup_tmp_tmpfs\r\e[0K"
}
setup_tmp_tmpfs