stage4 of shutdown

Paul Sopka <[email protected]> Mon, 22 Dec 2025 18:20:54 +0100
Newsgroups gmane.comp.sysutils.supervision.general
Message-ID <aUl99mx7kR5qLq6b@NANDERTY>
--LUrHizxVewXjTtgr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hey everyone,

I am trying to improve my selfmade shutdown script a bit more.
After reading through the source of s6-linux-init again,
I realised that it can only work if s6-linux-init-hpr is on the root partition,
since all other partitions are umounted before its execution.

Although this is surely fine in most cases
(and my current implementation has the same limitation),
I was thinking about ways to avoid this limitation.
This seems be only possible by
remounting all partitions read-only during stage4.
(is there any downside to mounting read-only instead of umounting?)

Additionally, since my init/shutdown scripts are created for
s6-svscan only I have thought about simplifying the shutdown procedure by
avoiding the "SIGTERM, SIGKILL, umount all" dance alltogether,
with the following structure that should(?) allow this:
a)	Assumption: everything is directly or indirectly started by s6-supervise.
b)	Users are instructed to write umount (or remount read-only) down scripts for s6-rc,
	here the script responsible for the partition housing the binaries required for shutdown
	should remount read-ony instead of umount.
c)	The shutdown script looks roughly as follows:
	I	Stop all s6-rc services orderly using s6-rc -Da.
		If successful continue with II,
		else stop the shutdown procedure and run into rescue,
		since one of the failed transition could be a umount/remount.
	II	If I is successful stop all
		s6-supervise (also non s6-rc) services with s6-svc -D.
	III	If II is successful or after timeout force kill
		remaining services with s6-svc -K
	IV	Remount what is still mounted read-only (or umount)
		(e.g. manually mounted usb sticks).
	V	Actual "hardware shutdown"
Would this be reliable or did I overlook anything?

I look forward to hearing your thoughts!
Paul Sopka

--LUrHizxVewXjTtgr
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iQJPBAABCAA5FiEEklpwGqZx1YzBW1hqccfIWi6jD2IFAmlJffEbFIAAAAAABAAO
bWFudTIsMi41KzEuMTEsMiwyAAoJEHHHyFouow9iePkP/i+w/tJ8ueRE9FSNGe5Q
uTXY3TOMg+TH1Q3mfW5pLkWX50C5qilwr6abhIugGT+2X5svm3pmNliDYTx/r3tX
Or6L2z8UUge4YEr+JfsBzP03BrPIITBFPe2vzJOyrodIugFnv02AXu3iWvF/GGSn
oCwdAW9pxM6fi18D5qS4iBmkYaSzKCF0gOg+BYSTN8TdYhV3zzZAGFiPSNzRyMak
6U/jXaIFdK1SJZuzzT5Fw7Ud57dXJvnYs2hTLQ+3jFuw2nhg6QHCwyI0CldMuvng
j4SZdm8PlxrrpUXVc6W++5Mu+jHn/U7+pvxP+5HCW3I4lQT2VTXjtm4eq7DLI/+P
LeCGOcyS7L6sDlmE3PenwHZpBoGlG3FUfRDeZu6DKvJtjE3jrfq+2B0HP+bjY4M/
wkSqvOX0noxgrd+Xv7oWqp0QiZ4HZjUQk4dlM27tKLHMaqlDZ/w6yCykJWazYuGT
4IdukWY7G7Z1+R8krT3FMyrQYSedQ/V7GZGeUWZ/OKYgNx+n0GLNeh7yCKmHiqNK
iBPW0/QldxrhdQDDbyzZqNI5Ve++T1REmec+wGKgkCV98DAhnG9OANrn0hmVzXSf
lqoNa0tn1UbZG61b1DTv8p9cBpjoNTDtp19hoWdgIbOEaJE/afY845oczR4LBFKO
uVKu9FzBZ3jREhd/Y23E/ojI
=Tc8E
-----END PGP SIGNATURE-----

--LUrHizxVewXjTtgr--