LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 08-14-2018, 09:50 AM   #1
Unturned3
Member
 
Registered: Jan 2018
Posts: 39

Rep: Reputation: Disabled
How does Linux shuts it self down?


Hello,
On the internet there are a lot of articles explaining the Linux boot process, but I couldn't find any detailed information describing the shutdown process. When I run the halt command, what exactly happens in the system? How does the init process get affected during reboot/poweroff?
I made a simple Linux system using Busybox init, and unlike mainstream Linux distributions, the little system just prints "System Halted" when it shuts down but it doesn't actually terminate the QEMU or VirtualBox session. What's causing this to happen?

Any help/explanation would be appreciated!
Thanks.
 
Old 08-14-2018, 09:54 AM   #2
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
Quote:
Originally Posted by Unturned3 View Post
Hello,
On the internet there are a lot of articles explaining the Linux boot process, but I couldn't find any detailed information describing the shutdown process. When I run the halt command, what exactly happens in the system? How does the init process get affected during reboot/poweroff?
I made a simple Linux system using Busybox init, and unlike mainstream Linux distributions, the little system just prints "System Halted" when it shuts down but it doesn't actually terminate the QEMU or VirtualBox session. What's causing this to happen?

Any help/explanation would be appreciated!
Thanks.
Would it not be the reverse of the start-up process ? I think it would be.
 
Old 08-14-2018, 10:29 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,568

Rep: Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865
Basically, ACPI sends a signal to the BIOS to physically turn off a computer and VirtualBox does emulate the same functionality. If you are not using APCI then upon shutdown the CPU stops and you will see the displayed halted message.

Back in the old days one would have to physically press the power switch (it was not a momentary push button then) to remove power.

Last edited by michaelk; 08-14-2018 at 10:31 AM.
 
Old 08-14-2018, 01:26 PM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
"halt" (the system) does not necessarily "shut down" (the power).
 
Old 08-16-2018, 04:44 AM   #5
Unturned3
Member
 
Registered: Jan 2018
Posts: 39

Original Poster
Rep: Reputation: Disabled
Thanks for the replies. I forgot to add ACPI support while compiling the kernel (to keep it small)! Turns out that's the reason why the VMs isn't quitting automatically.
However I still don't understand what happens to the init process when the system goes down. From what I've learned so far, I know that init will perform tasks such as killing services or unmounting disks upon shutdown, based on how it's configured. But does the init process actually exits? Won't that result in a kernel panic? (I guess the kernel is somehow notified that init will go down?)

Thanks!
 
Old 08-16-2018, 05:01 AM   #6
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
Quote:
Originally Posted by Unturned3 View Post
...I know that init will perform tasks such as killing services or unmounting disks upon shutdown, based on how it's configured. But does the init process actually exits? Won't that result in a kernel panic? (I guess the kernel is somehow notified that init will go down?)

Thanks!
From https://en.wikipedia.org/wiki/Init

Quote:
Init is a daemon process that continues running until the system is shut down. It is the direct or indirect ancestor of all other processes and automatically adopts all orphaned processes.
The above would imply that once services have been killed, disks unmounted, etc, the init process ending is the last thing that happens before ACPI does it's thing to kill power to the system.

Yes, if the init process was killed before that, then yes, it would cause a "kernel panic" to happen.
 
  


Reply

Tags
internals, kernel, poweroff, reboot, shutdown


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux shuts down randomly Vlaj Linux - Newbie 54 04-29-2018 04:41 PM
The Foresight Linux Project shuts down jeremy Linux - News 1 05-13-2015 09:01 PM
How Linux Kernel Shuts Down ? aarsh Linux - Kernel 4 11-11-2010 12:44 AM
Linux shuts down without any message enot Linux - Newbie 5 09-07-2006 10:23 AM
linux proxy server shuts down onyangoliech Linux - Networking 2 01-19-2006 03:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 04:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration