Score:17

Is Linux swap partition still needed with Ubuntu 22.04

hk flag

I read that if there is no swap partition, newer Ubuntu versions may use a special file on any other available disk space once the RAM is completely used.

Can anybody with more knowledge than me please confirm this information? Then I would remove my Linux-swap partition to gain more space.

RonJohn avatar
cn flag
Note that the swap file (or partition) does **not** need to be 2x RAM size on a non-laptop system. Hasn't needed to be that large in 10+ years.
markus-nm avatar
nc flag
FYI: the swapfile will use the same space as the swap partition (for a given swap size) -- you dont save any disk space by switching from swap-partition to swap-file. The swap-file is not dynamically resized, it is allocated at full size. However, you do gain the option to turn off the swap or resize it on demand. With a swap-partition, that would mean to repartition your disk, which would require a reboot, if it's the system disk.
Score:25
cn flag

There is no longer a default swap partition, but Ubuntu will use it. By default Ubuntu now uses swapfile as its easier to manage (no partition changes are required to increase/decrease size)

I'll still use swap partitions on most of my machines, but my systems are mostly dual boot & thus I can have multiple systems share the same swap partition thus saving my disk space... Also as I'm involved with QA, many installed systems are often being re-installed and any shared swapfile on another systems' drive just complicates matters (ie. sharing is still possible even with swapfiles)

Swap files vs Swap partitions just give us another option, and we can use whichever will work best for our system, and most importantly our own usage.

FYI: I've QA-tested & all releases up to current mantic (what will be 23.10 on release) can still use either. You can even use both if you wish (adding swapfile if you need extra swap for some tasks, though I suspect there are costs with doing this in efficiency - but it works)

Tejas Kale avatar
cn flag
In your QA testing, has hibernate ever worked? Always errors out with either Insufficient Memory or AMD GPU driver crashes. ( That probably deserves its own question )
guiverc avatar
cn flag
"*ever worked" - Yes it has... however it's box specific; as the same install on different hardware (*with different specs*) fails to hibernate.. Either way I haven't QA-tested hibernate in years as that's a rather hardware specific feature and different boxes need different configurations due to the different hardware. *added this later, only as this question has been picked up by UWN - 'hot in support'*
Score:8
US flag
user1708916

I've been reading about the thing with the swap Partition, and this is what I concluded:

Nowadays, at least in recent Ubuntu versions, there's not need to create a swap partition if you aren't going to use the Hibernation Mode. As you mentioned, if you don't create a swap partition, Ubuntu will use a swap file that will works (as far I know) just like a swap partition.

Anyway you can create it if you want, there won't be any problem, or if you have it and want to delete it, there won't be problem neither. If you go out of RAM, Ubuntu will use the swap file. I also read that you can even use Hibernation Mode with that swap file if you do the correct configs.

If you want to read about this in Ubuntu official documentation, you can do it: https://help.ubuntu.com/community/SwapFaq#Should_I_reinstall_with_more_swap.3F there is even a paragraph where explains that since the 2.6 Linux Kernel a swap file is as fast as a swap partition.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.