I have a virtual machine (hosted online) with 2Gb swap space.
total used free shared buffers cached Mem: 1995 438 1557 37 22 190 -/+ buffers/cache: 225 1770 Swap: 1998 0 1998
Since the swap space was small, I tried to increase it to 4GB.
Doing swapon -s, returned this result (not sure what it means since I don't have a second hard disk sda2)
Filename Type Size Used Priority /dev/sda2 partition 2046972 0 -1
Filesystem Size Used Avail Use% Mounted on /dev/sda1 25G 19G 4.3G 82% / udev 1.1G 4.1k 1.1G 1% /dev tmpfs 210M 492k 209M 1% /run none 4.1k 0 4.1k 0% /sys/fs/cgroup none 5.3M 0 5.3M 0% /run/lock none 1.1G 0 1.1G 0% /run/shm none 105M 0 105M 0% /run/user
So I did
swapoff -a #deactivating previous swap space fallocate -l 4G /swapfile #creating a swapfile chmod 600 /swapfile #giving permissions mkswap /swapfile #making swap the file swapon /swapfile #activating swap on the file echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab #stabilizying swap for it to be there after next reboot
Now I have the swap space I needed
total used free shared buffers cached Mem: 1995 1153 842 64 116 455 -/+ buffers/cache: 581 1414 Swap: 4095 0 4095
But, the 2GB of the previous swap space are still considered occupied if I do a df (maybe they will be free at the next reboot?) and my fstab has two entries for swap space.
# <file system> <mount point> <type> <options> <dump> <pass> /dev/sda1 / ext4 errors=remount-ro,relatime 0 1 /dev/sda2 swap swap defaults 0 0 proc /proc proc defaults 0 0 sysfs /sys sysfs defaults 0 0 devtmpfs /dev devtmpfs rw 0 0 /swapfile none swap sw 0 0
In this situation, how I may proceed to finalize the procedure? I have to remove the second line referring to swap in the fstab? (I mean /dev/sda2 swap swap defaults 0 0) It is safe to reboot?