Hibernate feature in Linux
Reduce TUX’s metabolic activity!
Short URL: http://fsmsh.com/1520
- 2007-01-12
- Server side | Intermediate
-
Write a full post in response to this!
This content was sponsored by:
For a long time, hibernation has been associated with proprietary operating systems. Now, the feature has started taking the front row in GNU/Linux systems too. What’s more, it’s fast, flexible and is a real time saver!
Introduction
Software hibernation or suspend-to-disk is a very productive operating system feature. It has many advantages over a cold system start or reboot. Not only does the hibernated system load up faster, the user also gets back to his previous session without much effort. This is important because of the time the user saves by avoiding the need to set up a work session again.
So, how is hibernation different? It is different because it saves the contents of the RAM (Random Access Memory) into some non-volatile storage medium before shutting down the system. Consequently, when the system boots up again, the operating system loads the suspended image from disk to get back to the previously stored session.
Software suspend, as hibernation is popularly known in Linux systems, has evolved a lot in present day kernels. It is constantly getting more and more stable and useful. Some implementations are available in the kernel while one is available as a patch that can be applied to the 2.4 or the 2.6 series. This article is meant to introduce you to the implementations available and the features that they provide.
Not only does the hibernated system load up faster, the user also gets back to his previous session without much effort
History and available methods in Linux
The history of software suspend in Linux can be traced to Gabor Kuti and Pavel Machek who developed a patch for the 2.2 series known as swsusp. It was probably an abbreviation for swap suspend as the snapshot image was written to the active swap partition of the system. Gabor used to maintain these patches on his personal page. The code base for this patch became the basis for three different implementations that we have today: swsusp, suspend2 and uswsusp.
swsusp was first incorporated in the 2.5.18 kernel. It subsequently became a part of the 2.6 stable release. Later, a fork of swsusp, known as pmdisk evolved. The difference between swsusp and pmdisk was that the latter’s code was much cleaner and well structured. Moreover, while swsusp used the /proc interface, pmdisk used the /sys interface. pmdisk cleanups were eventually merged into the swsusp code base.
Among all the available methods, the one that generates the maximum excitement is suspend2 by Nigel Cunningham. It introduces some important changes in the way the snapshot image is handled and is also noticeably faster. suspend2 is currently available as a patch for 2.4 and 2.6 kernels and will hopefully be merged into the mainline kernels in future.
Also worth mentioning is uswsusp, abbreviation for userland-swsusp. It is an implementation of an interface for software suspend in the user space. All kernels starting from 2.6.17 have uswsusp merged in them. The module gives access to software suspend functionalities by exposing common file operation methods that can be used to operate on a character device. This is only useful for developers who would like to write their software suspend applications in user space and hence I won’t delve into this topic in detail here.
swsusp
How swsusp works
swsusp works by taking a snapshot of the contents of the RAM. This snapshot or suspend image is copied and then saved in an atomic operation fashion to the active swap partition. Upon rebooting, if a valid image signature is found on the active swap, the image is loaded and the snapshot transferred back to memory. This gets back the saved state to the user. The following illustration shows the sequence in simple terms:
- User requests for software suspend
- All the running processes are given the
suspendsignal - The devices are frozen so that they don’t change the system state when the snapshot is taken
- The memory image is atomically copied with interrupts disabled
- Frozen devices are awakened so that the image can be written
- The image is written to swap
- Devices are suspended and the system powered off
The resume process involves just the inverse of the above steps.
Configuration and running
Configuring and running swsusp is a breeze since it is a part of the 2.6 vanilla kernel. If swsusp has not been compiled in your running kernel, you will have to enable it and recompile your kernel. It is always a good idea to compile a fresh stable version instead of tinkering with the running version because that way you always have a backup with you.
To enable swsusp, bring up the kernel configuration window:
$cd /your/linuxsourcedir $make xconfig
Write a full post in response to this!
Similar articles
Do you like this post?
Vote for it!
Copyright information
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is available at http://www.gnu.org/copyleft/fdl.html.
Biography
Bandan Das: Bandan is an active user and supporter of Open Source Softwares. He is currently pursuing Master of Science in Computer Engineering from Syracuse University, NY. He loves programming in C and LISP and loves playing his guitar when he wants a break from gadgets and geek stuff.
Best voted contents
Buzz authors
Free Software news
- RT @turicas: The #Arduino #HackNBeer yesterday with @maddoghall at #UFF (in Niterói/RJ - Brazil) was amazing! \o/ #freesoftware #FTW
- Second Sole of Ohio | marymoome: http://tinyurl.com/25y6nzv #coolest #freesoftware #freesoftware Amor no respeta l... http://bit.ly/azeueY
- http://tinyurl.com/25y6nzv #coolest #freesoftware #freesoftware Amor no respeta ley ni obedece a rey A diario una manzana es cosa sana
- via @Developpez A new font for easier code writing: http://bit.ly/9AADsE under #OpenFontLicense #freesoftware
- RT @turicas: The #Arduino #HackNBeer yesterday with @maddoghall at #UFF (in Niterói/RJ - Brazil) was amazing! \o/ #freesoftware #FTW
Similar entries
Other sites
- The Top 10 Everything (Dave). The good, the bad and the ugly.
- Free Software news (Dave & Bridget). All about free software -- free as in freedom!
- Book Reviews: Illiterarty (Bridget). Book reviews, blogs, and short stories.
Hot topics - last 60 days
-
10 years on: free software wins, but you have nowhere to install it
Tony Mobily, 2010-07-29 -
Tales From the Front: in Search of APT-GET UNDO
Rosalyn Hunter, 2010-08-13 -
Finding Free Music for a Free Film with Jamendo, VLC, and K3B
Terry Hancock, 2010-07-13 -
The Jargon of Freedom: 60 Words and Phrases with Context
Terry Hancock, 2010-07-24 -
MediaWiki and Script Translation for the Morevna Project
Terry Hancock, 2010-07-07
Hot topics - last 21 days
-
Net Neutrality: what does the Google Verizon proposal mean for GNU Linux?
Gary Richmond, 2010-08-16 -
The Bizarre Cathedral - 78
Ryan Cartwright, 2010-08-16 -
The Bizarre Cathedral - 79
Ryan Cartwright, 2010-08-24 -
Flip: A Simple Camera Done Right
Terry Hancock, 2010-08-31
Free Software Magazine uses Apollo project management and CRM for its everyday activities!





Distros that already come with Hibernate
Submitted by Anonymous visitor on Fri, 2007-01-12 15:21.
Vote!I just wanted to mention that for many users, Hibernate on GNU/Linux can be even easier. (Especially of interest to those who consider switching from Windows or the Mac and might be scared off by lengthy walkthroughs like this.)
gNewSense (www.gnewsense.org) and Ubuntu (www.ubuntu.com) both come with Hibernate already configured. So, for the user it's just a matter of clicking "Shut Down" -> "Hibernate". (I'm sure there are others too, but these are the ones I know.)
Distros that already come with Hibernate
Submitted by Raghu Kodali on Sun, 2007-01-14 16:54.
Vote!Debian Etch (Testing still) also has the hibernate built in. It worked out of the box for me on my Thinkpad (R51)
Distro's that come with Hibernate
Submitted by Anonymous visitor on Tue, 2007-01-16 08:38.
Vote!openSUSE 10.2 has it enabled by default too (I haven't tried it yet though), what I don't understand is this:
swsusp will not work with Symmetric Multi Processing (SMP) enabled in your kernel
But openSUSE has 2.6.18 with SMP as default kernel
Mac Suspend Techniques
Submitted by Anonymous visitor on Wed, 2007-01-17 02:10.
Vote!I hear the mack is always updating changes in ram to the hybernation partition so that when a hybernation action is called for there is less writing necessary. I'd really like to see this functionality brought to Linux.
-Joe Baker
Distros that already come with Hibernate
Submitted by Anonymous visitor on Mon, 2007-01-22 18:42.
Vote!Tried nearly all recent versions of Ubuntu to try out the Hibernate feature..works like crap.
Went back to Windows just bcoz I wanted this feature rather than waiting for Ok, Linux booting now.
thanks
Submitted by Anonymous visitor on Sun, 2007-03-25 18:18.
Vote!thanks
It was raining heavily with
Submitted by UK (not verified) on Thu, 2007-06-14 00:43.
Vote!It was raining heavily with lightning while my lengthy fortran code had been running on my dekstop pc for about a day, I simply hybernated Ubuntu and once the rain stopped I was able to continue from where it's left, This is a very useful feature which really worked and helped me,
I'm wondering what'll happen if I unplug the computer after hybernating, I'll see if writes the current state to the RAM or to the Harddisk. I'm assuming the latter is true.
Wanted to say thank you!
Submitted by original_jamingrit on Thu, 2008-08-07 01:30.
Vote!I know this probably wasn't the most up to date article on Linux hibernation, but it worked perfectly for me.
Followed the swsup method. I'm running SW 12.1 on a Toshiba Satellite MX40 series. Worked like a charm.