How to add Swap memory on Ubuntu

Bogdan Alexandru Militaru
2 min readFeb 18, 2021

Create a file and preallocate size. In the following example we allocate 4GB

$ sudo fallocate -l 4G /swapfile

The prompt will return:

$ ls -lh /swapfile
-rw-r--r-- 1 root root 4.0G Feb 8 08:50 /swapfile

Enable SWAP file

--

--