From 5d8640df60cf0ae4df73a003ac1787ab962ecb4c Mon Sep 17 00:00:00 2001 From: Didier Roche Date: Tue, 3 Mar 2015 17:43:21 +0100 Subject: [PATCH] Add systemd-emergency-tmpfs to force tmpfs on /tmp Force tmp.mount enablement if the system is low on disk space on /tmp. Tag the mount as "overflow" so that various UIs can detect and warn the user about this scenario. (LP: #1392637) --- debian/changelog | 4 ++++ debian/extra/generators/systemd-emergency-tmpfs | 27 +++++++++++++++++++++++++ debian/systemd.install | 1 + 3 files changed, 32 insertions(+) create mode 100755 debian/extra/generators/systemd-emergency-tmpfs diff --git a/debian/changelog b/debian/changelog index faf9f5f..0ff0358 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,10 @@ systemd (219-5) UNRELEASED; urgency=medium [ Didier Roche ] * Add "systemd-fsckd" autopkgtest. (LP: #1427312) + * Add systemd-emergency-tmpfs to force tmp.mount (tmpfs) enablement if the + system is low on disk space on /tmp. Tag the mount as "overflow" so that + various UIs can detect and warn the user about this scenario. + (LP: #1392637) -- Martin Pitt Tue, 03 Mar 2015 14:51:46 +0100 diff --git a/debian/extra/generators/systemd-emergency-tmpfs b/debian/extra/generators/systemd-emergency-tmpfs new file mode 100755 index 0000000..180dbdf --- /dev/null +++ b/debian/extra/generators/systemd-emergency-tmpfs @@ -0,0 +1,27 @@ +#!/bin/sh +# mount /tmp as tmpfs if /tmp is full so that the system still tries to boot +# tag it as "overflow" to warn the user. +set -e + +NORMAL_DIR="$1" +EARLY_DIR="$2" +LATE_DIR="$3" + +UNIT_PATH=/lib/systemd/system/tmp.mount +UNIT_OVERRIDE_PATH=${NORMAL_DIR}/tmp.mount.d +LOCAL_FS_WANTS_PATH=${NORMAL_DIR}/local-fs.target.wants/ + +avail=`df -BM -P /tmp/ | awk 'NR==2 { print substr($4, 0, length($4)-1) }'` +min_size=50 +[ "$avail" -gt ${min_size} ] && return 0 + +# add additional "overflow" tag +mkdir -p ${UNIT_OVERRIDE_PATH} +cat << EOF > ${UNIT_OVERRIDE_PATH}/99-emergency-tmpfs.conf +[Mount] +What=overflow +EOF + +# enable it +mkdir -p ${LOCAL_FS_WANTS_PATH} +ln -s ${UNIT_PATH} ${LOCAL_FS_WANTS_PATH} diff --git a/debian/systemd.install b/debian/systemd.install index e0eaed5..e559195 100644 --- a/debian/systemd.install +++ b/debian/systemd.install @@ -53,3 +53,4 @@ usr/share/locale/ ../../extra/tmpfiles.d/*.conf usr/lib/tmpfiles.d/ ../../extra/debian-fixup lib/systemd/ ../../extra/units/* lib/systemd/system/ +../../extra/generators/* lib/systemd/system-generators/ -- 2.1.4