Here is the video version, if you prefer it:
When you want to shut down your system, the following happens: (Ward, 2014)
init
asks every process to shut down- If some processes (or a process) don’t respond,
init
initiates a kill with aTERM
signal - If some processes (or a process) don’t respond still,
init
initiates a kill with aKILL
signal - The system makes preparations for a shutdown
- The system unmounts all of the other filesystems other than root
- The system remounts the root filesystem in read-only mode (meaning you can’t write, only read)
- The system writes out all of the data left over in the buffers to the filesystem (this happens during the remounting process; see (“Is the root filesystem unmounted during a Linux shutdown?,” n.d.))
- The kernel reboots or stops the system
My 2 cents – just know this conceptually. The only case where you will need to go deep into the details of this will be if you need to optimize something on a Linux machine (most likely you would be doing this professionally), if you need to know the details to accomplish some other task or if you are really really curious.
Hope you learned something useful!
References
Is the root filesystem unmounted during a Linux shutdown? (n.d.). Retrieved February 13, 2020, from https://unix.stackexchange.com/questions/298216/is-the-root-filesystem-unmounted-during-a-linux-shutdown
Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Pages 144-145
Subscribe to my newsletter to keep abreast of the interesting things I'm doing. I will send you the newsletter only when there is something interesting. This means 0% spam, 100% interesting content.