I did a clean install of Ubuntu 18.04 Desktop.
I used the graphical installer and chose "Encrypt the new Ubuntu installation for security".
It used by default LVM and created a partition for the swap instead of the file. Here is sudo swapon -s
result:
eviatan89@leviatan89-K55VD:~$ sudo swapon -s
Filename Type Size Used Priority
/dev/dm-2 partition 1003516 999448 -2
I need to increase the size as I am having lots of problems running low on RAM.
As curiosity, problems come when using Cassandra and Firefox with several open tabs (including YouTube). My system got 6GB of RAM.
Thanks a lot for your help!
Best Answer
The easiest solution would be to add a swap file. If you are already encrypting your root file system, I would not bother with an encrypted swap file, which is only a little more difficult, but it is slower. The advantage of a swap file is that you can remove it later to regain the disk space. And the disk is already encrypted!
The steps are straightforward. First, make the file. For example, this would make 1GB of new swap:
The
of=/swapfile
tellsdd
to put the new swap file in/swapfile
. You can call it anything you want. You can add multiple swap files, too. For recent Linux kernels, the speed is the same as a swap partition.Then, you need to format the swap file as swap space, like so:
This command will give you some output like:
And that's your new swap file. Finally, you need to activate the swap on your machine using the following command:
Now,
sudo swapon -s
should show you both the swap partition and the swap file.I then recommend adding some security by changing permissions as follows:
If all seems good so far, you can add the swap file permanently by adding the the following line to
/etc/fstab
using your favorite editor:You can add multiple swap files, of course. And you can remove the swap file by using
sudo swapoff /swapfile
.Hope this helps.