LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How does GRUB know whether to load hibernated image or load kernel from scratch (https://www.linuxquestions.org/questions/programming-9/how-does-grub-know-whether-to-load-hibernated-image-or-load-kernel-from-scratch-4175452007/)

linkaran 02-27-2013 10:53 PM

How does GRUB know whether to load hibernated image or load kernel from scratch
 
I understand that when you hibernate the system,a snapshot of the RAM contents is taken and is saved on sawap device. I read that when you select the kernel from your grub menu,it checks the swap device for a swsusp signature and if found then loads the target kernel, otherwise regular boot occurs. So what exactly is "it"? n where does the code to check the signature lie?

Thanks in advance!

TobiSGD 02-28-2013 04:38 PM

Grub does not know if there is a hibernated system, it always loads the kernel and initrd the same way. It is the kernel/init system itself that looks for the signature and decides to either make a normal startup or restore the hibernated system.

linkaran 02-28-2013 09:10 PM

Thank you for your reply.

So it is the init system that will always check the active resume device for a swsusp signature.If it finds one, it will load the target kernel and hand over the control to it thereafter. That makes sense. Thanks.

Also I was having another minor query as to what should happen to a kernel thread if it is hibernated but the user process whose request it was serving was just killed before hibernating the system?

TobiSGD 02-28-2013 09:27 PM

The init system will not load a different kernel (what you call target kernel). The kernel always is started first (without a kernel there would be nothing the init system can run on), then the init system is started. If the init system finds the signature it restores the saved state from the disk, otherwise it runs the normal startup sequence.

Quote:

Also I was having another minor query as to what should happen to a kernel thread if it is hibernated but the user process whose request it was serving was just killed before hibernating the system?
I don't get that. After the system is restored from the saved state it is exactly like it was before before hibernating, so there is no difference in execution if the system was hibernated in the meantime.


All times are GMT -5. The time now is 01:28 AM.