Score:0

No Swap partition, but system monitor shows 2GB swap consumption, why?

it flag

Why it is showing the swap usage without an actual swap partition ?

Is it good to create swap partition with ssd storage ?

OS: Ubuntu 20.04

System monitor shows partitions and memory usage:

Partitions

Memory Usage

in flag
Ubuntu generally does not use a dedicated swap partition anymore unless you specifically request one. Instead you will have a swap *file*, usually in the root directory. You can find it defined in your `/etc/fstab` file.
paladin avatar
kr flag
If I were you, I would even increase the swap file size, because it seems your system is hungry for memory. Maybe buy additional RAM modules. Swap file is okay for modern SSD. If you don't use a swap file, Ubuntu will use `/tmp` or `/var/tmp` instead, which is slower and increases filesystem fragmentation. (but filesystem fragmentation is usually not a problem while using a SSD)
C.S.Cameron avatar
cn flag
In Terminal what does `free` show?
heynnema avatar
ru flag
Just curious... my answer addresses your question, and it shows you how to solve your full /swapfile problem. Why isn't it the accepted answer?
it flag
@heynnema I was curious about "why" part of the question. Actually it was answered first in the comment by matigo. And another question is answered in the comment by paladin. The accepted answer also address the same thing, nothing more. Anyway thanks.
heynnema avatar
ru flag
@Rashi Just to clarify... comments by matigo and paladin can't be accepted, but they can be up-voted. There are only two answers that could be accepted, and I believe that my answer is the more complete answer. No big deal. Did you increase your /swapfile size?
it flag
I have up voted those comments, & your answer before. Upgraded RAM and increased the swapfile to 8GB.
Score:1
ru flag

You don't see a swap partition, because you're using a 2G /swapfile, and it's too small.

Note: You really need to add more RAM for your usage pattern.

Until then, we'll increase your /swapfile from 2G to 4G, and that should stop any freezing/crashing that you may have...

Note: Incorrect use of the rm and dd commands can cause data loss. Suggest copy/paste.

In the terminal...

sudo swapoff -a           # turn off swap
sudo rm -i /swapfile      # remove old /swapfile

sudo dd if=/dev/zero of=/swapfile bs=1M count=4096

sudo chmod 600 /swapfile  # set proper file protections
sudo mkswap /swapfile     # init /swapfile
sudo swapon /swapfile     # turn on swap
free -h                   # confirm 8G RAM and 4G swap

Edit /etc/fstab, using sudo -H gedit /etc/fstab or sudo pico /etc/fstab.

Confirm this /swapfile line in /etc/fstab... and confirm no other “swap” lines... use SPACES in this line... confirm NO TABS...

/swapfile  none  swap  sw  0  0

reboot                    # reboot and verify operation
Score:0
cn flag

Ubuntu 18.04+ uses a fixed size swapfile of 2 GB located at /swapfile instead of a partition.

You can easily grow or reduce this swapfile without repartitioning.

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.