The `reboot' command violates the principle of least astonishment: although named after the common and regular operation, it is /not/ the recommended and graceful way to reboot the machine. For example, it does not invoke rc.shutdown(8). The Handbook therefore recommends initiating a reboot[1] with `shutdown -r now', which is a longer and less obvious command. Because of this, many users (and especially those coming from Linux), have been using `reboot' for years when they should have been using `shutdown -r' instead. To make the interface more logical and intuitive, I propose that a breaking change be introduced that causes `reboot' invoked without parameters to have an effect equivalent to that of `shutdown -r now', and to provide the current `reboot' behavior via `fastboot' and/or a new command-line option, such as -f or --fast. With that change, the bare `reboot' will do what its name suggests: a graceful reboot of the system. This dangerous `reboot' behavior was discussed on #freebsd on the 23rd of July, 2024, where gentler ways to amend the situation were proposed, including improving the documentaion and displaying a warning or error message from `reboot'. ____________________ 1. https://docs.freebsd.org/en/books/handbook/boot/#boot-shutdown
(In reply to Anton Shepelev from comment #0) An important consideration in favor of my proposal is statistical: an overwhelming majority of situations when the user wishes to reboot his machine, call for a normal, graceful reboot, as effected by `shutdown -r [now]', rather than the fast reboot with an incomplete deinitialisation that `reboot' currently performs. It is therefore a matter of economy and elegance to make the more frequent command shorter and easier, and to handle the less frequent one as a special case with explicit activation. Since `reboot' and `halt' are a related pair, probably sharing a lot of the same code, my proposal affects them both in the same way. The existing `fastboot' and `fasthalt' aliases should them be redefined to `reboot -f' and `half -f' respectively.
I'd like to add my experience here, as I was the reason for that discussion on the IRC channel. While trying to write an rc script for a program of mine, I spent hours trying to figure out why my shutdown procedure didn't work. Only after lengthy debugging, and with help from the kind folks on #freebsd, was I able to determine that the problem wasn't with my rc script but rather with the fact that I had been using "reboot" instead of "shutdown -r now." Although it was quickly pointed out that the behavior of "reboot" is clearly documented, I had no indication that I should even look at the docs for "reboot". Coming from a Linux background, I was under the assumption it would simply reboot the machine. And reboot it did, so nothing gave me any hint that I was doing something wrong. I had been restarting my FreeBSD machines using "reboot" for years at that point. This led me on a wild goose chase for a fault in my script that didn't exist. I was made aware that the meaning of "reboot" as "skip proper procedures" is a very old default and that changing this established behavior could disrupt old scripts and ingrained habits. However, at the very least, I believe a hint - such as printing something like "emergency reboot, skipping proper shutdown!" to stdout or stderr - should be added to the "reboot" command.
With that said, I'm still in favor of actually changing the meaning of "reboot" to be less surprising for new users.
Embedded systems sometimes need a reboot this instant functionality. However, that can be bound to a number of other historic interfaces. In our systems at $WORK we have almost no aliases, but we do have "reboot" aliased to "shutdown -r now" This was hashed out maybe 15 or so years ago, and there was only mild support for doing something like this at the time. Since then, Linux's way has become more entrenched and the 'reboot right this instant' crowd has gone from small, but significant minority to almost nonexistant group. Most people tolerate the behavior, but few strongly support it. I'd suggest that we only do the current behavior when invoked as 'fastboot' or 'fasthalt'. But I fear it would be a big bikeshed, so that "we" will need to be someone else.
If anybody were to feel disenfranchised, there's always `init 6' or `kill -6 1'.
Maybe we can at least get that warning message about the shutdown being non-graceful in the mean time. Fun fact: I keep habitually typing "reboot" into machines, only to remember I made a mistake a few seconds later.
Q.E.D.: the current behavior of `reboot' is anti-intuitive, and should be changed to perform a /normal/ reboot of the system.
Wow, such a broad statement. While it might be counter-intuitive to some people there is obviously a cohort that finds the current behavior quite intuitive. I am one of them and used to what reboot(8) has been doing for decades.
(In reply to Anton Shepelev from comment #0) > a new command-line option, such as -f I like the idea, but -f is already taken: reboot [-cDdflNnpqr] [-e variable=value] [-k kernel] [-o options] It is an option for -k (No reboot or halt will be performed /boot/kname/kernel does not exist unless the -f flag is specified.)
Maxim Konovalov: > While it might be counter-intuitive to some people there > is obviously a cohort that finds the current behavior > quite intuitive. I am one of them and used to what > reboot(8) has been doing for decades. Habit is not intuition. For exaple, vi's `hjkl' navigation is not intuituve, yet users learn it by constant practice. I still insist that `reboot' is counter-intuitive because by default and without any parameters it should perform a normal, graceful reboot. Ed Maste: > > a new command-line option, such as -f > > I like the idea, but -f is already taken: > > reboot [-cDdflNnpqr] [-e variable=value] [-k kernel] [-o options] Who'd imagine so meny options and parameters to `reboot'? Where did you find them? On official man-page the syntax differs: reboot [-cdlNnpqr] [-k kernel] <https://man.freebsd.org/cgi/man.cgi?reboot(8)> Anyway, even if -f (for fast) and -q (for quick) are taken -- something I ought to have checked myself -- how about the uppercase -F?
(In reply to Anton Shepelev from comment #10) There is no one true intuition. It is always a function of subjective perception, previous experience, and zillion other factors. So what we have here is your intuition versus someone else intuition. I guess that the statement you made just based on your previous experience (or habit) with linux probably. My experience is different therefore expectations how reboot should work on FreeBSD.
I haven't commented so far since I don't care that much and wanted to see how the discussion goes. But I wasn't using reboot because of my experience with Linux, I was using it because it's called reboot. And while it's rebooting the system, it turns out that if I want to reboot I should actually be using shutdown instead. That is just bad design and violates the principle of least astonishment FreeBSD normally champions. In fact, with the way I use FreeBSD, I will never use the current reboot directly, so for myself I created a shell alias to shutdown -r now. And this is a FreeBSD pitfall I have seen multiple people fall into. And it is not just beginners. For instance this forum post starts with: "For over 20 years I have used the command: reboot. And never had any problems in my time. I frequently see the manuals say to use the command: shutdown -r now. Why is this used instead of "reboot" and what is the difference?" https://forums.freebsd.org/threads/reboot-my-way-or-reboot-your-way.89185/ I understand that there are people with different usage patterns and expectations, but I personally am in favour of changing the behavior of reboot and halt. I wouldn't even add a fast flag as there still will be fastboot and fashalt. But I can also accept if the current situation remains as it is.
I believe the issue stems from the way "reboot, the action" is easily conflated with "reboot, the command". When users are told to "reboot," it’s natural to assume that the simplest and most direct way to do so is by running reboot. For example, even freebsd-update instructs users: "[...] Please reboot and run freebsd-update again [...]". It’s reasonable to assume that many users will instinctively type reboot in response - I certainly did. And why wouldn’t they? At no point is there any indication that "reboot" is not intended for normal reboots. Casual use of the term "reboot", even in official tools, reinforces the assumption that the reboot command is the correct and expected way to do so. So while official tools could certainly use "shutdown -r now" instead of "reboot", I strongly believe that "reboot" is so deeply ingrained in the vocabulary of both IT professionals - including FreeBSD devs it seems - and everyday users, that trying to educate every potential FreeBSD user about this distinction would be an uphill battle. Regardless of prior experience with Linux or whatever else.
Created attachment 257061 [details] make reboot and halt aliases for shutdown -r now and shutdown -h now I created a patch to show how a change could potentially look if there is ever consensus to move ahead. I only tested it lightly. A few notes: - I kept the names of the _PATH_REBOOT and _PATH_HALT in include/paths.h despite them referring to fastboot and fasthalt as I wasn't sure who else was using them - I renamed reboot.{c,8} to fastboot.{c,8} but left the directory as reboot - I wasn't sure what to do with the history section of the fastboot.8 file. It still talks about the history of reboot - Since they are now derived from shutdown, the permissions and group ownership of reboot and halt change. It was -r-xr-xr-x root wheel and is now -r-sr-xr-- root operator
(In reply to Daniel Tameling from comment #14) The right place to litigate this is in arch@FreeBSD.org. I'd send an email there and point people at this bug and the code. I'd also expand the writeup you've done here. If there's enough interest, we can likely get it committed. But if you don't publicize it more broadly, it will die here w/o anybody doing anything because it's too big a change for any one developer to do unilaterally. I'll support it, though I might want reboot -f and halt -f to invoke fastboot and fasthalt.
(In reply to Warner Losh from comment #15) I assume you mean freebsd-arch@FreeBSD.org? I don't think arch@FreeBSD.org exists. I will write something up and send it in the next few days. Thanks for the advice.
How is the mailing list discussion progressing? Just a quick reminder: there’s a very simple, low-effort improvement available that, while it doesn’t resolve the root issue, would significantly improve the current situation. At the very least, inform the user that what just occurred wasn’t a normal reboot. Print a clear message, something like: "Emergency shutdown active - skipping normal shutdown procedures" This kind of feedback would go a long way in reducing confusion, it certainly would have saved me hours of debugging.
... Anything?
Re-assigned the PR to DES as he just recently overhauled this code.
The requested change was made in FreeBSD 16 in December.
Which one, the message informing the user or an actual change in the behavior of the command? Very much appreciated either way!
Ah, I think this is the commit: https://github.com/freebsd/freebsd-src/commit/4453ec5b8716bc465ff5192986099dc75d1f2ce7 So it's not only a message but a change to the actual behavior of the command. Very, very much appreciated! Thanks! It's only a few days since I've accidentally typed "reboot" into one of my FreeBSD machines, haha.