How does Linux operating system shut down?

Tim

Gilles wrote an excellent reply about how Linux kernel shuts down at https://unix.stackexchange.com/a/122667/674

I was wondering how Linux OS shuts down (in cases of both systemvinit and systemd)? I am expecting something similar to the boot sequence of Linux OS. I am particularly wondering how the processes notify each other, by some signal like SIGTERM and SIGKILL, or some other interprocess communication way?

Thanks.

Related:

What is the difference between "when the operating system shuts down" and "when the kernel shuts down"?

When the operating system shuts down, how does a service manager know that it should sends SIGTERM and SIGKILL to its services?

Stephen Kitt

With both sysvinit and systemd, shutting the operating system down starts by notifying the init process (the process with pid 1) that the system should shut down (or reboot, or power off).

sysvinit does this by using the /run/initctl FIFO to communicate with init, asking it to switch to the corresponding runlevel. See the init manpage for a brief overview.

systemd supports a variety of ways to do this. Various signals can be used to request a shutdown, reboot, etc., in various flavours; it’s also possible to request this over d-bus (the busctl manpage explains how to explore that).

Once pid 1 has been asked to shut down, it follows its configuration and specification and goes through all the appropriate steps for it. This typically includes notifying all users that a shutdown is in progress, shutting down all the running services (in a managed way with systemd; using shutdown scripts in various forms with sysvinit), syncing the mounted file systems, possibly unmounting them, killing all remaining processes (with the usual TERM then KILL sequence), and finally calling the kernel’s reboot system call with the appropriate parameters.

This describes the general sequence. There are many more twists to all this, including access control (with Polkit), various available hooks, kexec, sudden power-off handling, CtrlAltDel handling... The systemd documentation covers many of these details.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How does a linux-based operating system handle applications?

From Dev

How to lock down a specific operating system in grub

From Dev

How to check integrity of system if Wubi not shut down properly

From Dev

How do I shut down remote and local system from terminal?

From Dev

When the operating system shuts down, how does a service manager know that it should sends SIGTERM and SIGKILL to its services?

From Dev

How to shut down X?

From Dev

How to shut down Javafx?

From Dev

How can I catch or stop a Linux shut down from the terminal?

From Dev

How to shut down Linux if idle for 30+ minutes?

From Dev

How does the power button shut the computer down without root permission?

From Dev

How does the computer know that the PC was not properly shut down?

From Dev

How Fake raid communicates with Operating system(Linux)?

From Dev

After sleep state, PC with Linux doesn't let me shut down the system

From Dev

How does a Linux operating system recognize USB drive brand and other info?

From Dev

How does bash get commands into the operating system?

From Dev

How does a network port work?(operating system)

From Dev

How does design in an operating system work?

From Dev

How does Chrome detect the operating system

From Dev

How does the operating system manage processes

From Dev

How to shut down openconnect cleanly?

From Dev

Why do operating systems have an option to shut down?

From Dev

shut down system via REST url

From Dev

does a computer use RAM to shut down

From Dev

How to retain edit history in netbeans ide even after system shut down on windows?

From Dev

How do I shut down a Linux server after running for 60 minutes?

From Dev

System does not boot to operating system

From Dev

How does one skip “Windows did not shut down successfully” in Win7-64?

From Dev

How can I gracefully shut down RawCap?

From Dev

How to shut down a second UI thread

Related Related

  1. 1

    How does a linux-based operating system handle applications?

  2. 2

    How to lock down a specific operating system in grub

  3. 3

    How to check integrity of system if Wubi not shut down properly

  4. 4

    How do I shut down remote and local system from terminal?

  5. 5

    When the operating system shuts down, how does a service manager know that it should sends SIGTERM and SIGKILL to its services?

  6. 6

    How to shut down X?

  7. 7

    How to shut down Javafx?

  8. 8

    How can I catch or stop a Linux shut down from the terminal?

  9. 9

    How to shut down Linux if idle for 30+ minutes?

  10. 10

    How does the power button shut the computer down without root permission?

  11. 11

    How does the computer know that the PC was not properly shut down?

  12. 12

    How Fake raid communicates with Operating system(Linux)?

  13. 13

    After sleep state, PC with Linux doesn't let me shut down the system

  14. 14

    How does a Linux operating system recognize USB drive brand and other info?

  15. 15

    How does bash get commands into the operating system?

  16. 16

    How does a network port work?(operating system)

  17. 17

    How does design in an operating system work?

  18. 18

    How does Chrome detect the operating system

  19. 19

    How does the operating system manage processes

  20. 20

    How to shut down openconnect cleanly?

  21. 21

    Why do operating systems have an option to shut down?

  22. 22

    shut down system via REST url

  23. 23

    does a computer use RAM to shut down

  24. 24

    How to retain edit history in netbeans ide even after system shut down on windows?

  25. 25

    How do I shut down a Linux server after running for 60 minutes?

  26. 26

    System does not boot to operating system

  27. 27

    How does one skip “Windows did not shut down successfully” in Win7-64?

  28. 28

    How can I gracefully shut down RawCap?

  29. 29

    How to shut down a second UI thread

HotTag

Archive