To Enlarge Swap Space:
sudo swapoff -a
Delete your existing swap file located at root
Create the new swap file:
sudo fallocate -l XG /swapfile
Where X is the swapfile size in GB (4GB in your case)
sudo mkswap /swapfile
sudo chmod 0600 /swapfile
sudo swapon /swapfile
To enable Hibernation (optional):
- Edit /etc/default/grub to add resume location and offset to grub.cfg:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX resume_offset=XXXXX"
cscameron@cscameron-T:~$ filefrag -v /swapfile Filesystem type is: ef53 File size of /swapfile is 4819255296 (1176576 blocks of 4096 bytes) ext: logical_offset: physical_offset: length: expected: flags: 0: 0.. 0: 303104.. 303104: 1: 1: 1.. 2047: 303105.. 305151: 2047: unwritten 2: 2048.. 4095: 311296.. 313343: 2048: 305152: unwritten
A hibernate button can be added using gnome extensions.
Proof of concept that hibernation works with a swapfile
Showing swapfile, resume and UUID's
Showing hibernation popup
Showing resume from UUID is root partition and not from swap partition
free
to check that swap is not all used up.