Score:1

Should the Swap be this large?

mx flag

My computer is a bit old and sometimes it struggles to handle many tabs running small processes etc. I guess this has to do with the ram.

When I check the usage, this is what I get:

free -lhm
              total        used        free      shared  buff/cache   available
Mem:          3.6Gi       2.4Gi       585Mi        24Mi       651Mi       957Mi
Low:          3.6Gi       3.1Gi       585Mi
High:            0B          0B          0B
Swap:         2.0Gi       539Mi       1.5Gi

I wonder if the Swap should be this large, and if not, how could I resize it safely.

Details

Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:    20.04
Codename:   focal
Arch: x64
Swap: file (not partition)
guiverc avatar
cn flag
You've not provided OS & release details; also not mentioned if your swap is *swapfile* or swap partition. Swapfiles are easy to change sizes on; swap partitions not so easy... You can use both, but not the ideal situation. I'd for sure use more swap (but again I don't know your OS & release; not what you consider an *old* pc; I'm using a 2009 dell for example)
FedKad avatar
cn flag
Is the output you provided obtained during typical usage or during the system being less responsive than "normal"? Are you using 32-bit or 64-bit version of OS? Please, [edit] your question and add `uname -a` output together with `cat /etc/os-release`.
karel avatar
sa flag
In new installationsof u
Minsky avatar
mx flag
@guiverc thanks. added. I believe this output means it is not a partition? `sda 8:0 0 931.5G 0 disk ├─sda1 8:1 0 512M 0 part /boot/efi └─sda2 8:2 0 931G 0 part /`. It is a Lenovo Ideapad from 2016, but with browsers + tabs it sometimes struggles unless I use Lynx
Score:1
sa flag

In new installations of Ubuntu 20.04 a 1.5GB swap file (not a swap partition) is created by default in the /partition. A swap file is also created by default in new installations of Ubuntu 17.04 and later. The swap file is resized automatically when more swap space is needed, but it is always at least 1.5GB.

If you are using an operating system that was upgraded from an OS that was installed before 17.04 then your OS probably has a separate swap partition. In general it is recommended that the swap partition be 1.5-2 times the amount of RAM if your computer has 4GB of RAM or less. It is not necessary to have a swap partition that is larger than 8GB in most cases.

Lightweight flavors of Ubuntu require less RAM and therefore they also require less swap space.

enter image description here
RAM Usage of different flavors of 18.04 under baseline conditions  (Click image to enlarge)

Minsky avatar
mx flag
This is very useful, as I added in a comment, it is a swap file. Would you comment why would you want a swap about 2 times larger than RAM?
karel avatar
sa flag
I would want my swap space to be about 2 times the size of my RAM if I was frequently suspending Ubuntu which I never do. Instead I always save my tabs in Chrome before I logout or shutdown, Usually I don't want to save my tabs. If I don't want to save my tabs I use Firefox instead of Chrome. My workstation has 32 GB of RAM, and my swap file in Ubuntu 20.04 is only 1.5GB, which is the default minimum size.
Minsky avatar
mx flag
I see. So the swap keeps a copy of whatever was in memory
karel avatar
sa flag
According to Wikipedia *Unix systems, and other Unix-like operating systems, use the term "swap" to describe the act of substituting disk space for RAM when physical RAM is full.*
heynnema avatar
ru flag
@karel More correctly... the activity related to swapping is the movement of unused, or not recently used, "pages" of memory in/out to a /swapfile or swap partition, to make room in memory for currently active apps. Swapping usually happens in low memory situations. This user, with only 4G RAM, probably needs a larger /swapfile.
heynnema avatar
ru flag
@karel In my previous comment, change *"to make room in memory for currently active apps"* to *"to make room in memory for currently active processes"*.
Minsky avatar
mx flag
@heynnema thanks for that description, really useful to understand why should I do it -or not.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.