Skip to main content

Rough Notes on Swap File/Partition in Linux

Am using my rickety old laptop as my daily driver these days, because … reasons.
And now, that I run PyCharm alongside Emacs, alongside Chrome in its various incarnations, the poor old thing crashes, freezes and stutters a lot.
A cursory inspection told me that while I had plenty of CPU firepower, I was constantly running out of ram (8gb) and swap (1 gb partition).

Too broke to add more ram to the system right now (don’t even know if this thing will support 8 gb modules to push it up to 16).
So the only way to go, was to somehow increase the swap on my system.
This is the checklist for curious / researching Jason in the future.

  1. Make sure system is backed up
  2. Check if there is a swap file or partition
  3. If there’s a file then we’re in luck. If it’s a partition then,
  4. Just make sure we have a live usb disk. I used my Mint installer
  5. Then we need to turn swap off (swapoff command)
  6. If there’s a partition / file entry in fstab remove it
  7. Now, if it’s a file skip down to step 13
  8. If it’s a partition boot off the live usb disk
  9. Install some gui partition tool off the net, depending on the kind of partition we have. (for e.g. GParted for raw ext4 partitions and blivet-gui for lvm stuff)
  10. Best way forward (to my mind) is to get rid of the partition and then create a swapfile
  11. So delete the swap partition, and resize the main one to take in the free space left behind (this could take a while)
  12. Once done boot back into the system
  13. Create a bigger swapfile and activate it. (mkswap,swapon) (I made mine 3gb. (while having 8gb of ram))
  14. Create entry in fstab
  15. Reboot

Linuxize, has a pretty good guide on the commands and permissions involved.


P.S. Subscribe to my mailing list!
Forward these posts and letters to your friends and get them to subscribe!
P.P.S. Feed my insatiable reading habit.