Home > Articles > Open Source > Linux/UNIX/Open Source Operating Systems

  • Print
  • + Share This
Like this article? We recommend Hibernate Swap File Setup

Hibernate Swap File Setup

Some netbooks use a fast internal small drive for the operating system. Some single-drive netbooks run an alternative OS on a USB thumb drive or SD card in the internal flash card slot. If you're running a separate drive for the operating system, put the hibernate file on your main drive, which should have room for a hibernate file that's 1–2GB in size.

Step 1: Creating the Swap File

The decision you need to make here is size, but remember that you can revisit the size issue later on by creating another swap file.

If you haven't upgraded your netbook DRAM, you probably have 1GB of DRAM, meaning that if you do as I ordinarily recommend, you need 500MB of swap file space. I set my own swap file for 1GB, to avoid having to redo this step in the future, after a DRAM upgrade.

If you change this setting in the future, I recommend removing uswsusp completely:

$ sudo aptitude purge uswsusp

Then reinstall it:

$ sudo aptitude install uswsusp

The reason is so that you won't need to create a new initrd and a resume-offset (see the next section) manually.

No other changes should be required as long as you change neither the filename of the .swp file nor the drive/partition where it lives. However, you might want to do this again even if you don't make any changes, so that you can move the part of the drive where the data is written every time you run hibernation.

Run the following commands from your terminal command-line interface. If you're doing this with an Eee PC 900 or similar configuration, with a 2GB swap as the example, here's the syntax:

path-to = /media/USER/user/
  • 2GB swap:
  • sudo dd if=/dev/zero = /media/USER/user/hibernate.swp bs=1M count=2000
  • 1GB swap:
  • sudo dd if=/dev/zero of=/path-to/hibernate.swp bs=1M count=1000
  • 512MB swap:
  • sudo dd if=/dev/zero of=/path-to/hibernate.swp bs=1M count=500

Next, set swap on:

$ sudo swapon /path-to/hibernate.swp

Step 2: Configuring

Is swap working? Run this command to check:

$ free -m

You should see a Mem: line and a Swap line immediately below it. If this worked, begin configuring.

Configure the 00sleep_module as shown here:

$ sudo nano /etc/pm/config.d/00sleep_module

# The system defaults to "kernel" if this is commented out.
# SLEEP_MODULE="kernel"
SLEEP_MODULE="uswsusp"

Save and exit.

Next, install uswsusp:

$ sudo aptitude install uswsusp

The installation will spend a few minutes generating an initrd.img-[kernel name] file.

If your uswsusp doesn't automatically open a configuration wizard within the ASCII terminal, open the wizard yourself after the automated installation ends, as described in part 2 of this series, and continue this installation.

  • + Share This
  • 🔖 Save To Your Account