LinuxQuestions.org
Visit Jeremy's Blog.
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
 
LinkBack Search this Thread
Old 08-17-2012, 03:42 AM   #1
linkaran
LQ Newbie
 
Registered: Aug 2012
Posts: 17

Rep: Reputation: Disabled
Hibernate-Snapshot device


I would like to know how the snapshot of the system is taken during hibernation(S2disk) which is then stored in the swap partition.A typical /etc/suspend.conf shows that the snapshot device to be used is set to /dev/snapshot. Please suggest something to make my understanding better as to how the snaphot image is created and exactly how it is stored at its position which is then loaded into memory on resume(resume device parameter embedded into initramfs).
 
Old 08-18-2012, 02:13 PM   #2
business_kid
Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 5,953

Rep: Reputation: 496Reputation: 496Reputation: 496Reputation: 496Reputation: 496
As I understand it, the system at any point has a kernel running and stuff loaded in relevant spots. By putting these things back in memory exactly as they were and telling everything where to take up, you _should_ be back to where you were before the suspend.

In fact it never works as cleanly as that(Murphy's Law), and there's 'glue software' to fix that.
 
Old 08-18-2012, 11:27 PM   #3
linkaran
LQ Newbie
 
Registered: Aug 2012
Posts: 17

Original Poster
Rep: Reputation: Disabled
Thanks for the reply.

As you explained,the contents of RAM as they were before suspend are stored in swap and on resume the kernel loads them into memory again on resume to give us a feeling of a new kernel being loaded and resume to the state as we suspended in.

My question is how exactly is this snapshot taken and saved into the swap partition? And at what point during boot is this image loaded into the memory?
 
Old 08-20-2012, 03:49 AM   #4
business_kid
Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 5,953

Rep: Reputation: 496Reputation: 496Reputation: 496Reputation: 496Reputation: 496
Quote:
Originally Posted by linkaran View Post
Thanks for the reply.

As you explained,the contents of RAM as they were before suspend are stored in swap and on resume the kernel loads them into memory again on resume to give us a feeling of a new kernel being loaded and resume to the state as we suspended in.

My question is how exactly is this snapshot taken and saved into the swap partition? And at what point during boot is this image loaded into the memory?
Isn't this the beauty os Open Source, that you can look at the code for yourself and figure these things out? I never bothered, once it worked. If you boot, suspend, & resume then the dmesg output carries a blow by blow as it unhooks usb, etc.

If you tell us why you need this information, we may be able to help.
 
Old 08-21-2012, 02:40 AM   #5
linkaran
LQ Newbie
 
Registered: Aug 2012
Posts: 17

Original Poster
Rep: Reputation: Disabled
Thanks for the reply.

Well my long goal is to achieve a kind of hybrid between hibernation and shutdown where I close all the user-space program before powering down the system and also create a hibernation image. We use this image to the boot the system.

I am in the initial stage of learning the mechanism of S2disk and studying the role played by pm-utils,ACPI and initramfs.Right now I am trying to locate the process/code responsible for the creation of image and storing it in the swap.I hope this gives a broad idea of the work.
 
Old 08-21-2012, 03:37 AM   #6
business_kid
Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 5,953

Rep: Reputation: 496Reputation: 496Reputation: 496Reputation: 496Reputation: 496
To quote the Irishman when asked for directions:
"If I was you, I wouldn't start from here at all!"

Suspend and resume are major deals requiring balancing of all sorts of things. They were developed over years by project teams. For instance, the original APM implementation couldn't effectively handle IBM Thinkpads, which broke a number of expected norms and created havoc with interrupts. So it was dropped, and a whole new approach (acpi) was started, which initially was worse on many boxes.

You don't need a suspend, or hibernate. You want switch off,and autostart, and something like initng which boots and shuts down quicker. The beauty of suspend and hibernate is that you stay there with your same lusers logged into the same places, same programs running, reading same files, with environment variables intact, etc. This is behaviour you do not want.
 
Old 08-21-2012, 08:05 PM   #7
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,589

Rep: Reputation: 161Reputation: 161
Suspend and hibernate are hardware dependent. Programs designed to implement an interface between the operating system and hardware facilities for suspend/hibernate must comply to the relevant hardware, because it is the basis of those functions.

Neither is designed to boot a cold system. Hibernate begins to load the system image by a makeshift init linked to /sbin/init, in a conditional way, so if it fails, the system is recoverable.

Of course, it doesn't work that way, but that's the goal.
 
  


Reply

Tags
hibernate


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LVM device-mapper not deleted on snapshot removal nayabingi Linux - Server 3 10-05-2011 01:55 PM
Hibernate one distro, de-hibernate another Ulysses_ Linux - Software 8 12-28-2010 09:34 AM
13.1 Beta1 :: KDE SC 4.4.3 :: pm-hibernate works, KDE hibernate just locks the screen zordrak Slackware 7 05-12-2010 03:55 AM
How can I read the COW metadata for the device-mapper snapshot? liu1103xwxw Linux - Kernel 2 01-03-2010 08:58 PM
cli hibernate works but gnome panel hibernate fails BCarey Linux - Desktop 1 06-08-2007 10:21 AM


All times are GMT -5. The time now is 11:23 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration