Thoughts on setting up swap on SSD?

I have relatively good specs on my new laptop but only have 4gb of RAM. I thought of upgrading my RAM to improve multitasking but current conditions stop me from doing so (the pandemic + can’t afford to send this to the service center because I need it all week for schoolwork).

I’ve setup swap on my HDD but its really slow and causes slowdowns when the system swaps which is a big deal when clutching deadlines :joy: with multiple documents open and firefox tabs open. So I thought why not use a second swap on my SSD?

Now, I’ve read in several forums that setting up swap on SSD is not advisable since it can shorten its lifespan but I’ve noticed that these were from 5-10+ years ago. I’ve also read that newer SSDs lifespans have greatly increased since they are designed to do that memory cell distribution thing (?) so swap on SSD is actually a good choice.

I can’t seem to find a reliable source as most answers I’ve seen are conflicting (probably because of the year difference). I also haven’t seen documentation regarding this so I’d like to know your thoughts about swap on SSDs. Many thanks!

TLDR; is swap on newer SSDs advisable or not (considering RAM upgrade is not possible)?

Yes, swap on modern SSDs should be fine. Modern SSDs have wear leveling algorithms to help with situations like swap. In fact, I would argue that for desktop usage swap on HDD is not advisable due to the performance hit.

That being said, swap is a complicated subject and there are other approaches as well like zswap and zram which should be investigated.


Thanks for answering!

Could I ask for some information or links to guides regarding zswap and zram? I saw those options on the arch wiki but I think they weren’t explained properly :upside_down_face:

EDIT: There are documentations from the linux kernel but are too technical for me to understand :sweat_smile:

The Arch wiki is a pretty good reference but if you want something more detailed:

If you want something less detailed there is also the Majaro wiki page on swap which was mostly written by me:


Thank you very much! :smiley:

I’ll have a look at the Manjaro wiki page you wrote but I’ll skip on the one (see my edit lol)

1 Like

You might want to check up on swappiness as well:


Thank you! I actually have configured that one and am trying different swappiness values

1 Like

If you use a swap partition, it might make sense to add zswap on top of it (maybe via systemd-swap).


Would it not take up some more space of the already 4GB RAM? But perhaps it’s worth it?

Doesn’t SWAP rely more on RAM usage and how much RAM a system has than the type of Disk?

Yes, but it is compressed and usually results in better performance.

The amount of RAM you have can certainly have an impact on how often you are using your swap. However, the speed of the disk has a big impact on how fast that swap will be when you need to access it.


Regarding the famous swappiness value, and why it doesn’t have to be set to very low values, one should have a look at the documentation:

This control is used to define the rough relative IO cost of swapping
and filesystem paging, as a value between 0 and 200. At 100, the VM
assumes equal IO cost and will thus apply memory pressure to the page cache and swap-backed pages equally; lower values signify more
expensive swap IO, higher values indicates cheaper.

Keep in mind that filesystem IO patterns under memory pressure tend to be more efficient than swap’s random IO. An optimal value will require experimentation and will also be workload-dependent.

The default value is 60.

For in-memory swap, like zram or zswap, as well as hybrid setups that have swap on faster devices than the filesystem, values beyond 100 can be considered. For example, if the random IO against the swap device is on average 2x faster than IO from the filesystem, swappiness should
be 133 (x + 2x = 200, 2x = 133.33).

(I highlighted. Source:


Definetily worth it! I have a 2GB low-spec laptop that is actually pretty usable once zswap is set up.


Also ram is probably the easiest thing to fit yourself, no need to send to a service centre. Normally just open a small hatch on the bottom, click into place and it is done.

What make and model?

1 Like

if you look at youtube ‘arch conf 2020’ some explain also about swap…

would say, is like expansion tank of your home heater cv :slight_smile: but there is also different opions about it :slight_smile:

@anon31687413, thank you! That’s a very helpful insight on swappiness values :smiley: I’ll keep that in mind.

@xircon, it’s a Lenovo Ideapad S340-14IML. I did some research from the Lenovo website and there’s an empty slot for ram. However, I have some warranty concerns if I do it myself since I’m quite inexperienced with hardware and also left necessary tools like screwdrivers at the school dormitory :upside_down_face: So, I’ve decided to wait until break and bring this to them hehe.

@ringo, I’ll have a look at that one too, thanks! Don’t know or haven’t seen what home heaters are though ( I live in a hot country) :sweat_smile:

I agree. I actually learned about swap because I had to compile some things on a 1GB raspberry pi and in my experience has been very helpful.

1 Like

Depending on the size of your SSD, it should indeed handle a lot of writes.
The average 500GB drive is rated for 300TBW (total terabytes written over the lifetime of the disk). Although, it’s true, there are some models out there with 150TBW ratings.

I have configured dynamic swap on my SSD, and am hammering it exactly like I would use a HDD, including lots of torrents, VMs, copying large projects daily, etc.
*It’s worth noting this machine has 32GB ram, so swap usage is minimal, but you can test your machine for about a month and see the total writes increase

You can run sudo smartctl /dev/nvme0n1 -a to see your S.M.A.R.T. values and that would give you an idea about your usage patterns. (adjust the /dev/nvme0n1 part to match your drive’s path).

After 10 months of usage my 1TB SSD shows the following S.M.A.R.T. stats:

Namespace 1 Size/Capacity: [1,02 TB]
Namespace 1 Utilization:            793.123.688.448 [793 GB]

Available Spare:                    100%
Available Spare Threshold:          10%
Percentage Used:                    1%
Data Units Read:                    22.273.823 [11,4 TB]
Data Units Written:                 25.063.939 [12,8 TB]
Host Read Commands:                 256.546.416
Host Write Commands:                283.641.210
Controller Busy Time:               5.101
Power Cycles:                       699
Power On Hours:                     4.443

That’s 12 TB written over 10 month. Let’s say 15TB over a year to make the math easier. That would mean this SSD would use up the allotted 300TBW (although I was talking about the typical 500GB SSD with 300TBW, whereas my SSD is 1TB rated 640TBW) in 20 years. That’s at least 2 times more than I plan to use this machine.

Take the worst case of a 150TBW rated SSDs and it would still give it a 10 year run.

1 Like

I tried ZRAM , working good . Well I first used it in Garuda and thought it caused my system to consume more RAM , but it doesn’t . I don’t see performance drops . You can try that out , after all RAM is still faster than SSD :innocent:

Edit : ZRAM seems to compress 33% of data on RAM . That means if you turn off swap you will see your RAM usage increasing by half of the swapped content’s size . Till now I didn’t use swap because of privacy concerns and slow speed of swap when needed . But from now on I would like my system to swap , it’s definitely freeing up RAM :hugs:


Yes. That’s probably the reason why many Android devices come with zram swap.