Swap with SSDs can cause issues with hardware degradation?

I stlll use a swap partition but after reading following I’m not sure if it’s realy needed with SSD & 16 GB RAM … so swap or not to swap?

Warning: Although swap is generally recommended for systems using traditional spinning hard drives, using swap with SSDs can cause issues with hardware degradation over time.

source:

Operating System: EndeavourOS
KDE Plasma Version: 5.21.1
KDE Frameworks Version: 5.79.0
Qt Version: 5.15.2
Kernel Version: 5.10.19-1-lts
OS Type: 64-bit
Graphics Platform: X11
Processors: 8 × AMD FX™-8350 Eight-Core Processor
Memory: 15.6 GiB of RAM
Graphics Processor: GeForce GT 630/PCIe/SSE2

That’s frequently asked question :upside_down_face:

or other ones here
https://forum.endeavouros.com/search?q=ssd%20swap


My opinion - don’t, coz there’s no need to with 16 Gb of RAM.

3 Likes

My opinion is quite the opposite. Back in the spinning disk days, I often ran systems without swap because the performance penalty was so high that I was often willing to risk the system crashing.

Since SSDs are so much faster, it makes sense again.

Whether you use swap or not is a matter of personal preference and depends what your workload looks like. Just consider what happens when you run out of memory. Unless you running some kind of OOM manager, stuff just starts failing all over the place and/or your system crashes.

Since most modern SSDs have sophisticated wear leveling the risks to having a swap partition are likely fairly minimal.

If you really want to avoid swapping to your SSD, I would implement zram. This moves your swap into a compressed area in RAM.

5 Likes
lsof +r2 | grep ~/.cache

and what is about other folders on the SSD? like .cache? I think there are many more writes on .cache than into swap, I could be wrong… but if you have a big amount of RAM swap will not be used that often, but on stuff like browsing with a browser there will be a lot read and writes on cache and tmp.

2 Likes

Unless you’re doing a LOT of swapping and have a really old generation SSD or a cheap QLC based SSD, it’s really not that much of a deal IMO. Modern TLC drives often have about a write per day guarnateed life. Most basic uses will come NOWHERE near this, so a few extra GB won’t mean much.

3 Likes

That doesn’t sound like a lot of data… :sweat_smile:

1 Like

I don’t know, the lowest most TLC drives go is .2 dwpd. On a 512GB, that means 100GB written EACH DAY, EVERY DAY, for 5 years is the guaranteed life (assuming you’re not buying the ULTRA cheap stuff that only has 3 year warranty). Put another way, that’s 35.6 TB of information written per year for 5 years on a MERE 512GB SSD. I don’t know about you, but I do not approach 100GB written on 99.99999999% of days. Even if I had swap enabled and set to be fairly swappy, I don’t think I’d approach 100GB written every day. And that’s the LOW end of TLC drives, so only goes up from there!!!

1 Like

Erm…I think that was intended to be joke that a single write per day is not a lot. :innocent:

2 Likes

I symlink the browser directories to a folder on my hdd. Saves ssd writes :wink:
I also do this for discord and vscode.

1 Like

I sometimes have difficulty understanding the concept of amount of data written. My SSD hit 1% use when I had written about 800GB data. I was doing android dev and saving device snapshots, building apk on my ssd. That made lots of writes.

so 1% = 0.8TB
then 100% = 80TB; meaning I can write upto 80TB data in total.
Is this reasoning correct?
mine is 256GB ssd.

also how do you find out the dwpd for your ssd?

sudo smartctl -A /dev/nvme0                                                     
[sudo] password for lain:
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.10.19-1-lts] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF SMART DATA SECTION ===
SMART/Health Information (NVMe Log 0x02)
Critical Warning:                   0x00
Temperature:                        30 Celsius
Available Spare:                    100%
Available Spare Threshold:          50%
Percentage Used:                    1% <------- This ------
Data Units Read:                    2,534,295 [1.29 TB]
Data Units Written:                 2,106,499 [1.07 TB]
Host Read Commands:                 36,021,486
Host Write Commands:                73,751,258
Controller Busy Time:               1,525
Power Cycles:                       403
Power On Hours:                     445
Unsafe Shutdowns:                   296
Media and Data Integrity Errors:    0
Error Information Log Entries:      0
Warning  Comp. Temperature Time:    0
Critical Comp. Temperature Time:    0
Temperature Sensor 1:               30 Celsius

Just do Data Units Written/# days since drive was put into service (or to be more technical for the warranty, days since warranty was activated)

1 Like

Comes out to 21.5GB/Day. Doesn’t it sound too low?

No, I’d say yours is SIGNIFICANTLY higher than mine. For instance on the laptop I’m on…

Data Units Written:                 2,932,894 [1.50 TB]

Yet this SSD is (a bit) over a year old, so my dwpd is something insanely small like 4GB/day. Which to be fair is actually more than I was expecting.

I guess we (or at least me) is getting confused again.

“Data units written” only measures the total data written during the life of SSD. My ssd has high value because while doing android dev in Jan, I used to save multiple snapshots a day, each snapshot about 3gb, and did builds also. I wrote a lot of data.

So dividing it by number of days used, gives the average data “you” (the user) wrote to it. Its not what it has been rated at. Do I make sense?

OH…you meant how do you find out the RATED DWPD!! I thought you were asking how do you find your dwpd that you’ve been actually using. MOST manufacturers publish this information on the drives technical page. A few of the lower end 3rd party don’t, but generally all the 1st party and first tier 3rd party distributors do.

Such as, the drive for my T14: https://www.adata.com/upload/downloadfile/Datasheet_XPG%20SX8200%20Pro_EN_20190719.pdf

On the last page:

640TBW (I have the 1TB) over the 5 year warrantied lifetime of the drive means it has a dwpd of 359GB

2 Likes

“To swap or not” …that is the question. :thinking:

I do swap file. :yum:

I have tried a lot of different ways of handling swap - and so far I have settled on having it there, and never having it put into use!

I’m at about 36GB daily writes. At this rate, my 1TB SSD would last me 48 years.
I am using swap on my SSD from day one, even if the machine has 32GB RAM installed.
I’d say SSD wear is somewhat overemphasized. Just check your usage numbers an judge for yourself.

2 Likes

This is how I look at it. At the rate I write, my warranties will LONG be over and probably the electrical portions of the drive will start failing before I start suffering from nand wear issues.

1 Like

I swap. Mainly because I use a laptop and use hibernate. I have 40gb of RAM but only a 20GB swap. I figured in all reality I rarely use more than 20gb at any time so I’ll still be able to hibernate. If I’m working on something requiring more ram than that, I’m probably way to busy to stop, so I still wouldn’t need more.

Point I was really making, if you plan to hibernate, swap is necessary.

Will it be a problem later? I guess I’ll find out. I’ve not had an SSD fail on me except for a kingston drive that came DOA.