10

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

1

2 Answers 2

11

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

2
  • 6
    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.) Jul 14, 2012 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, 2016 at 22:23
1

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

vm.swappiness=0

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.

1
  • 3
    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. Aug 24, 2014 at 21:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .