I'm using Cinnamon 20.2. The default swapfile is 2 GB.
Question: If my computer runs into a situation whereby it needs more than 2 GB, will the operating system automatically increase the 2 GB to say 3 GB -- or do I need to manually do it? If manually, how would I best do that?
Many thanks!
[SOLVED] Swapfile 2 GB default size - Will it auto-increase if need be?
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.
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.
- Venus Flytrap
- Level 2
- Posts: 92
- Joined: Thu Sep 30, 2021 6:32 am
- Location: Canada
[SOLVED] Swapfile 2 GB default size - Will it auto-increase if need be?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 3 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
System: Mint Cinnamon 21.1. CPU: Intel E7600. RAM: 4GB. Video: ATI HD 4830. SSD: Kingston KC600 512GB (boot-drive) & Kingston A400, 480GB (backup). Display: ASUS VA24DQ 23.8"
Re: Swapfile 2 GB default size - Will it auto-increase if need be?
First of all please note that you should on a 2G system not expect to need more than 2G swap, 1G I'd in fact say, in the sense that if you do the system is unmanageably slow already anyway; that you're loading it up too much.
But as a direct answer, no, it would not grow automatically; enlarging a swapfile is easy though.
But as a direct answer, no, it would not grow automatically; enlarging a swapfile is easy though.
Code: Select all
$ sudo swapoff /swapfile # stop swapping to /swapfile
$ sudo dd if=/dev/zero of=/swapfile bs=1M count=3K # create /swapfile anew and of size bs*count (here, 3G)
$ sudo mkswap /swapfile # "format" /swapfile as a swap file
$ sudo swapon /swapfile # make /swapfile available again for swapping
- Michael_Hathaway
- Level 4
- Posts: 329
- Joined: Sat Oct 09, 2021 2:27 am
- Location: Shebang, USA
- Contact:
Re: Swapfile 2 GB default size - Will it auto-increase if need be?
A swap file allows Linux to simulate the disk space as RAM. When your system starts running out of RAM, it uses the swap space to and swaps some content of the RAM on to the disk space. This frees up the RAM to serve more important processes. When the RAM is free again, it swaps back the data from the disk.
RAM is 1000 times faster than SSD and 100,000 times faster than the usual HDD. If an application relies too much on the swap, its performance will degrade as it cannot access the data at the same speed as it would have in RAM. I would increase your ram instead of trying to increase your swap file size.
You can also adjust your swappiness file. Swappiness is a Linux kernel property that defines how often the system will use the swap space. Swappiness can have a value between 0 and 100 (default is 60). A low value will force the kernel to avoid swapping whenever possible for applications, while a higher value will force the kernel to use the swap space more aggressively. It isn't a on/off switch, but more like a ratio fader. The opposite is true for sever file processing. On a desktop computer, a lower swappiness value will speed up how fast applications function. On a file server, a higher swappiness value will speed up file services.
Current value listed, default is 60:
To change this value:
scroll to the bottom of sysctl.conf and start a new line, enter a value 10-60:
The optimal swappiness value depends on your system workload and how the memory is being used. You should adjust this parameter in small increments to find an optimal value. You can monitor your memory use in htop.
RAM is 1000 times faster than SSD and 100,000 times faster than the usual HDD. If an application relies too much on the swap, its performance will degrade as it cannot access the data at the same speed as it would have in RAM. I would increase your ram instead of trying to increase your swap file size.
You can also adjust your swappiness file. Swappiness is a Linux kernel property that defines how often the system will use the swap space. Swappiness can have a value between 0 and 100 (default is 60). A low value will force the kernel to avoid swapping whenever possible for applications, while a higher value will force the kernel to use the swap space more aggressively. It isn't a on/off switch, but more like a ratio fader. The opposite is true for sever file processing. On a desktop computer, a lower swappiness value will speed up how fast applications function. On a file server, a higher swappiness value will speed up file services.
Current value listed, default is 60:
Code: Select all
$ cat /proc/sys/vm/swappiness
Code: Select all
$ sudo xed /etc/sysctl.conf
Code: Select all
vm.swappiness=60
Re: Swapfile 2 GB default size - Will it auto-increase if need be?
When I installed mint on a Lenovo Yoga (4 GB soldered-on, non-upgradable) from 2015, the default swap file was 2GB. With some memory intensive browser tabs in Firefox, everything ran smooth & nice until boom! out of memory and machine frozen for 5 minutes or until a tab (or cinnamon?) crashed, freeing up some memory.
Got a little better when adjusting swappiness to 20. Increasing swap to 4GB helped avoiding lots of the freezes and I can have more tabs open.
Now, I think swappiness is set at 30 IIRC, and I run a not-recommended setup with 6GB swap. Firefox is able to gobble it all up anyway. It might not be ideal for performance, but I prefer the computer getting gradually slower instead of just suddenly being unresponsive for 5 minutes or more.
My next mint laptop will have 16 GB
Got a little better when adjusting swappiness to 20. Increasing swap to 4GB helped avoiding lots of the freezes and I can have more tabs open.
Now, I think swappiness is set at 30 IIRC, and I run a not-recommended setup with 6GB swap. Firefox is able to gobble it all up anyway. It might not be ideal for performance, but I prefer the computer getting gradually slower instead of just suddenly being unresponsive for 5 minutes or more.
My next mint laptop will have 16 GB
- ricardogroetaers
- Level 6
- Posts: 1368
- Joined: Sat Oct 27, 2018 3:06 am
- Location: Rio de Janeiro, Brasil
Re: Swapfile 2 GB default size - Will it auto-increase if need be?
In Windows, the swap file, with its system-managed
size, tends to grow too large.
This is usually "corrected" by setting a fixed size for the swap file.
I don't know to what extent a hypothetical swap file managed by the Mint system would work better.
size, tends to grow too large.
This is usually "corrected" by setting a fixed size for the swap file.
I don't know to what extent a hypothetical swap file managed by the Mint system would work better.
- Venus Flytrap
- Level 2
- Posts: 92
- Joined: Thu Sep 30, 2021 6:32 am
- Location: Canada
Re: Swapfile 2 GB default size - Will it auto-increase if need be?
Great answers and comments, thanks everyone!
I come from a background of primarily using Windows -- and it automatically adjusted swap file size for me. That worked ok for the most part.
Now that I'm new to Mint, I wasn't sure how it handled it. Now I know, thanks!
Like many here, I've benefited from the "Easy Linux Tips Project" website tweaks. For my old computer (specs in signature below) I've set swappiness to 20, zswap.max_pool_percent=40, turned off special effects in Cinnamon and performed the browser cache mod to Firefox. It all seems to work relatively quite well.
I've only once seen my swapfile fill up to the max 2 GB, and that was when I had a memory leak from a bad program. In that case, the fixed 2GB swapfile saved me from a hidden error, as it brought to my attention, through sluggishness, that something was wrong with memory management. (I ran HTOP, and found swapfile was full as was RAM despite the program being very small) I exited that flawed program and then all went back to normal.
This old computer is my web-surfing computer. It's too much of an antique to run any new version of Windows -- hence why I recently put Linux Mint on it. And, I must say, Mint has been fantastic for this computer! It literally saved it from going to the recyclers.
I do have modern high-spec computers, but they are laptops running Windows. But for home use, this old desktop PC perfectly fills the need.
Three cheers to Linux Mint!
I come from a background of primarily using Windows -- and it automatically adjusted swap file size for me. That worked ok for the most part.
Now that I'm new to Mint, I wasn't sure how it handled it. Now I know, thanks!
Like many here, I've benefited from the "Easy Linux Tips Project" website tweaks. For my old computer (specs in signature below) I've set swappiness to 20, zswap.max_pool_percent=40, turned off special effects in Cinnamon and performed the browser cache mod to Firefox. It all seems to work relatively quite well.
I've only once seen my swapfile fill up to the max 2 GB, and that was when I had a memory leak from a bad program. In that case, the fixed 2GB swapfile saved me from a hidden error, as it brought to my attention, through sluggishness, that something was wrong with memory management. (I ran HTOP, and found swapfile was full as was RAM despite the program being very small) I exited that flawed program and then all went back to normal.
This old computer is my web-surfing computer. It's too much of an antique to run any new version of Windows -- hence why I recently put Linux Mint on it. And, I must say, Mint has been fantastic for this computer! It literally saved it from going to the recyclers.
I do have modern high-spec computers, but they are laptops running Windows. But for home use, this old desktop PC perfectly fills the need.
Three cheers to Linux Mint!
System: Mint Cinnamon 21.1. CPU: Intel E7600. RAM: 4GB. Video: ATI HD 4830. SSD: Kingston KC600 512GB (boot-drive) & Kingston A400, 480GB (backup). Display: ASUS VA24DQ 23.8"