Bug#862013: initramfs-tools-core: /run tmpfs size hardcoded at 10% RAM, but 16.0 MiB free required in /run/systemd
Hi, Using 10% of RAM for /run is a good default, but not suitable for all systems. 10% might be too small for system with less memory (e.g. virtual machine with 160 MiB RAM) or too big (VM host with 256/512 GiB RAM). A too small /run partition leads to not enough space on it. If the /run partition is huge, systemd's journald will consume lot of memory, because it defaults to using at most 15% of the respective file system of /run/log/journal. Adjusting the size of /run via an entry in /etc/fstab is not sufficient since journald calculates it limits before systemd remounts /run with the small size. Therefore journald could occupy the full /run partition with its logs. Allow specifying the size of /run by adding a RUNSIZE configuration variable and a ramsize= boot argument. Mounting /run must be done after reading the configuration. A tested patch is attached and I created a merge proposal: https://salsa.debian.org/kernel-team/initramfs-tools/merge_requests/2 -- Benjamin Drung System Developer Debian & Ubuntu Developer ProfitBricks GmbH Greifswalder Str. 207 10405 Berlin Email: benjamin.dr...@profitbricks.com URL: https://www.profitbricks.de Sitz der Gesellschaft: Berlin Registergericht: Amtsgericht Charlottenburg, HRB 125506 B Geschäftsführer: Achim Weiss, Matthias Steinberg, Christoph SteffensFrom 6569b72cad0145843b55022fa6bc9e00a75a6d79 Mon Sep 17 00:00:00 2001 From: Benjamin DrungDate: Tue, 15 May 2018 12:12:56 +0200 Subject: [PATCH] Make size of /run configurable Using 10% of RAM for /run is a good default, but not suitable for all systems. 10% might be too small for system with less memory (e.g. virtual machine with 160 MiB RAM) or too big (VM host with 256/512 GiB RAM). A too small /run partition leads to not enough space on it. If the /run partition is huge, systemd's journald will consume lot of memory, because it defaults to using at most 15% of the respective file system of /run/log/journal. Adjusting the size of /run via an entry in /etc/fstab is not sufficient since journald calculates it limits before systemd remounts /run with the small size. Therefore journald could occupy the full /run partition with its logs. Allow specifying the size of /run by adding a RUNSIZE configuration variable and a ramsize= boot argument. Mounting /run must be done after reading the configuration. Closes: #862013 Signed-off-by: Benjamin Drung --- conf/initramfs.conf | 11 +++ init| 19 ++- initramfs-tools.8 | 7 +++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/conf/initramfs.conf b/conf/initramfs.conf index f0f5071..da862bc 100644 --- a/conf/initramfs.conf +++ b/conf/initramfs.conf @@ -62,3 +62,14 @@ DEVICE= NFSROOT=auto +# +# RUNSIZE: ... +# +# The size of the /run mount point in bytes, and rounded up to entire pages. +# This option accepts a suffix % to limit the instance to that percentage of +# your physical RAM or a suffix k, m or g for Ki, Mi, Gi (binary kilo (kibi), +# binary mega (mebi) and binary giga (gibi)). +# Overridden by optional ramsize= bootarg +# + +RUNSIZE=10% diff --git a/init b/init index 8a40b42..aa2fae6 100755 --- a/init +++ b/init @@ -33,8 +33,6 @@ export quiet mount -t devtmpfs -o nosuid,mode=0755 udev /dev mkdir /dev/pts mount -t devpts -o noexec,nosuid,gid=5,mode=0620 devpts /dev/pts || true -mount -t tmpfs -o "noexec,nosuid,size=10%,mode=0755" tmpfs /run -mkdir -m 0755 /run/initramfs # Export the dpkg architecture export DPKG_ARCH= @@ -101,6 +99,9 @@ for x in $(cat /proc/cmdline); do ;; esac ;; + runsize=*) + RUNSIZE="${x#runsize=}" + ;; nfsroot=*) NFSROOT="${x#nfsroot=}" ;; @@ -147,9 +148,9 @@ for x in $(cat /proc/cmdline); do debug=y quiet=n if [ -n "${netconsole}" ]; then - exec >/dev/kmsg 2>&1 + log_output=/dev/kmsg else - exec >/run/initramfs/initramfs.debug 2>&1 + log_output=/run/initramfs/initramfs.debug fi set -x ;; @@ -169,7 +170,7 @@ for x in $(cat /proc/cmdline); do ;; netconsole=*) netconsole=${x#netconsole=} - [ "x$debug" = "xy" ] && exec >/dev/kmsg 2>&1 + [ "x$debug" = "xy" ] && log_output=/dev/kmsg ;; BOOTIF=*) BOOTIF=${x#BOOTIF=} @@ -201,6 +202,14 @@ else resume=${RESUME:-} fi +mount -t tmpfs -o "noexec,nosuid,size=${RUNSIZE:-10%},mode=0755" tmpfs /run +mkdir -m 0755 /run/initramfs + +if [ -n "$log_output" ]; then + exec >$log_output 2>&1 + unset log_output +fi + maybe_break top # Don't do log messages here to avoid confusing graphical boots diff --git a/initramfs-tools.8 b/initramfs-tools.8 index 0eee050..61a2fcb 100644 --- a/initramfs-tools.8 +++ b/initramfs-tools.8 @@ -88,6 +88,13 @@ mounts the rootfs read-only. \fB\fI rw mounts the rootfs read-write. +.TP +\fB\fI ramsize +The size of the /run mount point in bytes, and rounded up to entire pages. +This option accepts a suffix % to limit the instance to that percentage of +your
Bug#862013: initramfs-tools-core: /run tmpfs size hardcoded at 10% RAM, but 16.0 MiB free required in /run/systemd
Thanks for the suggestions! On the subject of RAM requirements, for i386 systems (the case in my original message) a minimum of 128 MB is still mentioned in https://www.debian.org/releases/stable/i386/ch03s04.html.en Thus it might make sense to automatically cater for such low-mem i386 systems, or at least mention those fstab adjustments in the installation instructions. Best regards J Esteves
Bug#862013: initramfs-tools-core: /run tmpfs size hardcoded at 10% RAM, but 16.0 MiB free required in /run/systemd
On Tuesday, 27 June 2017 4:19:56 AM AEST Michael Biebl wrote: > > Now what can we do about /dev and /sys/fs/cgroup neither of which needs to > > be 24G in size on a system with 48G of RAM? Should I open a new bug > > report about this? > > What exactly would that solve? > Neither of those are writable by the user. In the past I've dealt with buggy scripts running as root, either writing to the wrong name of a device or writing to a device that wasn't there. https://www-uxsup.csx.cam.ac.uk/misc/horror.txt See Mike Stefanik's entry in the above file for an example. -- My Main Blog http://etbe.coker.com.au/ My Documents Bloghttp://doc.coker.com.au/
Bug#862013: initramfs-tools-core: /run tmpfs size hardcoded at 10% RAM, but 16.0 MiB free required in /run/systemd
Am 27.06.2017 um 04:03 schrieb Russell Coker: > Now what can we do about /dev and /sys/fs/cgroup neither of which needs to be > 24G in size on a system with 48G of RAM? Should I open a new bug report > about > this? What exactly would that solve? Neither of those are writable by the user. Michael -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? signature.asc Description: OpenPGP digital signature
Bug#862013: initramfs-tools-core: /run tmpfs size hardcoded at 10% RAM, but 16.0 MiB free required in /run/systemd
For /run specifying the number of inodes is also a good idea. For a system with 160M of RAM it will default to 20480 inodes which may be more than you want on a system with less than the recommended amount of RAM. tmpfs /run tmpfs nosuid,noexec,size=20M,nr_inodes=4096 0 0 The above might be more suitable for the use of J M Cerqueira Esteves. Thanks Michael for suggesting the use of /etc/fstab, I've tested it and it solves the issue of /run. Now what can we do about /dev and /sys/fs/cgroup neither of which needs to be 24G in size on a system with 48G of RAM? Should I open a new bug report about this? -- My Main Blog http://etbe.coker.com.au/ My Documents Bloghttp://doc.coker.com.au/
Bug#862013: initramfs-tools-core: /run tmpfs size hardcoded at 10% RAM, but 16.0 MiB free required in /run/systemd
Am 27.06.2017 um 02:08 schrieb Michael Biebl: > You can add a entry to /etc/fstab which specifies the desired amount of > RAM for /run. > systemd will remount /run with the size you set very early during boot. > I don't think a separate config option is necessary. Something like this in /etc/fstab should do the trick tmpfs /run tmpfs nosuid,noexec,size=20M 0 0 Michael -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? signature.asc Description: OpenPGP digital signature
Bug#862013: initramfs-tools-core: /run tmpfs size hardcoded at 10% RAM, but 16.0 MiB free required in /run/systemd
On Sun, 07 May 2017 13:38:11 +0100 J M Cerqueira Esteveswrote: > Package: initramfs-tools-core > Version: 0.130 > Severity: important > > In a virtual machine with 160 MiB RAM, running a freshly installed Debian > stretch system (i686), Since wheezy, the minimum requiremensts are 256M of RAM: https://www.debian.org/releases/wheezy/amd64/ch03s04.html.en > got messages like this logged from (at least) sh and ifup: > >"Failed to reload daemon: Refusing to reload, not enough space available > on /run/systemd. > Currently, 15.6M are free, but a safety buffer of 16.0M is enforced." > > I noticed that /usr/share/initramfs-tools/init mounts /run specifying > "size=10%". > > To prevent this issue in machines low on RAM, it would be nice for the /run > tmpfs size > to be automatically set taking into account systemd's minimum requirement. > Or, at least, > to have this size as a nicely (/etc/...) configurable parameter with some > warning on README. You can add a entry to /etc/fstab which specifies the desired amount of RAM for /run. systemd will remount /run with the size you set very early during boot. I don't think a separate config option is necessary. Michael -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? signature.asc Description: OpenPGP digital signature
Bug#862013: initramfs-tools-core: /run tmpfs size hardcoded at 10% RAM, but 16.0 MiB free required in /run/systemd
Package: initramfs-tools-core Version: 0.130 Severity: important In a virtual machine with 160 MiB RAM, running a freshly installed Debian stretch system (i686), got messages like this logged from (at least) sh and ifup: "Failed to reload daemon: Refusing to reload, not enough space available on /run/systemd. Currently, 15.6M are free, but a safety buffer of 16.0M is enforced." I noticed that /usr/share/initramfs-tools/init mounts /run specifying "size=10%". To prevent this issue in machines low on RAM, it would be nice for the /run tmpfs size to be automatically set taking into account systemd's minimum requirement. Or, at least, to have this size as a nicely (/etc/...) configurable parameter with some warning on README. -- System Information: Debian Release: 9.0 APT prefers testing APT policy: (500, 'testing') Architecture: i386 (i686) Kernel: Linux 4.9.0-2-686-pae (SMP w/1 CPU core) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages initramfs-tools-core depends on: ii cpio 2.11+dfsg-6 ii klibc-utils 2.0.4-9 ii kmod 23-2 ii udev 232-22 Versions of packages initramfs-tools-core recommends: ii busybox 1:1.22.0-19+b3 Versions of packages initramfs-tools-core suggests: ii bash-completion 1:2.1-4.3 -- no debconf information