How to remove my swap partition
- Inicie sesión ou rexístrese para enviar comentarios
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?
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.
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
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).
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.
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.
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?
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).
Ok, then I confused the terms.
I only need suspend-to-ram, not suspend-to-disk or something similar.
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).
- Inicie sesión ou rexístrese para enviar comentarios