0

I have a trusty old ThinkPad R60 with only 3 GB RAM (upgraded from 2 GB) with Linux Mint Debian Edition 4 running on it. I chose LMDE for stability and the desktop environment. The machine is one of my workhorses and, usually having multiple applications/windows/tabs open, is never turned off. This is how the 256 GB SSD is partitioned:

Screenshot

As you can see, the drive is encrypted and there is currently no swap space, but due to a chronic RAM shortage I would like to create some (maybe around 3-4 GB, matching RAM capacity) in order address the frequent slowdowns.

Is it possible to freshly create swap on a running system and is there a difference between using a swap partition and a swap file? Does encryption cause any additional issue requiring attention? And is there anything that must be taken into consideration when running an SSD?

My layman guess on the last part would be that swap performance will be better with an SSD than with a standard mechanical HDD, but can result in increased wear (more write/erase cycles) when using parts of an SSD as RAM.

david
  • 297
  • 6
  • 18

1 Answers1

1

The easiest approach on already running system would be to create a swap file. Example below would create 4 GB one:

dd if=/dev/zero of=/swapfile.sys bs=1M count=4096
chmod 600 /swapfile.sys
mkswap /swapfile.sys
swapon /swapfile.sys
sed -i '$ a\/swapfile.sys\tnone\tswap\tsw\t0\t0' /etc/fstab

The last line is needed to automatically load it again after reboot.

You are correct as far as SSD/HDD difference is concerned. Swap will indeed perform better on SSD. I wouldn't worry about write/erase cycles as any modern SSD will generally do fine. It's really only issue on either SD or MMC device.

Josip Medved
  • 8,862
  • 1
  • 30
  • 42
  • Sorry, but this solution won't work since **LMDE4 automatically creates a swap file during installation** (without any option to disable it) - i.e. OP already *has* a swap file running! Therefore, a working solution must explain either how to enlarge an already existing & active swap file - or - how to create a new swap file of larger size, "hot-transfer" the contents of the active swap file to the new, empty one, then deactivate the old file and activate the new one. And all this, while the system is running, avoiding loss of data or a system crash. OP is facing a much more complicated issue – david Aug 24 '20 at 22:09
  • He explicitly said "there is currently no swap space" and image he attached shows no swap partition... – Josip Medved Aug 26 '20 at 02:53
  • Yes, and in that you are right. But the image doesn't show the block devices. I'm positive that if OP checks again, `gnome-disks` will show an encrypted swap partition/block device (probably around 2-4 GB). There is no way to install LMDE without it – david Aug 26 '20 at 03:17