Re: restarting s6-svscan (as pid 1)

2023-11-17 Thread Laurent Bercot

This may be a weird question, maybe: is there any way to persuade
s6-svscan (as pid 1) to restart _without_ doing a full hardware reboot?
The use case I have in mind is: starting from a regular running system,
I want to create a small "recovery" system in a ramdisk and switch to it
with pivot_root so that the real root filesystem can be unmounted and
manipulated. (This is instead of "just" doing a full reboot into an
initramfs: the device has limited storage space and keeping a couple
of MB around permanently just for "maintenance mode" doesn't seem like a
great use of it)


 As Adam said, this is exactly what .s6-svscan/finish is for. If your
setup somehow requires s6-svscan to exec into something else before
you shut the machine down, .s6-svscan/finish is the hook you have to
make it work.
 Don't let the naming stop you. The way to get strong supervision with
BSD init is to list your services in /etc/ttys. You can't get any
cheesier than that.

 That said, I'm not sure your goal is as valuable as you think it is.
If you have a running system, by definition, it's running. It has 
booted,

and you have access to its rootfs and all the tools on it; there is
nothing to gain by doing something fragile such as exec'ing into
another pid 1 and pivot_rooting. Unless I've missed something, the
amount of space you'll need for your maintenance system will be the
exact same whether you switch to it from your production system or from
cold booting.

--
 Laurent



Re: restarting s6-svscan (as pid 1)

2023-11-17 Thread Steve Litt
d...@telent.net said on Fri, 17 Nov 2023 22:20:32 +


>I was thinking I could use the .svscan/finish script to check for the
>existence of the "maintenance mode" ramfs, remount it onto /
>and then `exec /bin/init` as its last action, though it seems a bit
>cheesy to have a file called `finish` that actually sometimes performs
>`single-user-mode` instead. Would that work?

I don't know if it would work. Why not try it. Also, you might need to
make changes to the 3 script.

As far as "cheesy", the only disadvantage is self-documentation, and
self-documentation could be preserved by adding a properly named script
and calling or exec'ing it.

SteveT

Steve Litt 

Autumn 2023 featured book: Rapid Learning for the 21st Century
http://www.troubleshooters.com/rl21


Re: restarting s6-svscan (as pid 1)

2023-11-17 Thread adam
Quoting d...@telent.net (2023-11-17 14:20:32)
> I was thinking I could use the .svscan/finish script to check for the
> existence of the "maintenance mode" ramfs, remount it onto /
> and then `exec /bin/init` as its last action, though it seems a bit
> cheesy to have a file called `finish` that actually sometimes performs
> `single-user-mode` instead. Would that work?

I think your use case is *precisely* what .svscan/finish is for -- it's how you
get s6-svscan to exec() into some other process.  That other process can be an
instance of itself.

The fact that systemd has a special self-exec() mechanism always seemed weird
and bizzarre.  Just use the general mechanism.

> Perhaps a more general use case for re-execing pid 1 would be after OS
> upgrades as an alternative to rebooting

Sure, if you upgrade the libc or your compiler, and you want s6-svscan to use
those new libc/compiler, this is an easy way to do it.

> though other than wanting to preserve uptime for bragging rights I can't see
> any real advantage...

You can pass arbitrary large chunks of data to a re-exec()'ed pid1.  It's not
always easy to do that across a reboot, since you have to pass the data to the
bootloader and back.  Also "the data" could be open file descriptors.

  - a


restarting s6-svscan (as pid 1)

2023-11-17 Thread dan


This may be a weird question, maybe: is there any way to persuade
s6-svscan (as pid 1) to restart _without_ doing a full hardware reboot?
The use case I have in mind is: starting from a regular running system,
I want to create a small "recovery" system in a ramdisk and switch to it
with pivot_root so that the real root filesystem can be unmounted and
manipulated. (This is instead of "just" doing a full reboot into an
initramfs: the device has limited storage space and keeping a couple
of MB around permanently just for "maintenance mode" doesn't seem like a
great use of it)

I was thinking I could use the .svscan/finish script to check for the
existence of the "maintenance mode" ramfs, remount it onto /
and then `exec /bin/init` as its last action, though it seems a bit
cheesy to have a file called `finish` that actually sometimes performs
`single-user-mode` instead. Would that work?

Perhaps a more general use case for re-execing pid 1 would be after OS
upgrades as an alternative to rebooting - though other than wanting to
preserve uptime for bragging rights I can't see any real advantage...

Any thoughts?


Daniel