I have issue regarding my swap size.
When I issue htop
I get this output showing that I only have 2 GB of swap space:
Also when I check system monitor:
But, If I check the swap partition using Gparted
, it is showing that I have 21 GB of swap space:
Also the output of swapon -s
is:
Filename Type Size Used Priority
/swapfile file 2097148 0 -2
Why Ubuntu isn't using all available swap space and just using 2GB?
The problem is that you haven't properly set up your /etc/fstab.
There are two kinds of swap available to you. A /swapfile, or a partition-based swap area. You have to decide on one or the other.
Note: A 22G swap partition is excessive (unless you're planning on hibernating).
Your /etc/fstab currently has something like:
You should either increase your 2G /swapfile to 4G, or switch your swap line to use your /dev/sda7 swap partition, with something like:
Note: changing the UUID to what's found in the
sudo blkid
command.To increase your current /swapfile to 4G, do the following:
Note: Incorrect use of the
dd
command can cause data loss. Suggest copy/paste.In the
terminal
...Confirm this /swapfile line at the end of /etc/fstab... and confirm no other “swap” lines...
To edit, use
sudo -H gedit /etc/fstab
orsudo pico /etc/fstab
Note: Then you can remove your 22G swap partition /dev/sda7.
swapon -s
indicates the swap space that is currently in use. The output of your command indicates that a swapfile,/swapfile
, is in use. Your swap partition is not used. For it to be used, it would need to be included into/etc/fstab
. Currently, you will see an entry for/swapfile
. You would need to add another entry for the swap partition.