Completely agree. I just added another 8 gigs of ram to have 16 like I prefer and even with 8 gigs I rarely went over 2.5 used. Setup the system with no swap partition or file and I’m not noticing any performance decrease because of that choice.
I personally always swap. I only have laptops though. I use hibernate a lot. Swap = RAM. If it’s an HDD, it’s a partition, if it’s an SSD, it’s a file.
If it’s a desktop, it’s completely your call. Just remember, no swap, no hibernate.
Is there a reason for this? I’ve heard some stuff about a swap partition being harmful for SSDs (as opposed to a file), but is that something to be concerned about for, say, my laptop with 8GB RAM?
Yes, technically any write operation = bad for SSD = each write reduce it’s lifespan.
Personally i would not use swap for 8 Gb RAM, unless you need to hibernate or do something very heavy routinely…
With 4 Gb i would think about it maybe
That’s pretty much how I think about swap. With 16 GB RAM, it’s unlikely you’ll ever need it in normal usage. And if you do happen to need it, making a swapfile is literally 10 seconds of work (and waiting maybe 5 minutes for
dd to do its magic and copy zeroes to it). Or, if you don’t need swap, but are really paranoid about running out of memory, you can set up systemd swap.
If you want to hibernate, you need swap, of course. A swap partition is easier to setup for hibernation, but a swap file will always be more flexible.
I’ve got 5 GB of RAM on my laptop, and it needs swap. I made a 7 GiB swapfile for it, just so it can hibernate without any worries. It’s a bit wasteful, but I’ve got a 2 TiB HDD in it, so I don’t care.
But I do notice it writing to the swapfile from time to time, even in normal usage (when opening more than a couple of tabs in Firefox, for example). Not very often, and it rarely uses over 500 MiB of swap, but it does use it.
If it bothers you, try to override default (too aggressive in my opinion) settings:
It does not bother me, as it is really rare. But I did set swappiness to 10 on it a long time ago (when I was testing those performance tweaks by librewish). Didn’t notice any difference, to be honest
(hmm, my system’s currently set up to hibernate soon after closing the lid…)
In that case, is a swap partition any more detrimental than a swap file? I’d be inclined to try replacing my swap partition with a file if it’ll extend the lifetime of my SSD.
It makes no difference for SSD’s longevity whether you write to a file or a swap partition. Writing is writing.
You may also want to read about Zram/zswap
I’m not really 100% sure to be honest. @keybreak said about what I’ve read, although I do don’t exactly understand it. Basically since you partition it it will always write to the exact same block which is fine on spinning rust, but not ideal for an SSD. Although I’m not sure why that wouldn’t also be true with a swap file,I don’t know. But that’s what i read on the internet, so I know it’s gotta be true, even if I don’t understand it.
My other computer has a swap partition on a Samsung Evo 850 SSD. I’m going to leave it and see how long it goes before the HD fails. It’s been there since May 1, so I’ll let you know when it fails.
Well either way they’ll wear SSD about the same, coz however you look at it - it’s still a part of disk which physically writes, regardless if it is partition or file…
I doubt there is some drastic difference…
Samsung SSDs are best ones, hopefully it will live for years and years
Please correct me if I am wrong, but today’s SSDs will survive several hundred TBs (or more) worth of writing. For a swap partition/file that at any rate will seldom or rarely be used, I wouldn’t think there is so much to worry about the disk’s longevity. It very well might fail for other reasons than having a swap partition/file set up, hibernating included. I can’t see a scenario when a user hibernates so many times during a day and then writing many GB data to the disk each time. That is not my use case anyway.
Depends on system / tasks at hand (for example if you use Android studio routinely ), but to me it is just completely excluding most obvious possible point of failure - which is always good.
1 Tb may be way faster than you probably think, with some setups and use cases - you’d be surprised
For example after analyzing disk writes on Windows back in a day - i always disable Firefox’s disk cache (again, you’d be very surprised it’s daily writes), and you don’t really need it if you have enough RAM.
At the end of the day, the use case is then a far more important factor when it comes to a disk longevity than the “evils” of a swap file/partition “per se”.
As an average user, who doesn’t strain my systems that much, I wouldn’t think swapping is something to worry about.
Actually, if I don’t think I need hibernation I set up an small amount of zram for just in case the kernel is in dire need to move some files out of the way.
For the most part yes, but you know…
If you’re thinking about mitigation of risks
Imagine that you left some program in the night and gone to sleep, on the next morning you see that it’s memory-leaking like crazy (think of Deepin for example ) and you have additional i don’t know…30 Tb written by your swap
Is it rare?
Is it possible?
Swap is for punks: “live fast - die young!”
P.S. Never trust robots
That would be an extreme and a rare occurrence. It is possible, yes. But how probable?
But I do get your point. If it is possible that anything exists at all, rather than nothing, then everything is possible.
ps. I hadn’t really thought of swap as a philosophical issue…hmm…
That would be my guess, but I figured, it’s easier to setup and I’m willing to buy another SSD is it fails withina couple of years. Let’s see if this whole thing holds any water.