[Solved] How to remove swap?

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Lumikki

[Solved] How to remove swap?

Post by Lumikki »

I noticed that my Mint 12 Cinnamon never use swap at all. So, I was thinking to remove it.

If I do this:

swapoff -a
Then comment swap disk off from fstab.

Is that all whats required?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
claudecat

Re: How to remove swap?

Post by claudecat »

You could go a step further and delete your swap partition using gparted. My swap never gets used either, but with disk space so cheap (I have over 4tb), I leave it as it is.
User avatar
sdim
Level 3
Level 3
Posts: 154
Joined: Fri Mar 21, 2008 6:19 pm

Re: How to remove swap?

Post by sdim »

Yeah, but won't he have to adjust some things in fstab, then?
I've read that one needs to do that, so I didn't bother deleting my Swap unused space.
MB:MSI 770 C-45 / HD1:500 GB-->Windows / HD2:320 GB-->Mint 20 Cinnamon
CPU:AMD X4 640 3.00 GHz / RAM:4.0 GB / VGA: NVidia GeForce GT630
Rua
Level 3
Level 3
Posts: 159
Joined: Sat Sep 17, 2011 11:09 am
Location: Netherlands

Re: How to remove swap?

Post by Rua »

But what happens if you run out of memory? Even if it just happens once... you never know.
Lumikki

Re: How to remove swap?

Post by Lumikki »

If computer runs out of memory, then it's crash. I assume.
Okey, I got my swap removed. What wasn't that big job.
mikecrosoft

Re: How to remove swap?

Post by mikecrosoft »

Hello lumikki. I think there is really no problem with letting your system use some swap space, but if you really need to decrease the priority of Virtual Memory vs RAM usage you can simply change the swappiness value; to do that it would be as follows (extracted from https://help.ubuntu.com/community/SwapFaq, and tested so many times in the past and once while writing the comment):

** This would be just in case yu haven't deleted your swap partition or permanently modified anything related, I've read you have already deleted your swap partition so I post this just in case somebody needs a less agressive approach **

1. Open a terminal
2. Type:

Code: Select all

cat /proc/sys/vm/swappiness
3. That will display your swappiness actual value (60)
4. If you are going to be testing your system performance during some time to see if you really need to make this change permanent or if you're going to try with different swappiness values until you find the optimum one, I suggest you to create a launcher in your desktop with the following command:

Code: Select all

gksudo sysctl vm.swappiness=10
5. That will change your swappiness value to 10 when you double click the launcher, to try with different values just replace 10 by any integer number in the range 0-100
6. Once you have find the optimum value and decided to make changes permanent, open a terminal and type:

Code: Select all

sudo gedit /etc/sysctl.conf
7. Search for vm.swappiness and change its value as desired. If vm.swappiness does not exist, add it to the end of the file like so:

Code: Select all

vm.swappiness=10
8. Save the file, reboot and check the change is workig using the command in step 2
Locked

Return to “Beginner Questions”