Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The matter is that my computer has 3Gb of memory ram. Therefore i think that i don't need too much swap memory size, and i really need free space in the hard disk. sorry by my English

share|improve this question
possible duplicate of How to resize partitions? – Eliah Kagan Aug 24 '14 at 21:42
up vote 9 down vote accepted

Yes. You can change the size of the swap partition, by using GParted. You can install it from the Ubuntu Software Center.

Remember that gparted won't work on a mounted partition. When you are working on the swap partition, you have to unmount it first with swapoff. When you are done, to active the new swap space you do it with swapon.

NOTE: You might want to consider doing this from a live/bootable CD or USB, to be safe. Also keep in mind that anytime you deal with partitions, there is risk involved in doing so.

NOTE: When dealing with partitions, always make sure that a backup is available in case something goes wrong. You may consider Clonezilla

share|improve this answer
It's inadvisable to change the partition table on the system drive from which the OS is running. When the size of a partition changes, that is done by editing the partition table. There are many good applications of GParted on installed Ubuntu systems, but this mistake is why it's not installed by default. To resize partitions, you should boot from an OS not installed on the physical drive where you're doing it. (So you can use an Ubuntu live CD/DVD/USB for this.) I'd recommend editing your answer to account for this. (If you prefer, though, I could post a separate answer.) – Eliah Kagan Jul 14 '12 at 18:36
I changed the partition using this method, but this changed the UUID of the swap partition, and thus the file /etc/fstab was not correct any more and had to be modified. – Étienne Jan 17 at 22:23

I think that your best option is to lower the "swappiness" value, dealing with the partition table of your HDD can be tricky and dangerous.

run this command

gksudo gedit /etc/sysctl.conf

add this line


restart the computer, the kernel will not use the swap, the swap will be mounted but unused.

you can set this between 0 and 100, the meaning of this option is about the percentage of use of the swap space, 0 = never use the swap.

share|improve this answer
This doesn't "free space in the hard disk" (which the question asks for). To do that the swap partition must be shrunk, removed, or reformatted with its own filesystem where data may be stored. Shrinking it is probably the best of those three options. – Eliah Kagan Aug 24 '14 at 21:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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