From d55629b815715853a037e06d52444f19ab712e80 Mon Sep 17 00:00:00 2001 From: "Martin \"eto\" Misuth" Date: Wed, 31 Oct 2018 13:23:51 +0100 Subject: [PATCH 1/2] Add void.runit_readproctitle parameter to 2 and new void-runit(8) man page Our stage 2 was extended with void.runit_readproctitle= kernel command line parameter to optionally disable spawning system's runsvdir(8) with log proctitle. This is intended mainly for system rescue situations, when too many damaged services are logging too many error messages per second causing system's runsvdir(8) cpu load to skyrocket and pin single machine core to 100%. Although I am not doubting runsvdir(8)'s robustness, this behaviour is completely unnecessary especially since it can be easily disabled by not providing runsvdir(8) with proctitle log buffer. By exposing this tweak as kernel command line paramter, we allow sysadmins to prevent this situation on affected machines by editing kernel command line from boot loader. To distingusih this parameter from normal kernel parameters, prefix "void." was chosen. Also, by permanently adding it to bootloader's kernel invocation, one can effectively disable this functionality altogether, if they don't have use for it. I also added new void-runit(8) manpage stub intended to describe this and possibly other Void's specialised runit(8) scripts. In the future I would like to eventually extend it with those descriptions. --- 2 | 29 ++++++++-- Makefile | 1 + void-runit.8 | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 174 insertions(+), 5 deletions(-) create mode 100644 void-runit.8 diff --git a/2 b/2 index 0a39298..15347d3 100755 --- a/2 +++ b/2 @@ -3,11 +3,24 @@ PATH=/usr/bin:/usr/sbin +readproctitle='log: ...........................................................................................................................................................................................................................................................................................................................................................................................................' +for arg in $(cat /proc/cmdline); do + case $arg in + 'void.runit_readproctitle='* ) + doreadproctitle="$(echo "${arg}" | cut -d'=' -f2)" + if [ "0" = "${doreadproctitle}" ]; then + echo 'runit readproctitle disabled: '"${arg}"' (via kernel cmdline)' + readproctitle= + fi + ;; + esac +done + runlevel=default for arg in $(cat /proc/cmdline); do - if [ -d /etc/runit/runsvdir/"$arg" ]; then - echo "Runlevel detected: '$arg' (via kernel cmdline)" - runlevel="$arg" + if [ -d /etc/runit/runsvdir/"${arg}" ]; then + echo 'runit runlevel detected: '"${arg}"' (via kernel cmdline)' + runlevel="${arg}" fi done @@ -17,5 +30,11 @@ runsvchdir "${runlevel}" mkdir -p /run/runit/runsvdir ln -s /etc/runit/runsvdir/current /run/runit/runsvdir/current -exec env - PATH=$PATH \ - runsvdir -P /run/runit/runsvdir/current 'log: ...........................................................................................................................................................................................................................................................................................................................................................................................................' + +if [ -z "${readproctitle}" ]; then + exec env - PATH="${PATH}" \ + runsvdir -P /run/runit/runsvdir/current +else + exec env - PATH="${PATH}" \ + runsvdir -P /run/runit/runsvdir/current "${readproctitle}" +fi diff --git a/Makefile b/Makefile index 877969b..475ec93 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,7 @@ install: install -m644 halt.8 ${DESTDIR}/${PREFIX}/share/man/man8 install -m644 modules-load.8 ${DESTDIR}/${PREFIX}/share/man/man8 install -m644 vlogger.8 ${DESTDIR}/${PREFIX}/share/man/man8 + install -m644 void-runit.8 ${DESTDIR}/${PREFIX}/share/man/man8 ln -sf halt.8 ${DESTDIR}/${PREFIX}/share/man/man8/poweroff.8 ln -sf halt.8 ${DESTDIR}/${PREFIX}/share/man/man8/reboot.8 install -d ${DESTDIR}/etc/sv diff --git a/void-runit.8 b/void-runit.8 new file mode 100644 index 0000000..94b92dc --- /dev/null +++ b/void-runit.8 @@ -0,0 +1,149 @@ +.Dd October 31, 2018 +.Dt void-runit 8 +.Os +.Sh NAME +.Nm void-runit +.Nd information about Void Linux implementation of runit +.Sh SYNOPSIS +.Nm kernel +.Op Ar preceding kernel parameters ... +.Op Cm void.runit_readproctitle= Ns Ar 0|1 +.Op Ar void_runsvdir +.Op Ar succeeding kernel parameters ... +.Sh DESCRIPTION +Void Linux uses +.Xr runit 8 +as it's default +.Xr init 8 +system. +.Pp +Like in case of any other +Linux based operating system, original +.Xr runit 8 +init scripts have been slightly modified +to better suit Void's needs. +.Pp +Void's +.Xr runit 8 +usually does right thing +on it's own, by default, but you +are free to tweak its execution to better +match your installation requirements. +.Pp +This can be done by passing +.Nm +arguments through kernel command line to +.Xr runit 8 Ns . +.Pp +Currently following arguments are supported: +.Bl -tag -width " " +.It Cm void.runit_readproctitle= Ns Ar 0|1 +Disables +.Xr runsvdir 8 +.Xr readproctitle 8 Ns Ap Ns +s +.Ar log +functionality. +.Pp +This might be desirable on systems where many +.Xr runit 8 +services are damaged and are logging too many +error messages per send, causing +.Xr runsvdir 8 +to consume excessive amounts of cpu time or +when system's operator is using other tools to +capture uncaught system log messages. +.It Ar void_runsvdir +This is name of specific subdirectory within +.Pa /etc/runit/runsvdir Ns . +.Pp +For +.Xr runit 8 +it means same thing what +.Sy runlevel +or +.Sy target +means in other +.Xr init 8 +schemes (like system V init or systemd for example). +.Pp +Eg. if you set +.Ar void_runsvdir +to +.Sy default +then +.Xr runit 8 +will try to boot into +.Pa /etc/runit/runsvdir/default +directory (aka runlevel). +.Pp +Similarly if you set it to +.Sy single +then +.Xr runit 8 +will boot into +.Pa /etc/runit/runsvdir/single Ns , +which represents +.Sy single user mode Ns . +.Pp +There is no limit in number of +.Sy runsvdirs +(aka runlevels, targets) you can create, +but these +.Sy runsvdir +names are reserved by Void: +.Pp +.Bl -tag -width " " -compact +.It Cm default +.Sy runsvdir +into which Void boots by +default. +.It Cm single +Void boots into this +.Sy runsvdir +when boot error occurs (or when specifically +requsted by operator on kernel command line). +.It Cm current +Symlink to currently active +.Sy runsvdir +on a running system. +.El +.Pp +If not specified, +.Sy default +is assumed. +.Sh EXIT STATUS +Not applicable. +.Sh EXAMPLES +.Bd -literal -offset 0 +vmlinuz-4.66.1_7 rw void.runit_readproctitle=0 single +.Ed +.Sh SEE ALSO +.Xr runit 8 , +.Xr init 8 , +.Xr runsvdir 8 , +.Xr runsvchdir 8 , +.Xr sv 8 , +.Xr runsv 8 +.Sh HISTORY +This manpage was written when +.Cm void.runit_readproctitle= +boot parameter was added to official +.Nm 2 +(Void's runit stage 2) script of +.Nm void-runit +scripts package. +.Sh AUTHORS +.An Leah Neukirchen Aq Mt leah@vuxu.org . +.An Duncan Overbruck Aq Mt mail@duncano.de +.An Martin Mišúth Aq Mt et.code@ethome.sk +.Sh LICENSE +.Nm +is in the public domain. +.Pp +To the extent possible under law, +the creator of this work +has waived all copyright and related or +neighboring rights to this work. +.Pp +.Lk http://creativecommons.org/publicdomain/zero/1.0/ From d7104b95d902ffa452d97388120fecb66e0373d1 Mon Sep 17 00:00:00 2001 From: "Martin \"eto\" Misuth" Date: Wed, 31 Oct 2018 16:32:04 +0100 Subject: [PATCH 2/2] Typo fix in initial void-runit(8) commit mistyped `send` instead of `second`. --- void-runit.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/void-runit.8 b/void-runit.8 index 94b92dc..3b64c37 100644 --- a/void-runit.8 +++ b/void-runit.8 @@ -48,7 +48,7 @@ functionality. This might be desirable on systems where many .Xr runit 8 services are damaged and are logging too many -error messages per send, causing +error messages per second, causing .Xr runsvdir 8 to consume excessive amounts of cpu time or when system's operator is using other tools to