How to remove my swap partition

9 Antworten [Letzter Beitrag]
quantumgravity
Offline
Beigetreten: 04/22/2013

I have a Notebook with 4G ram and I heard very often that the swap partition is pretty useless. If you don't agree with this (I haven't any reference and maybe I heard false claims) then please explain why.
Anyway, the actual reason for thinking about it is my plan to create an encrypted partition where all my sensible data will be stored.

I *don't* want to install everything new and encrypt the whole disk. For a big part of my data I consider it the lesser evil knowing these files in the wrong hands instead of don't having access to them ever again.

But I know that an encrypted partition is no good if my swap is still in use. How can I remove it?
Just removing the partition will certainly cause a lot of trouble in the system.
Is deleting the correct line from fstab erasing the partition enough?

ZykoticK9
Offline
Beigetreten: 04/07/2011

if you use hibernate, you need swap (equal to RAM)... if not, go ahead - i still don't think it's a good idea. Just remove/comment the entry in fstab, then you might want to restart, to verify everything is working and that "free" shows no swap.

G4JC
Offline
Beigetreten: 03/11/2012

Not sure the take away of having no swap, but I found this option on a DDG search: https://www.antagonism.org/privacy/encrypted-swap-linux.shtml

BugRep
Offline
Beigetreten: 04/05/2012

You can use swapoff (possibly with argument -a) command to stop using swap temporarily. If you remove the swap line from fstab and restart your machine, I believe you can safely remove the partition.

Your system might respond faster after removing the swap partition (this comes from personal experience).

TralfamadorianOrator
Offline
Beigetreten: 11/12/2011

Other than for hibernation, swap space is kicked in when your RAM gets used up.

You'll be fine as long as you don't do anything that causes your 4 GB of RAM to fill up, like graphics or video editing or genomic sequence analysis.

You can use the 'top' command to check whether your swap space is being used.

BugRep
Offline
Beigetreten: 04/05/2012

Swap can be used by the system even if the RAM is not completely used up. This can be disabled by changing swappiness to 0.

https://en.wikipedia.org/wiki/Swappiness

quantumgravity
Offline
Beigetreten: 04/22/2013

Thanks to everyone for your comments!
For starters, I will test my system with swapiness = 0 and the top command so I can see if the partition is actually needed. On top of that, I will use swapoff -a from time to time and observe how the system is working with this option.

Concerning hibernation I don't understand why a swap partition is mandatory for this.
I mean it's suspend-to-ram, so a sufficiently big ram should be just fine?
Are you sure it will not work anymore without swap?

BugRep
Offline
Beigetreten: 04/05/2012

Hibernation is not suspend-to-ram. The contents of RAM is written to a swap partition when hibernating.

RAM needs power, or it looses data.
When a computer is hibernating it is possible to disconnect power (or remove battery) or even boot another operating system (which must not use the swap where the data is).

quantumgravity
Offline
Beigetreten: 04/22/2013

Ok, then I confused the terms.
I only need suspend-to-ram, not suspend-to-disk or something similar.

Magic Banana

I am a member!

I am a translator!

Offline
Beigetreten: 07/24/2010

The original idea behind the swap is to get a degradation of the performances (disks are hundreds if not thousands of times slower than RAM) when the RAM become full instead of directly having the kernel (more or less arbitrarily) choose a process to kill. That lets time to find a guilty or non-essential process by yourself and terminate it (less abruptly than with a 'kill -9'!).

If the memory occupation never ever reaches the available quantity of RAM, the swap is useless (although today, it is used as well for hibernation, as mentioned by other users). But would you take the risk just to save a few GB of disk space? If you run servers, you should probably not (that may be the process the kernel decides to kill).