Date: Wed, 12 Mar 2025 18:01:41 +0100 From: Edgar Fuß <e...@math.uni-bonn.de> Message-ID: <z9g99xdkapuqu...@trav.math.uni-bonn.de>
| I know /etc/init called /bin/sh /etc/rc back in the day, It still does, normally. | but things may have changed. Not really. | init(8) says "Executes /etc/rc". It does, but "rc" is "run commands" - it both is, and always was, and forever will be, a script (that is its reason to exist), which needs an interpreter to run it. "Executing a script" is just a shorthand way of saying "exexute the interpreter for which this script is designed to use and tell it to run this script". /etc/rc has #!/bin/sh. That's not really much more that a comment in this case, though it does allow /etc/rc to be run from single user mode (rather than "sh /etc/rc"), if there's some good reason to do that. That's rare, as the environment in which that runs (eg: having a controlling tty, connected stdin/out/err) isn't that in which the rc script expects to be invoked. | But sbin/init.c has | argv[0] = "sh"; | argv[1] = _PATH_RUNCOM; [...] but that argv[0] there is just what becomes $0 which /etc/rc only uses in error/log messages. | So I guess the manpage should be re-phrased. I doubt there's a real need for that. | Any better idea for using an alternate shell than exec /rescue/sh <<EOF? If you give boot the -a switch, then, as well as other things, it will ask what path to init to use (it defaults to the normal one). If you tell it /rescue/init instead, then that init will use /rescue/sh as the shell to run the rc script. kre ps: updating the fundamental stuff on an active system, however you do it, is always going to be a very dangerous operation. If you do that kind of thing in single user mode (and have /rescue as a fallback in case anything goes wrong) and you do in in the boring, slow, way (ie: no running steps in the background because they take a while, and then going ahead and doing "other stuff" while it happens) then there's very little possibility (power fails, hardware faults, ... excepted, which is why /rescue is needed, just in case) anything can go wrong. There are many ways to do the actual updates, but as long as there's nothing which is going to try and use something while it is being updated (and that you never try to write on top of a file being used - always make new files and rename to be what is the proper name once the file contents are all in place) there's very little chance of anything going wrong. Personally, I just have a second root filesystem, update the one not being used (then it is just a mounted filesys somewhere, being used by nothing) and once that's finished, just reboot, using the different root filesys, then if something goes wrong, just reboot again to the older version, fix the problem, and try again.