1

If the root filesystem is unmounted, then how can init be accessed to run the last few steps that occur afterwards?

bumped to the homepage by Community 2 days ago

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

0

init is the first process to be executed after the kernel was loaded and the last to "shut down the lights" - figuratively spoken.
The kernel does not need / to be mounted to run init, as it can be run completely from memory.
"Live" distributions are running almost completely from memory and there are even some, whose cd/dvd/usbstick/floppy you can even remove from the pc after the system was loaded into memory.

Now to the question in the title of your question: yes, it is unmounted on most distributions - other remount / read-only.

More information can be found in /etc/inittab (if the system is running with sysvinit) of your system and for example on http://wiki.linuxquestions.org/wiki/Run_Levels

On systemd you can view which objects are evaluated with systemctl list-dependencies --after systemd-halt.service.

  • And distribtions take care that none of the tasks they want to do after unmounting / require filesystem access. – Henrik Jul 25 '16 at 19:21
  • RedHat 6, for example, remounts / readonly (/etc/rc.d/rc0.d/S01halt). – Stephen Harris Jul 25 '16 at 19:27
  • what I was trying to figure out right now: how can one tell what happens with systemd? at least on my ubuntu there is no /etc/inittab – Phillip -Zyan K Lee- Stockmann Jul 25 '16 at 19:30
  • The systemd-shutdown manpage may provide guidance. In particular it mentions: It is necessary to have this code in a separate binary because otherwise rebooting after an upgrade might be broken -- the running PID 1 could still depend on libraries which are not available any more, thus keeping the file system busy, which then cannot be re-mounted read-only. – Stephen Harris Jul 25 '16 at 19:41
  • systemctl list-dependencies --after systemd-halt.service got me a tree of units which are run/stopped/umounted after a shutdown was initiated. The man-page @StephenHarris mentioned led me to the explanation of systemd-halt.service and its friends systemd-poweroff.service, systemd-reboot.service and systemd-kexec.service. Which helped me with the list-dependencies command. Thanks for that. – Phillip -Zyan K Lee- Stockmann Jul 25 '16 at 19:44
0

PID 1 can be run from a RAM-based filesystem. For example systemd + dracut can pivot_root into a tmpfs during shutdown. dracut-shutdown.service(8) has some more information about this.

Otherwise, you remount the remaining filesystems as read-only. After remounting read-only, the filesystem is clean. It is consistent on-disk; requires no repair operations; has no remaining writes cached or queued up in RAM.

umount / is even interpreted the same as mount / -o remount,ro. Although that does not happen on other unix-likes; it is a Linux-specific quirk :-).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.