Re: sysctl to prevent reboot?

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Thu, 10 Jul 2025 13:31:20 UTC

> On Jul 10, 2025, at 9:18 PM, Bjoern A. Zeeb <bzeeb-lists@lists.zabbadoz.net> wrote:
> 
> Hi,
> 
> I am not sure where but I thought I saw a change fly by which would
> prevent a shutdpwn -r /reboot (and possibly halt?) from being executed
> while a sysctl was set.
> 
> Does anyone have a reference or have I been dreaming?
> 
> I would find that very helpful for host systems running (multiple) bhyve
> instances.  Happened twice to me recently that I typed reboot in the wrong
> window and restarted my dev machine entirely rather than a guest.
> 
> /bz
> 
> -- 
> Bjoern A. Zeeb                                                     r15:7
> 


Hi Bjoern A,

I believe Konstantin's work [1] and  [2] are precisely what you need.

[1] https://cgit.freebsd.org/src/commit/?id=7fb88c20eccc3fd2118fda2ba58d7afe2b87f7e3 <https://cgit.freebsd.org/src/commit/?id=7fb88c20eccc3fd2118fda2ba58d7afe2b87f7e3>   shutdown(8): refuse to run if /var/run/noshutdown is present
[2] https://cgit.freebsd.org/src/commit/?id=384d976725a5c29734a9227fcdb6ef0807485c91 <https://cgit.freebsd.org/src/commit/?id=384d976725a5c29734a9227fcdb6ef0807485c91>  rc.d: Add precious_machine rc.conf knob to create /var/run/noshutdown

Best regards,
Zhenlei