2

I've dual-booted my laptop with Windows 10 and Ubuntu 18.04. While installing Ubuntu, I created a swap space of 15GB. My laptop has 8GB RAM. I hadn't noticed earlier, but now that my system is running out of memory, I noticed that System Monitor shows only 1.1GB swap. Turning off swap and turning it on doesn't help either. What is happening here? How can I fix it?

gparted snapshot

system monitor snapshot

PS: I don't know if it matters. Initially I had tried to disable swap altogether. I followed this answer and set swappiness to 10. Now I've changed it back to the default value 60.

Edit1:
Adding content of /etc/fstab

$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/nvme0n1p7 during installation
UUID=3f9f3cd3-acfb-47a8-aff2-fac6a7405e02 /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=B827-57AB  /boot/efi       vfat    umask=0077      0       1
/swapfile                                 none            swap    sw              0       0
# (identifier)  (location, eg sda5)   (format, eg ext3 or ext4)      (some settings) 
UUID=3a70fe9d-3ffc-4e4e-b7b1-d94f2dbe0bbd   /home    ext4          defaults       0       2 
  • I understand that the current trend is to only use 8GB swap if your computer has GB RAM. What does the command free show? Or swapon -s? – C.S.Cameron Aug 09 '20 at 02:53
  • 1
    Please edit your question to include the line(s) of /etc/fstab that include swap. – user535733 Aug 09 '20 at 02:53
  • 2
    In the terminal, run sudo cat /proc/swaps and you'll probably discover you're using swapfile and not a swap partition. It'll look like /swapfile when you run the command. If that's the case, you can use a search engine to find out how to change it. – KGIII Aug 09 '20 at 02:55
  • Perfect. It worked. Thanks. If you can write it as an answer, I'll accept it. – Nagabhushan S N Aug 09 '20 at 03:05

1 Answers1

1

Following KGIII's comment, I fixed it as follows

Check if /swapfile is being used instead of swap partition

$ sudo cat /proc/swaps
Filename                Type        Size    Used    Priority
/swapfile                               file        1158220 0   -2

Now, to change swap from using /swapfile to partition, I followed this blog. Although it does the reverse, the required commands are available.

Turn off /swapfile

$ sudo swapoff /swapfile

Edit /etc/fstab file to use swap partition instead of /swapfile. Commented existing line and added new line. UUID can be obtained from gparted (right click on swap partition and select information)

UUID=530e52cc-8a1d-400b-bbde-b47c0246586d none            swap    sw              0       0
# /swapfile                               none            swap    sw              0       0

Format the swap partition

$ sudo mkswap /dev/nvme0n1p8

Set swap to use the partition

$ sudo swapon /dev/nvme0n1p8