Swap and Lubuntu (21.04/hirsute and up)

Q: What is swap?

I’ll refer to general instructions here - please look at SwapFaq - Community Help Wiki which includes instructions on setting up swap too.

Q: Can Lubuntu use swap?

Yes; all releases of Lubuntu have allowed the use of swap. Lubuntu 20.04 LTS allows you to create swap partitions in the Manual partitioning area, and post-install you can setup and use swap files, please refer to How to create a swapfile in Lubuntu 20.04 & 20.10.

Lubuntu 21.04 and later provide more options too. :slight_smile:

Q: Can Lubuntu 21.04 create swapfile during install?

Yes if you use the erase disk option.

Other install options do not offer to create a swap file; eg. Manual partitioning, Replace a partition do not offer you the chance to create a swap file, but you can add one if you like post-install by referring to the previously provided link.

With the Manual partitioning option you can also create new swap partitions if required.

Q: Which is better? Swap partition or swap file?

Each has benefits and of course costs. Swap files are easier with encryption and far easier should you need to change the size, so being simpler I’d suggest using swapfile over swap partition.

However if you have a dual boot system you can share a swap partition between two releases of GNU/Linux eg. *I have a swap partition that is shared between Lubuntu 20.04 LTS & Lubuntu impish; I can’t hibernate one & switch to the other of course with a shared swap partition, but it saves space over having a swapfile for each OS.

Q: Can I use swap partition & swapfile?

Yes you can.

Q: Replace a partition? Does a prior swapfile get re-used/created?

I looked at this using the current impish system and this type of install causes a 512MB swapfile to be created. :slight_smile: This type of install is clean so all files are new on install.

Note: As the calamares currently used in impish is identical to that of 21.04/hirsute I’d expect 21.04 to be the same.

Q: Manual partitioning; install into existing partition(s) without format; does it cause swap to get re-used

This install involves re-using existing partitions and not formatting, ie. an unclean install… I think of it as a quick fix because of a package stuff up (but not user configs, as that isn’t touched; any user config problem will remain!) as this is a very fast way to re-install & get back to being functional. It causes the installer to

  • notes your packages installed
  • erases system directories
  • installs new system
  • adds back the additional packages you had installed (if they’re available in Ubuntu repositories)

without touching user files (assuming you don’t format!).

I tested this using the current impish system and this type of install kept a 512MB swapfile which was used on reboot. :slight_smile:

This type of install is unclean so the swapfile in my case was not re-created (going by file creation timestamp) so if you’d increased size beyond the default 512MB I’d expect the larger size to have survived (/ is not a system directory which is wiped). Alas I didn’t think of changing the size prior to this test :frowning:

Note: As the calamares currently used in impish is identical to that of 21.04/hirsute I’d expect 21.04 to be the same.

4 Likes