RetroFed Forum
Your home away from modern life.
Stop Doing Swap Partitions
Post Reply
AuthorMessage
redjard reddthat.com Redjard@reddthat.com
Joined: 2023-08-06
#52 · Quote Reply

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

Generally it only happens to programs you keep running in the background and might not use for a long time that also don't have much background activity. For example password managers.

1
redjard reddthat.com Redjard@reddthat.com
Joined: 2023-08-06
#53 · Quote Reply

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.

I do the same and use ugrd. I think dracut would also work.
You just set the resume kernel parameter to the decrypted memory device with the swapfile offset.
As long as the initrd attempts a resume after it decrypted all volumes it'll work, and the initrd doesn't even need to understand why and what was resumed from

1
redjard reddthat.com Redjard@reddthat.com
Joined: 2023-08-06
#54 · Quote Reply

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 parame...

btrfs's handling makes sense. The kernel talks to the disk directly, the file is just a pointer for what range it uses, and a placeholder for the filesystem. Something like raid, balancing, cow, all won't work because the kernel doesn't even go through btrfs to change the swap"file".
If you want a proper file as swapfile, with the corresponding overhead, you can make a regular file and mount it via loopback then use it as a swap device.

1
Fizz lemmy.nz Fizz@lemmy.nz
Joined: 2023-06-12
#55 · 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 wi...

As well as oom situations, swapping allows the memory to be used more effectively by swapping out anonymous pages that aren't likely to be used but can't be dropped.

11
redjard reddthat.com Redjard@reddthat.com
Joined: 2023-08-06
#56 · Quote Reply

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

So you shut your pc down like a caveman when you do hardware upgrades or repairs or move apartments?

2
rumschlumpel feddit.org rumschlumpel@feddit.org
Joined: 2024-06-23
#57 · (edited) Quote Reply

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 ...

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.

IF RAM used + swap used don't exceed total swap space. Yeah, sometimes I run into that. Solved by killing webbrowsers, which suggests that most of the swap space is filled with unused webpages...

2
glibg10b lemmy.zip glibg10b@lemmy.zip
Joined: 2026-02-05
#58 · Quote Reply

swapfile gang

.rw------- root root 4.0 GB Mon Jun  1 04:10:37 2026  /var/swap
14
redjard reddthat.com Redjard@reddthat.com
Joined: 2023-08-06
#59 · Quote Reply

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

what if you never restart the browser though?

1
michaelmrose lemmy.world michaelmrose@lemmy.world
Joined: 2023-07-23
#60 · 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.

Is this tongue in cheek i swear I cannot tell any longer.

Some swap is beneficial

6
cannedtuna lemmy.world cannedtuna@lemmy.world
Joined: 2023-06-21
#61 · Quote Reply

Is this tongue in cheek i swear I cannot tell any longer. Some swap is beneficial

It’s based on a common meme template. Yeah it’s tongue in cheek and I guess a lot of commenters can’t tell given this is a memes comm

8
SaharaMaleikuhm feddit.org SaharaMaleikuhm@feddit.org
Joined: 2024-07-23
#62 · Quote Reply

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

64 GB are $1000 so maybe not

1
dan upvote.au dan@upvote.au
Joined: 2023-06-14
#63 · Quote Reply

So you shut your pc down like a caveman when you do hardware upgrades or repairs or move apartments?

Yeah I shut down every day. It boots up fast enough that it's really not an issue.

4
dan upvote.au dan@upvote.au
Joined: 2023-06-14
#64 · Quote Reply

Generally it only happens to programs you keep running in the background and might not use for a long time that also don't have much background activity. For example password managers.

It depends on what you set your swappiness to, too. I think Linux distros still have pretty aggressive defaults that swap more than they probably need to.

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

swapfile gang .rw------- root root 4.0 GB Mon Jun 1 04:10:37 2026  /var/swap

Do you hibernate? 🐻

1
Grandwolf319 sh.itjust.works Grandwolf319@sh.itjust.works
Joined: 2023-06-24
#66 · Quote Reply

And here I am using swap for my self hosted services, some of which use ridiculous amount of ram.

2
topperharlie lemmy.world topperharlie@lemmy.world
Joined: 2023-06-11
#67 · Quote Reply

Everyone defending swap like crazy in the comments... so let me give a counter argument specifically for desktop:

Many years ago I stopped using swap on all my computers (I exclusively use linux) and the reason is: every time anything regarding interactivity went to swap, my system would freeze and literally become unusable for a really long time until I killed something. Since I got tired if that behaviour I decided I prefer for random shit to die but my computer still be usable.

It wasn't very often, but I don't get OOM killer often either (as in I don't remember the last time it happened and I use linux every day for both work and fun), and the freezing situation was way more annoying, to the point I sometimes ended up cold switching off the computer. I'm surprised on how many people run out of memory constantly. I guess you all are just using linux for servers and have crazy processing of infinite data...

13
boonhet lemmy.zip boonhet@lemmy.zip
Joined: 2026-08-12
Banned
#68 · Quote Reply

Everyone defending swap like crazy in the comments... so let me give a counter argument specifically for desktop: Many years ago I stopped using swap on all my computers (I exclusively use linux) and the reason is: every time anything regarding interactivity went to swap, my system would freeze and literally become unusable for a really long time until I killed something. Since I got tired if t...

Were you using a HDD for swap? It's nearly unnoticeable on an NVMe drive.

8
topperharlie lemmy.world topperharlie@lemmy.world
Joined: 2023-06-11
#69 · Quote Reply

Were you using a HDD for swap? It's nearly unnoticeable on an NVMe drive.

yep it was HDD, but with the low amount of times I have any OOM issue, I'm way more worried about NVMe flash burning than a random process being killed once every blue moon.

In fact I didn't mention, but since the advent of flash drives what I've done is trying to locate heavy disk writing apps and find alternatives for them, amid disabling many logs.

For swap, it hunts me to think some automatic process I don't have control over will burn those sweet erase cycles without me noticing just because someone programmed it poorly. I'm way more happy knowing I have some control over it.

2
onlinepersona programming.dev onlinepersona@programming.dev
Joined: 2023-09-01
#70 · Quote Reply

"I'm not a friggin bear, I don't hibernate!"

16
Axolotl feddit.it Axolotl_cpp@feddit.it
Joined: 2025-10-10
#71 · Quote Reply

My built-in Devil's Advocate has to ask if that's really true? Have you got a citation newer than 2 decades old? Frankly, i find it difficult to believe that anyone wouldn't like to use electron software, for the simple reason that making your SSD suffer is fun.

Edit: in 30 years of administering Linux and (previously) Solaris sytems i've never once had to change HDDs or SSDs, so claims of torture are, i opine, exaggerated. i'll also claim that keeping electron software out of the filesystem is not good for your hygiene.

7
whyNotSquirrel sh.itjust.works whyNotSquirrel@sh.itjust.works
Joined: 2023-06-10
#72 · Quote Reply

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

what is using so much ram?

2
danielfm123 lemmy.zip danielfm123@lemmy.zip
Joined: 2026-07-12
#73 · Quote Reply

Swap and zram saved my R and Python Dana analysis script a couple of times.

11
glibg10b lemmy.zip glibg10b@lemmy.zip
Joined: 2026-02-05
#74 · Quote Reply

Do you hibernate? 🐻

No, I have a 13-second boot time

6
18107 aussie.zone 18107@aussie.zone
Joined: 2023-07-04
#75 · (edited) Quote Reply

what is using so much ram?

Trying to ray-trace a 512,000x256,000 image using Chunky. I had to split it into 16 parts to reduce the RAM to a sane amount (in 2018, it may have been optimised since).

I was trying to find the limit for a single png, and I think I found it.

3
j3tt lemmy.world j3tt@lemmy.world
Joined: 2026-08-01
#76 · 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 wi...

I sometimes cannot do hibernate when I did a scrub on my ZFS. But the first try always frees up the swap and so the second attempts works every time.

1
j3tt lemmy.world j3tt@lemmy.world
Joined: 2026-08-01
#77 · Quote Reply

what if you never restart the browser though?

I close my browser before hibernating; more lifetime for my SSD that way and it is faster, too.

1
j3tt lemmy.world j3tt@lemmy.world
Joined: 2026-08-01
#78 · Quote Reply

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 ...

I use 1.5-2x the swap on new installations these days. I want hibernate to always work.

3
Klajan lemmy.zip Klajan@lemmy.zip
Joined: 2023-10-02
#79 · Quote Reply

I use 1.5-2x the swap on new installations these days. I want hibernate to always work.

I use the same, but I think to be super conservative It should be 1.5x + VRAM

2
fuck_u_spez_in_particular lemmy.world fuck_u_spez_in_particular@lemmy.world
Joined: 2023-07-24
#80 · Quote Reply

what is using so much ram?

16GB are my usual breakfast, I'll fill that quickly after booting... I'm happy that I got 64GB, though even that is often used up, thus I sometimes wish for 128Gb though (and for running somewhat capable local LLMs 512GB would be even better...).

Bottomline: ypu can basically never have enough RAM...

7
CommanderCloon lemmy.ml CommanderCloon@lemmy.ml
Joined: 2023-07-31
#81 · 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.

That makes it funnier ngl

15
tal lemmy.today tal@lemmy.today
Joined: 2023-10-04
#82 · Quote Reply

Trying to ray-trace a 512,000x256,000 image using Chunky. I had to split it into 16 parts to reduce the RAM to a sane amount (in 2018, it may have been optimised since). I was trying to find the limit for a single png, and I think I found it.

I'd guess that there are probably utilities to export the world file to POV-Ray or Blender or something. They might be able to scale better.

1
TheRagingGeek lemmy.world TheRagingGeek@lemmy.world
Joined: 2023-06-15
#83 · Quote Reply

My built-in Devil's Advocate has to ask if that's really true? Have you got a citation newer than 2 decades old? Frankly, i find it difficult to believe that anyone wouldn't like to use electron software, for the simple reason that making your SSD suffer is fun. Edit: in 30 years of administering Linux and (previously) Solaris sytems i've never once had to change HDDs or SSDs, so claims of tort...

That’s some really great luck you have, over the 15 years or so I have been running my Linux server I have had to replace the SSD twice(likely due to gentoo and compiling everything all the time) and had 2 hdds in my raid cluster need replacement. Here’s hoping my NAS has your luck

6
Axolotl feddit.it Axolotl_cpp@feddit.it
Joined: 2025-10-10
#84 · (edited) Quote Reply

That’s some really great luck you have, over the 15 years or so I have been running my Linux server I have had to replace the SSD twice(likely due to gentoo and compiling everything all the time) and had 2 hdds in my raid cluster need replacement. Here’s hoping my NAS has your luck

To be clear: what i wrote is not actually something real, it was a joke i made by modifying a comment from a thread on github gist, i am actually surprised it wad credible enough that someone would reply seriously xD

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

7
grrgyle slrpnk.net grrgyle@slrpnk.net
Joined: 2024-03-18
#85 · Quote Reply

My built-in Devil's Advocate has to ask if that's really true? Have you got a citation newer than 2 decades old? Frankly, i find it difficult to believe that anyone wouldn't like to use electron software, for the simple reason that making your SSD suffer is fun. Edit: in 30 years of administering Linux and (previously) Solaris sytems i've never once had to change HDDs or SSDs, so claims of tort...

I manage a cluster that makes heavy use of SSDs in RAID10 configuration. Those things are constantly degrading and having to be swapped out. I've started a drawer of faulted drives that I don't have the heart you throw out.

2
grrgyle slrpnk.net grrgyle@slrpnk.net
Joined: 2024-03-18
#86 · Quote Reply

No, I have a 13-second boot time

Bah, 56 seconds ought to be enough for anyone

5
grrgyle slrpnk.net grrgyle@slrpnk.net
Joined: 2024-03-18
#87 · 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 wi...

I found that with swap the applications would slow to a crawl and then basically lock up entirely until I hauled my ass over and manually power cycled the machine.

2
diaphragmwp discuss.tchncs.de diaphragmwp@discuss.tchncs.de
Joined: 2026-06-03
#88 · (edited) Quote Reply

Once tortured myself with having to go through...

The Android build system. Booo, scary.

I only wanted a LineageOS boot image built. The recommended specs list 64GiB RAM. Figured wouldn't apply to me until I tried to build a target literally called "nothing". It just used up all of the RAM and OOMed about 2 minutes in, building the "build cache" or whatever the fuck it needs to do to "warm up".

After a few fucktons of swapspace, turning off some of my daemons, some sysctl fuckery (there were options for limiting process virtual memory size IIRC? I put it all the way up) and taskset -p 0-15:1 (use logical CPUs 0, 2, 4...), I had my laptop allocating 50 something GiB. I have 16GB (decimal) physical RAM installed and I consider that already way too much for my usual needs.

After about half an hour of the build system build systeming, it just stopped doing that then built the kernel in 4 minutes with everything else in some time too.

Yes, I have tried just running make directly. That just resulted in an image that did nothing but toggle on and off an empty (no percentage) charging circle via power button.

12
InnerScientist lemmy.world InnerScientist@lemmy.world
Joined: 2023-06-30
#89 · 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

Also "unresizeable" as if you can't just swapoff and just delete and recreated it anywhere (update the path in fstab) and then swapon again.

2
RustyNova lemmy.world RustyNova@lemmy.world
Joined: 2023-11-24
#90 · Quote Reply

I don't really need swap until I need to compile blender... Need somewhere around 64Gb (with compression) to deal with the peaks

6
provectus lemmy.ml provectus@lemmy.ml
Joined: 2026-04-23
#91 · Quote Reply

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.

That is pretty cool. Did not know that. Will still be keeping my partition because it works fine for me.

3
JackbyDev programming.dev JackbyDev@programming.dev
Joined: 2023-06-13
#92 · Quote Reply

Is this tongue in cheek i swear I cannot tell any longer. Some swap is beneficial

Like a lot of memes, they exaggerate for humor. This meme was originally about math.

3
JamesBoeing737MAX sopuli.xyz JamesBoeing737MAX@sopuli.xyz
Joined: 2024-09-04
#93 · Quote Reply

Everyone defending swap like crazy in the comments... so let me give a counter argument specifically for desktop: Many years ago I stopped using swap on all my computers (I exclusively use linux) and the reason is: every time anything regarding interactivity went to swap, my system would freeze and literally become unusable for a really long time until I killed something. Since I got tired if t...

Or shotcut. I once ran it on 8GB, minimal arch with no swap. Well.

And I'm not even trying to build android on my new relatively modern laptop. It won't work.

2
TheRagingGeek lemmy.world TheRagingGeek@lemmy.world
Joined: 2023-06-15
#94 · Quote Reply

To be clear: what i wrote is not actually something real, it was a joke i made by modifying a comment from a thread on github gist, i am actually surprised it wad credible enough that someone would reply seriously xD https://gist.github.com/joshenders/c4960cec9c63a7b7d68ffa9543356c43

Definitely bit the onion on this one, it did seem remarkable lol though I just pulled a 16 year old drive out of my Son’s PC(that was technically still working however slowly) hence the semi plausibility on my end lol

2
MonkderVierte lemmy.zip MonkderVierte@lemmy.zip
Joined: 2025-05-30
#95 · Quote Reply

My built-in Devil's Advocate has to ask if that's really true? Have you got a citation newer than 2 decades old? Frankly, i find it difficult to believe that anyone wouldn't like to use electron software, for the simple reason that making your SSD suffer is fun. Edit: in 30 years of administering Linux and (previously) Solaris sytems i've never once had to change HDDs or SSDs, so claims of tort...

Also, while Linux does run without Swap, it's like running gears without grease.

2
Axolotl feddit.it Axolotl_cpp@feddit.it
Joined: 2025-10-10
#96 · (edited) Quote Reply

Definitely bit the onion on this one, it did seem remarkable lol though I just pulled a 16 year old drive out of my Son’s PC(that was technically still working however slowly) hence the semi plausibility on my end lol

lmao, 16 years is a lot! That drive can drive

2
devfuuu lemmy.world devfuuu@lemmy.world
Joined: 2023-06-17
#97 · (edited) Quote Reply

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

Been using a swap file in a luks partition for years. I hibernate very regularly.

1
mazzilius_marsti lemmy.world mazzilius_marsti@lemmy.world
Joined: 2024-07-15
#98 · Quote Reply

unfortunately with S0ix being forced on all modern laptops, zram is the only logical choice. With s3 sleep at least i can say i need swap because i need hibernation...With S0ix? Dont bother.

3
tired_n_bored lemmy.world tired_n_bored@lemmy.world
Joined: 2023-06-08
#99 · Quote Reply

Can anyone tell me why I see swap usage with 10+GB of free RAM available?

8
Mwa thelemmy.club Mwa@thelemmy.club
Joined: 2024-06-27
#100 · Quote Reply

SWAP RAM is useful for hibernation mode and fall back ram incase you have low memory.

12
droans lemmy.world droans@lemmy.world
Joined: 2023-06-21
#101 · Quote Reply

Can anyone tell me why I see swap usage with 10+GB of free RAM available?

Because you just taught your computer how to be lazy. "oH lOoK aT mE i'M sWaP mEmOrY"

5
Post Reply Page 2 of 3   Goto page « First 1, 2, 3 Last »
Back to top