This question already has an answer here:

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?


marked as duplicate by Cas, karel, Kevin Bowen, MadMike, Elder Geek Mar 20 '17 at 12:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


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.

  • RE: #3 well, I wouldn't have any good reason to if my machine would hibernate... – swrobel Jun 16 '11 at 17:25
  • I kept coming across mentions of having to mess with UUIDs or something when the swap partition changes. Is that not the case? – swrobel Jun 16 '11 at 17:26
  • The UUID shouldn't change if you resize the partition. But it will change if you delete and create it again. – Javier Rivera Jun 16 '11 at 18:08
  • Ubuntu is supposed to create swap partition big enough to hibernate while installing unless you choose to manually select partitions. – Javier Rivera Jun 16 '11 at 18:09
  • Well, although Ubuntu is supposed to make it big enough it doesn't. Here's what I've tried so far: first I tried resizing the swap partition but neither the Ubuntu install disk or a GParted LiveCD would grow the size of the extended partition that swap was on. So I deleted the swap partition, grew my primary partition, and moved swap to a file using the wiki I referenced. However then I started getting an error about the swap header when I tried to hibernate. So I did part 2 here: ubuntuforums.org/showthread.php?t=1042946 and now hibernate works, but it boots fresh instead of resuming – swrobel Jun 16 '11 at 21:47

I finally solved this. Of course, to answer the "Why is this all so difficult?" part of my question, I would just have to respond "This is Linux, you fool, of course everything is difficult!"

Here are the steps:

  1. Boot to Ubuntu install CD (I'm on Natty) and choose the option to run Ubuntu now
  2. Go to system -> GParted Partition Editor
  3. Delete the swap partition and the extended partition that holds it (if by some miracle you're able to resize your swap partition from here, I imagine your life will be a lot easier than mine)
  4. Decrease the size of your primary partition by the amount you want your new swap to be (I made mine 2x RAM + 500MB just to be safe). The easiest way to do this is to fill in the amount of space you want swap to be in the "free space following" field
  5. In the free space that has now been created, choose new, type linux-swap and you can name the partition "swap" if you like
  6. Hit the Apply button (should be a check mark) to write the changes to disk
  7. When done, reboot back into Ubuntu

Now you need to find what partition your swap is on and what its UUID is. UUID?! you say? Well that's the Universally Unique IDentifier for the partition so you can reference it even if it's on a different mount point from boot-to-boot due to adding disks, etc. If this is your primary disk, it's probably not a big deal.

  1. Pull up a terminal and run gksu gparted & and enter your root password. The & lets this process run while still giving you access to the command line.
  2. Right-click on your swap partition and choose Information. You should see the Path and UUID listed there. Keep this open for further reference.
  3. Run gksu gedit /etc/fstab & and look for the line that has swap in it. It should be the third column, separated by spaces or tabs. You can either use the path or the UUID to tell Linux where to find your swap partition. I recommend UUID because it'll stay constant even if you move the partition around or the disk somehow becomes sdb instead of sda or something like that. Make the appropriate edits and save the file. Your line should look something like this if you used UUID (with your UUID instead, of course):
    • UUID=41e86209-3802-424b-9a9d-d7683142dab7 none swap sw 0 0
    • or this if you used path: /dev/sda2 none swap sw 0 0
  4. Save and reboot to make sure the new swap gets activated properly at startup

Grab a glass of milk and wait for Ubuntu to come back up... The fun part comes next

  1. Pull up a Terminal again and run cat /proc/swaps and hopefully you see the path to your swap partition listed there. If not chances are something went wrong in the steps above. Here's my output:

    Filename                Type        Size    Used    Priority
    /dev/sda2               partition   2676732 6360    -1
  2. gksu gedit /etc/default/grub & to pull up the boot loader configuration

  3. Look for the line GRUB_CMDLINE_LINUX="" and make sure it looks like this (using your UUID of course) GRUB_CMDLINE_LINUX="resume=UUID=41e86209-3802-424b-9a9d-d7683142dab7" and save the file
  4. sudo update-grub and wait for it to finish
  5. gksu gedit /etc/initramfs-tools/conf.d/resume & and make sure its contents are resume=UUID=41e86209-3802-424b-9a9d-d7683142dab7 (with your UUID of course in place of mine). Save the file!
  6. sudo update-initramfs -u
  7. Reboot!

Now you should be able to hibernate and resume! I really hope this helps someone else. I can't believe Ubuntu is on version 11 and it still SUCKS THIS HARD to get it to hibernate your laptop. Don't lose faith though, it can be done!

  • In your first lot of seven steps.... delete number 2 i.e. do 3 first. Now select the swap partition, select swap off, grow partition, select swap on and reboot That's it that is all that's needed. – robin0800 Jun 17 '11 at 8:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.