1229616e21
And enable it by default, since it's a sensible thing to do. This makes the bootmisc config file unnecessary, since it was only used before to make sure that /tmp was wiped on every boot. Mounting /tmp as a tmpfs will be skipped if: * The user or maintainer configured deviceinfo_tmp_as_tmpfs_size=0 * If they didn't but the device has less than 2GB of RAM * And in any case, if it is already mounted, to respect users that might have it in /etc/fstab The options for mounting /tmp has been copied from my local debian tmp.mount service. The only real difference is that we are mounting it after /etc/fstab, and they do so before. Fixes #2233
33 lines
856 B
Text
33 lines
856 B
Text
#!/sbin/openrc-run
|
|
|
|
depend() {
|
|
need localmount
|
|
after swapfile
|
|
before bootmisc
|
|
}
|
|
|
|
start() {
|
|
source /usr/share/misc/source_deviceinfo
|
|
|
|
if [ "$deviceinfo_tmp_as_tmpfs_size" = "0" ]; then
|
|
return 0
|
|
fi
|
|
|
|
_tmpfs_size="50%"
|
|
if [ -n "$deviceinfo_tmp_as_tmpfs_size" ]; then
|
|
_tmpfs_size="$deviceinfo_tmp_as_tmpfs_size"
|
|
fi
|
|
|
|
_mem_size_mb="$(LC_ALL=C free -m | awk '/^Mem:/{print $2}')"
|
|
# Mount if asked to, or if more than default memory,
|
|
# but never if already mounted
|
|
if [ -n "$deviceinfo_tmp_as_tmpfs_size" ] || \
|
|
[ $_mem_size_mb -ge 2048 ] && \
|
|
! mountinfo -q -f tmpfs /tmp ; then
|
|
ebegin "Mounting /tmp as tmpfs"
|
|
mkdir -p /tmp || { eend 1 "Failed to create /tmp" ; return 1 ; }
|
|
# mount params taken from Debian buster
|
|
mount -t tmpfs -o mode=1777,strictatime,nosuid,nodev,size="$_tmpfs_size",nr_inodes=400k tmpfs /tmp
|
|
eend $?
|
|
fi
|
|
}
|