RetroFed Forum
Your home away from modern life.
Stop Doing Swap Partitions
Post Reply
AuthorMessage
cannedtuna lemmy.world cannedtuna@lemmy.world
Joined: 2023-06-21
Quote

Credit to @ryanc@infosec.exchange

I just did the graphic

669   Original
Jul piefed.blahaj.zone irotsoma@piefed.blahaj.zone
Joined: 2025-09-25
#2 · Quote Reply

There are good use cases for swap. I work with very performance sensitive memory hogging applications that tend to process in bursts as incoming batched data arrives. We also have a lot of required background "security" applications.

Having the idle applications move out to swap so that a significant amount of free RAM to allow for the active, real-time applications to expand into is a major boon. RAM is expensive now, so it's become even more critical to not waste it.

But even in self-hosting at home I take advantage of it since I have a limited number of servers with limited RAM and a bunch of applications and/or docker containers running, many of which don't need to be active at all times, but if they were all active, would have trouble with the limited RAM. Swap allows for inactive applications to free up RAM for the active ones and leave enough available at all times to allow an application to quickly spin up new jobs.

Anyway, sure, for a simple desktop computer without a bunch of junk background applications running for "security" or whatever, and an overabundance of RAM installed, it's probably not useful. But for high performance, memory hungry applications with lots of background stuff running, it can be a big help.

That said, there are use cases where the opposite is useful and using a RAM drive is better than writing to disk for cache and temporary logs when you have enough RAM. My opnsense router for instance uses a RAM drive to store cache and logs (logs are mirrored to the NAS for long term storage, so just the local copy is lost on reboot). That system has enough RAM and I'd rather reduce disk wear, and I don't plan to add too many other applications to that server that it would run low.

64
87Six lemmy.zip 87Six@lemmy.zip
Joined: 2025-09-19
#3 · Quote Reply

All I know is that I had 16GB RAM and 4GB swap and I used to get crashes sometimes.

Set that fucker to 32GB out of spite, now no crashes. No idea why that helped. But I guess I do have like 15 tabs open on the regular (web dev)

19
WalrusDragonOnABike [they/them] reddthat.com WalrusDragonOnABike@reddthat.com
Joined: 2023-12-31
#4 · Quote Reply

I've had my computer crash trying to open or save a pdf once because it used up all the RAM space (16gb) and then used up the small swap (probably like 10gb?) and I guess some critical processes I guess just got told "no." Seems wild to me that Windows would just crash before it told a pdf it couldn't use over 20gb of memory.

5
Oisteink lemmy.world Oisteink@lemmy.world
Joined: 2023-06-18
#5 · Quote Reply

There are good use cases for swap. I work with very performance sensitive memory hogging applications that tend to process in bursts as incoming batched data arrives. We also have a lot of required background "security" applications. Having the idle applications move out to swap so that a significant amount of free RAM to allow for the active, real-time applications to expand into is a major bo...

Its a meme built on stuff like this:

https://gist.github.com/joshenders/c4960cec9c63a7b7d68ffa9543356c43

24
queeradjacent sh.itjust.works queeradjacent@sh.itjust.works
Joined: 2026-08-10
#6 · Quote Reply

Maybe stop giving a shit what I do with my partions? 🤷 Mine is definitely to try and make hibernate work on a shitty old laptop that'll drain the battery if I let it sleep and unplug it.

1
onipa feddit.org onipa@feddit.org
Joined: 2025-07-22
#7 · Quote Reply

Maybe stop giving a shit what I do with my partions? 🤷 Mine is definitely to try and make hibernate work on a shitty old laptop that'll drain the battery if I let it sleep and unplug it.

I was thinking about hibernation as well but wasn’t sure if hibernation might also work with a swap file

2
basic_user lemmy.world basic_user@lemmy.world
Joined: 2023-06-12
#8 · (edited) Quote Reply

Have a PC with 16gb ram that lives up to the overwatch game system reqs. When I installed it and launched it, it began building some sort of cache. A one time job. During that chache my os would force close steam to prevent an oom crash. I then added 16gb swap and during the owerwatch cache job the used phys ram would max out at 12gb I think and the swap sent up to 10gb. So a 22gb ram job. Yikes. Thanks swap ram 👍

5
dan upvote.au dan@upvote.au
Joined: 2023-06-14
#9 · Quote Reply

People still use swap partitions instead of swap files?

29
windowsphoneguy feddit.org windowsphoneguy@feddit.org
Joined: 2024-06-22
#10 · Quote Reply

OMG I miss this meme format

5
tal lemmy.today tal@lemmy.today
Joined: 2023-10-04
#11 · (edited) Quote Reply

"Hello I would like to torture my SSD's FTL because I left three Electron apps open"

If you don't actually need the swap, Linux isn't going to make use of swap. If you need the swap, then you'd probably rather use it than have the OOM killer take out a process.

My desktop has plenty of swap available, but is using none of it, because the system isn't under memory pressure.

10
libewa feddit.org libewa@feddit.org
Joined: 2026-07-29
#12 · Quote Reply

People still use swap partitions instead of swap files?

This. Swap files on LUKS encrypted partition. Also, the swapspace daemon!

17
IAmYouButYouDontKnowYet reddthat.com IAmYouButYouDontKnowYet@reddthat.com
Joined: 2026-01-25
#13 · Quote Reply

People still use swap partitions instead of swap files?

Don't you need swap partitions to be able to use hibernation?

6
PervServer fedinsfw.app PervServer@fedinsfw.app
Joined: 2026-04-13
#14 · Quote Reply

Don't you need swap partitions to be able to use hibernation?

Nope, I hibernate with a swap file and it's in a LUKS partition. Although IIRC that whole setup requires me to use systemd boot.

7
Blue_Morpho lemmy.world Blue_Morpho@lemmy.world
Joined: 2023-11-14
#15 · Quote Reply

All I know is that I had 16GB RAM and 4GB swap and I used to get crashes sometimes. Set that fucker to 32GB out of spite, now no crashes. No idea why that helped. But I guess I do have like 15 tabs open on the regular (web dev)

Historically swap needed to be a minimum of installed ram.

10
Blue_Morpho lemmy.world Blue_Morpho@lemmy.world
Joined: 2023-11-14
#16 · Quote Reply

"Unresizeable block device at end of disk"

Classically the swap partition was located at the physical middle of the drive so that on average, no matter where the heads where, the swap partition wasn't far away

17
JasonDJ lemmy.zip JasonDJ@lemmy.zip
Joined: 2024-01-16
#17 · Quote Reply

All I know is that I had 16GB RAM and 4GB swap and I used to get crashes sometimes. Set that fucker to 32GB out of spite, now no crashes. No idea why that helped. But I guess I do have like 15 tabs open on the regular (web dev)

15 tabs? Those are rookie numbers. Unless you mean "before 8:07 Monday morning".

17
tal lemmy.today tal@lemmy.today
Joined: 2023-10-04
#18 · (edited) Quote Reply

Historically swap needed to be a minimum of installed ram.

I don't recall that, but IIRC it does need to be a minimum of installed RAM if you want to be able to hibernate, since then you write out the contents of your memory to swap. That makes having at least as much swap as RAM a good rule of thumb for many systems.

IIRC kernel crash dumps also make use of swap in a similar way, though I assume that in most sane scenarios, it's not going to actually require as much swap as physical memory, because you won't have all of your physical memory allocated to the kernel.

On non-exotic Linux systems, I always make sure to have more swap than physical RAM.

10
dan upvote.au dan@upvote.au
Joined: 2023-06-14
#19 · Quote Reply

This. Swap files on LUKS encrypted partition. Also, the swapspace daemon!

I've seen so many setups where people encrypt their data but forget to encrypt their swap.

12
dan upvote.au dan@upvote.au
Joined: 2023-06-14
#20 · Quote Reply

Don't you need swap partitions to be able to use hibernation?

I don't use hibernation so I'm not sure.

2
Supercrunchy programming.dev Supercrunchy@programming.dev
Joined: 2025-07-01
#21 · Quote Reply

There are good use cases for swap. I work with very performance sensitive memory hogging applications that tend to process in bursts as incoming batched data arrives. We also have a lot of required background "security" applications. Having the idle applications move out to swap so that a significant amount of free RAM to allow for the active, real-time applications to expand into is a major bo...

I also found it useful to do some one-off batch processing of a big file without thinking of chunking and doing too complicated things. Imagine something like a 60GB file in a custom format that need to be deduplicated. It's easier to just load it all up in memory and do run the algorithm 2-3x slower using a 50GB swapfile than spend hours to complicate the algorithm.

6
ruuster13 lemmy.zip ruuster13@lemmy.zip
Joined: 2025-07-09
#22 · Quote Reply

I init a ramdisk and put a swap file there and call it L4 cache

10
18107 aussie.zone 18107@aussie.zone
Joined: 2023-07-04
#23 · Quote Reply

No

15.5/15.5 GB RAM used, plus 16.8/465GB swap

It turns out the computer mostly freezes once you go past 200% RAM used.

44
SolSerkonos piefed.social SolSerkonos@piefed.social
Joined: 2025-07-25
#24 · Quote Reply

15 tabs? Those are rookie numbers. Unless you mean "before 8:07 Monday morning".

fr. I'm over here with like 30+ tabs open. I should definitely trim these..

3
queeradjacent sh.itjust.works queeradjacent@sh.itjust.works
Joined: 2026-08-10
#25 · Quote Reply

I was thinking about hibernation as well but wasn’t sure if hibernation might also work with a swap file

Honestly the kernel is smart enough to only use it if you need it most of the time from what I can remember from my admin days, no idea why op cares.

3
rem26_art fedia.io rem26_art@fedia.io
Joined: 2024-03-03
#26 · Quote Reply

Building a PC in 2026 be like "I cant afford RAM, but I can use a whole TB hard disk I shucked from an old WD external as swap and maybe my PC will feel modern"

11
Eager Eagle lemmy.world eager_eagle@lemmy.world
Joined: 2023-07-07
#27 · (edited) Quote Reply

15 tabs? Those are rookie numbers. Unless you mean "before 8:07 Monday morning".

browsers offload inactive tabs from memory anyway, unless you're actively switching among 15+ tabs, they won't be using as much ram

8
smeg feddit.uk smeg@feddit.uk
Joined: 2023-07-01
#28 · Quote Reply

[deleted]
68
palordrolap fedia.io palordrolap@fedia.io
Joined: 2024-08-13
#29 · (edited) Quote Reply

I init a ramdisk and put a swap file there and call it L4 cache

I actually did this for a laugh a very, very long time ago. I had upgraded my 75MHz Pentium machine from 8MB to a whopping 40MB, so since I knew it would run fine with just 8, I installed a TSR RAMdisk and told Windows 3.1 to put its swap on that drive.

It worked great, but I decided I'd rather use the memory for other things.

But in more modern times, I've literally forced browser caches into memory-based tmpfs to take the load off system disks, which is basically the same thing. And it reduces wear on my hardware.

8
Zenorbi lemmy.world Zenorbi@lemmy.world
Joined: 2023-07-02
#30 · Quote Reply

I used to be this guy. We have huge amount of memory in our storage server. Why would we need swap? Well, once the system started killing programs I read up on swap and how the system handles its caches, especially ZFS ARC.

Short version is that while the system can evict its caches syncronously, it can only async notify ZFS that it should also shrink its caches, but the out-of-memory killer will start killing before ZFS and its kernel counterpart can start to free up memory.

A tiny bit of swap completely solved this, since swapping is sync for the kernel and the OOM killer will wait for it.

45
cannedtuna lemmy.world cannedtuna@lemmy.world
Joined: 2023-06-21
#31 · Quote Reply

[deleted]

Shit did I botch it? I made this on my phone and the toot I copied the script from was just text. Wanted to make it look more interesting so I found this site that let you make the windows. I just went with what I thought looked best.

30
provectus lemmy.ml provectus@lemmy.ml
Joined: 2026-04-23
#32 · (edited) Quote Reply

Then what is the setup if my computer only has 4GB of memory for daily driving? Just curious because swap partitions are what I normally do on limited resource machines.

7
Ooops feddit.org Ooops@feddit.org
Joined: 2024-07-06
#33 · (edited) Quote Reply

Don't you need swap partitions to be able to use hibernation?

It's doable with a swap file instead. But some filesystems are more supportive than others.

For example BTRFS doesn't support swapfiles over multiple devices (so my raid1c3 spanning 3 differently sized disks for example) and also swapfiles must be completely pre-allocated.

And no matter the filesystem you need to manually tell the kernel device and physical offset for the file via kernel parameters. Which can again be easier on some than on others (also causing the no-multiple-device filesystem problem mentioned above.

3
smeg feddit.uk smeg@feddit.uk
Joined: 2023-07-01
#34 · Quote Reply

Shit did I botch it? I made this on my phone and the toot I copied the script from was just text. Wanted to make it look more interesting so I found this site that let you make the windows. I just went with what I thought looked best.
[deleted]
3
azimir lemmy.ml azimir@lemmy.ml
Joined: 2023-06-02
#35 · Quote Reply

I have a small home server that I occasionally push through huge batch processing jobs. During the pushes, I might collide with other projects that use a pretty big chunk of the RAM. So, to make sure it's never a killer (just a major slow down), I made a 32GB swap file. If I need it, it's there and disk is hella cheap.

This machine has never had a GUI installed. No browsers to complain about, just plain old data processing, stats models, and old skool computing.

Now, my worst case scenario was building a C++ program on a raspberry pi gen 1. That has 256MB of RAM. g++ ran out building, so I NFS mounted a huge disk from my desktop machine and made the swap file there. The build took a while... but the program ran fine after the week long build, no swap needed.

4
alecsargent lemmy.zip alecsargent@lemmy.zip
Joined: 2025-08-13
#36 · Quote Reply

Real Linux users do not use MacOS window decorations in their graphics.

;)

5
cannedtuna lemmy.world cannedtuna@lemmy.world
Joined: 2023-06-21
#37 · Quote Reply

Real Linux users do not use MacOS window decorations in their graphics. ;)

Used a website to make the windows since I was on mobile. Thought it looked too plain w/o the window decorations, but yeah. I mean there’s so many distros and themes, who’s to say it couldn’t be Linux. I’ve seen KDE reskinned to look like OSX

2
cannedtuna lemmy.world cannedtuna@lemmy.world
Joined: 2023-06-21
#38 · Quote Reply

[deleted]

Idk. KDE has themes like this but yeah I get it

5
wuffwuffwuff sh.itjust.works wuffwuffwuff@sh.itjust.works
Joined: 2024-07-15
#39 · Quote Reply

[deleted]

i'm sure someone has made a KDE theme or a Gnome theme that replicates MacOS, let's pretend that's what's happened.

11
mlg lemmy.world mlg@lemmy.world
Joined: 2023-07-29
#40 · Quote Reply

Then what is the setup if my computer only has 4GB of memory for daily driving? Just curious because swap partitions are what I normally do on limited resource machines.

Dunno how well zswap handles at that size, but the point is that is compresses swap into RAM, so it would use a max of 819.2M for a total of 2457.6M of swap space. If you need more, then by all means, use a swap file or partition lol.

Actually linux easily supports multiple and tiered swap mounts, so you could even go zswap + ssd swap + hdd swap, or a cheapo "burn at your own risk" usb flash swap lol.

6
zitrone 🍋 europe.pub zitrone@europe.pub
Joined: 2026-03-10
#41 · Quote Reply

Real Linux users do not use MacOS window decorations in their graphics. ;)

right real linux user do everything in the tty and maybe put something in the framebuffer if they want to view an image or similar

5
Dumhuvud programming.dev Dumhuvud@programming.dev
Joined: 2023-06-11
#42 · Quote Reply

Don't you need swap partitions to be able to use hibernation?

Nah, you can use resume_offset instead.

Here's an example: https://forum.endeavouros.com/t/how-to-hibernate-with-btrfs-swapfile-luks2-systemd-boot-dracut/55620/2

5
adarza lemmy.ca adarza@lemmy.ca
Joined: 2024-05-29
#43 · Quote Reply

People still use swap partitions instead of swap files?

that's what trixie's netinst defaults to when i set up new desktops using encrypted lvm.. root and swap volumes inside that, unlocking together at boot. my use doesn't hit swap much, so it's nbd. i just leave it like it is. only where an installer doesn't support encrypted swap partitions do i use a file or ram-based swap instead.

2
Trail lemmy.world Trail@lemmy.world
Joined: 2023-07-11
#44 · Quote Reply

Real Linux users do not use MacOS window decorations in their graphics. ;)

Real real Linux users use whatever the hell they want.

19
alecsargent lemmy.zip alecsargent@lemmy.zip
Joined: 2025-08-13
#45 · Quote Reply

Used a website to make the windows since I was on mobile. Thought it looked too plain w/o the window decorations, but yeah. I mean there’s so many distros and themes, who’s to say it couldn’t be Linux. I’ve seen KDE reskinned to look like OSX

It's fine, I really like MacOS X too. To be fair those window decorations looks real nice as demos.

5
7rokhym lemmy.ca 7rokhym@lemmy.ca
Joined: 2023-07-26
#46 · Quote Reply

Definitely configure swap, but I don't think there is much benefit of a swap partition over a swap file these days and swap files are trivial to configure.

9
dan upvote.au dan@upvote.au
Joined: 2023-06-14
#47 · Quote Reply

that's what trixie's netinst defaults to when i set up new desktops using encrypted lvm.. root and swap volumes inside that, unlocking together at boot. my use doesn't hit swap much, so it's nbd. i just leave it like it is. only where an installer doesn't support encrypted swap partitions do i use a file or ram-based swap instead.

It's not as bad with LVM since LVM is more flexible. A swap file does still make it easier to change the size as needed though. If you need more swap, you can spin up a new swap file pretty much instantly while the system is running, without having to repartition. You can have both a swap partition and a swap file active at the same time though.

On systems where the data is encrypted, also encrypting the swap makes sense so I'm glad Debian does that.

4
muhyb programming.dev muhyb@programming.dev
Joined: 2023-07-05
#48 · Quote Reply

Then what is the setup if my computer only has 4GB of memory for daily driving? Just curious because swap partitions are what I normally do on limited resource machines.

Eh, it's fine. That's what I do with 4 GB RAM as well. However even though I set 8 GB swap on that machine I noticed it's hardly using the half of it at most. (Using Void Linux)

3
DevDave piefed.social DevDave@piefed.social
Joined: 2026-04-06
#49 · Quote Reply

I've seen so many setups where people encrypt their data but forget to encrypt their swap.

what's the problem? it's not like you dump the entire contents of your system's ram to disk any time use hibernate /s

6
dan upvote.au dan@upvote.au
Joined: 2023-06-14
#50 · Quote Reply

what's the problem? it's not like you dump the entire contents of your system's ram to disk any time use hibernate /s

Even without hibernation, data in apps you have open will end up in the swap if your system is ever RAM-constrained.

4
Kangae_Hishiryo scribe.disroot.org Kangae_Hishiryo@scribe.disroot.org
Joined: 2026-04-13
#51 · Quote Reply

There are good use cases for swap. I work with very performance sensitive memory hogging applications that tend to process in bursts as incoming batched data arrives. We also have a lot of required background "security" applications. Having the idle applications move out to swap so that a significant amount of free RAM to allow for the active, real-time applications to expand into is a major bo...

Actually, there are more than these.
For example, hibernation and/or hybrid suspension. It's, AFAIK, mandatory to have a swap partition to be able to hibernate and/or hybrid suspend your device.

11
Post Reply Page 1 of 3   Goto page 1, 2, 3 Last »
Back to top