How to manually suspend Linux

For years I have been dual-booting Linux and Windows on my laptop. When I need to switch to Windows I usually cringe. Partly because using Windows feels like being trapped in the trunk of a car. More importantly I have to close all my Linux programs, terminals and start over when I reboot. large

I make full use of the multiple workspaces offered on most Linux distributions. Currently I'm running Lubuntu 15.10. It's the lightweight LXDE version of Ubuntu. I like to have my email client in one workspace, web browser in anouther, code editors in one and terminals in anouther. It's all organized and I know where everything is, kinda like my garage.

To switch OSes I have to reboot and pick the other from the GRUB boot menu. Windows is able to hibernate which saves an image to the hard drive and revives the same state when you boot. Linux does not have this enabled by default. You can suspend which does the same thing but stores your image in your RAM. If your system loses power the image is gone.
large

Hibernate can be enabled in most Linux distros but has the side effect of loading as soon as you hit the power button. That does not give the opportunity to access the GRUB menu. So you can't boot into Windows.

After years of begrudgingly switching to Windows and losing my nicely organized desktops I found the solution. It's a simple little command line tool called s2disk.

large

s2disk takes care of hibernation and resume. The hibernate function does the following tasks.

The resume program does basically the same, in reverse order:

To install s2disk on Ubuntu you have to install uswsusp. It's as simple as:

sudo apt-get install uswsusp

uswsusp which stands for (userspace software suspend) contains a whole suite of programs that deal with hibernation and suspend. It has s2ram which suspends to ram, that works like a sleep function. If your system loses power the snapshot is gone. s2disk which suspends to disk by utilizing the swapfile. And s2both which is a combination of the two.

To use s2disk you run this simple command in your terminal:

sudo s2disk

That's it. You'll get some feedback on screen as it works through the stages of snapshotting the system. And a progress bar. Once it's done it will shut off your machine.

When you boot into Ubuntu the resume program will run and put you in the same state as you left.

Comments? Drop me an email