Ubuntu – How to add more swap easily so that I can hibernate the laptop?


I installed Natty on my laptop with default options. I guess it created a swap partition equal to the size of my RAM. Every time I try to hibernate I get the "not enough swap" message, which is annoying. I want to hibernate! Why can't you just use some of my 20GB free HD space to hibernate? I only have 1GB RAM on this old geezer.

I've seen the swap faq @ http://help.ubuntu.com/community/SwapFaq but it's painfully dense. It shows me how to create a swap file and turn that on, but doesn't explain the following:

  1. Will the system hibernate to that swap file, or will it still be confused because the swap partition is there and too small?
  2. Do I need to get rid of the swap partition? I don't desperately need the space, but I would like to reclaim it because this computer has a pretty small HD.
  3. Why is this all so difficult?


Best Answer

The best way IMHO is just to increase the size of the swap partition.

Boot your computer with a Ubuntu Live CD/USB.

The live CD will detect and use your swap, you should disable it to be able to manipulate it. Open a terminal and type the following command:

sudo swapoff -a

Afterwards, open Gparted, an resize your partition. You will need to shrink some partition that is close to it. It should be quite straightforward.

You will need to boot from some external method, because you can't resize partitions that are in use, and it's quite likely that you will need to shrink your main partition.

Now the other questions:

  1. Yes.

  2. If you use a swap file then yes, you can get rid of your swap partition. But I believe that using a swap partition is easier. It's also the standard practice in linux, most of the tutorials that you can find on the net will expect it.

  3. Messing with swap is something that no newbie should do in any OS. No need to make it easy.