The swap memory after this process

How to increase swap size in Ubuntu 20.04

I’m my actual job, I have a very powerful laptop. A Dell Inspiron 15 5000. This laptop was delivered to me the laptop with an Ubuntu distro installed, so I only had to setup all the environments.

Last month I had a lot of performance issues and the system was constantly freezing. First only with Slack notifications, but the last weeks, also with compilations of projects, or chrome tab loadings.

What was the reason for these performance problems? Shit! I only had 2GB of swap memory available. For a computer with 16 GB of RAM, the recomendations are the same amount of swap (1,5x or 2x if you want hibernation), so, I decided to increase my swap file size to 32GB. The steps to do it, are the next:

  • We need to disable the swapping.
$ sudo sudo swapoff -a
  • Next, we need to resize the swap file
$ sudo dd if=/dev/zero of=/swapfile bs=4G count=16
  • Now, we have to change the swap file permissions
$ sudo chmod 600 /swapfile
  • And convert it in swap
$ sudo mkswap /swapfile
  • Activate it
$ sudo swapon /swapfile
  • And add to /etc/fstab if not present
/swapfile none swap sw 0 0

And all my problems of perfomance are solved! You can see the available memory with:

$ sudo free -h

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.