How do I create a swap partition for hibernation?

While installing Ubuntu 11.10 a months ago I had not allotted any swap space, I now came to know that there would be no Hibernate option without Swap space.

Is it possible to do it Now?, What if the drives mess up? I have 4 gigabytes of ram, a 500 GB disk and I'm dual-booting with Windows 7.


Make a backup of all your important data before attempting this.

You need to boot from your installation media and use the Gparted application to shrink the filesystem, it is generally recommended to have a swap partition double the size of your RAM. Once you have shrunk the filesystem you should right-click on the now "unallocated space" and format it as swap. Once done, hit the "Apply all operations" button and reboot.

Now you should be back in your main Ubuntu system.

You need to run the gksudo gedit /etc/fstab command and add a line like this:

/dev/sdXY swap swap defaults 0 0

Of course, change the XY to the correct settings for the system.

Finally, reboot or run sudo swapon /dev/sdXY to use the swap without rebooting.


You can use gparted to resize your partitions and make some space to a new swap partition. Although this works pretty good according to my own experience, before doing it, you should make a backup of all your files just in case.