Swapfile and RAM

  • I’ve been using Manjaro as My daily drive OS for 6 months now, and I will buy a laptop within two days.
    the laptop has built-in 8 GB RAM, so I can’t upgrade it.
  • usually, I use less than 8 GB of RAM but sometimes I use more than 8 GB, but not exceeding 10 GB

Can I use a 10GB swap file on the SSD to solve the RAM problem?

  • I searched for if the swapfile will damage the SSD, and I found that it’s not that harmful, is that true?
  • please help me make the decision because the purchase will be ensured tomorrow and I can buy the 16GB version
1 Like

Personally I’d just go for the 16GB one.

However, if for whatever reason, that’s not possible, 8GB, with say another 8GB in swap should be fine.

The reason why it’s not optimal to use an SSD for SWAP is because an SSD has a limited number of read/writes for it’s lifetime, which should be fine for almost everyone. But SWAP puts extra strain on the drive because it’s extra reads & writes.

But you can adjust the swappiness to be less active, which is better for an SSD.

2 Likes

I think, in the long run you will thank yourself for paying the litte bit more for the 16GB version.

7 Likes

Not as limited as some believe. My oldest SSD is ~10+ years old and has always had swap, it’s outlasted any HDD I’ve had (mostly because I don’t trust them after ~7+ years).

If I were you I’d go for the 16GB and 10GB swap on SSD.

2 Likes

Probably depends on the quality and/or brand then.

And yeah, I’ve had my latest SSD for ±2 years now, and if I’m correct, it’s 4% used:

Percentage Used:                    4%
2 Likes

I have two laptops, one is about 2014 era and the other 2018. They both have reasonable specs for their age and both have 4gb ram. I also created an equivilante size swap partition on both, as the norm when installing. I have yet to see either one of these machines use the swap. I also don’t allow them to suspend or hibernate. There either on or off.

2 Likes

Sounds like me.

2 Likes

Without reading the other replies, i feel i have to inform you of a fact you likely don’t know:

  1. A swapfile, or swap partition, will NOT increase your RAM, in case you want to run applications that need more memory.
  2. A swap(file/partition) is only used to switch memory to a storage device, when that memory is not needed at some point while the system needs some extra memory.
  3. Because of the above your SSD will be used to write MORE-OFTEN at those times, and thus will decrease it’s life-time.
    Thus it can be harmful

I personally would never suggest to use any SSD as swap because it’s to expensive for that usage…
But you might be richer as the average person :woman_shrugging: :stuck_out_tongue_winking_eye:
:vulcan_salute:

1 Like

Yes, I’m very rich :rofl: :rofl:
Thank you, I’m so grateful for you all.
I decided to buy another laptop but it’s not a new laptop, it’s used, but guess what, it’s 24GB of RAM.

The fear mongering about the SSD lifespan is not justified, especially nowadays. It is true that a SWAP file will read/write more on the SSD, but you’ll not kill your SSD by having SWAP on it. Using a web browser intensively would not be better/worst than having a SWAP file. For example Windows defaults to having a SWAP file (it is called the Page File), Windows does not kill SSD. They are made to have data written to them, A LOT of data (unless you got a cheap no name Chinese one from 10 years ago).

//EDIT: you can just check the SMART properties from the SSD, and see how it doesn’t reduce its lifespan after a month/year of usage with SWAP on it. If you see the lifespan reducing, you can still ask if it seems normal or not later on the forum. Don’t be afraid, unless you do specific idiotic things intended to destroy a SSD, you’ll not destroy a SSD.

8 Likes

Yes, it’s just gonna contribute to the wear level of your SSD everytime the swap is used.

Certainly the 16GB version. That’s my current amount of RAM and sometimes my workload passes it and the swap is used. Of course we might have a different workload but eventually the 16GB will last you a longer time, especially if the laptop you choose only has soldered RAM with no expansion slot.

1 Like

Not too worry:

Use zram which creates a compressed portion of RAM.
If that’s not enough you can set up zswap which uses a copressed swap space. But it’s a bit more complicated.
Both things can be found in the Arch Wiki.

1 Like

I have a laptop with 8GB RAM and I did have sometimes problem, when system was out of RAM (system was frozen).

It all ended when I decided to move to swap file using swapspace (AUR).

I also added zramswap, but didn’t notice any difference. However, both swapspace (needs to be configured after installation) and zramswap work fine - all freezing problems went away. Whenever I need more RAM, the system automatically and dynamically adds more swap file.

I recall also tweaking some swap settings. Don’t remember what exactly, because this was years ago.

1 Like

Ah, forgot to add, that I assume, you have SSD, then swapfile will work fine. With HDD, it will be horribly slow and lagging.

In theory, on a SDD, when swapfile app is adding swap, there could be some short-timed freeze, but I didn’t notice them , however I have M2 SSD. With SATA SSD there may be some freezes for a few seconds, but that is still a good tradeoff IMO.

Anyway, the better SSD you have, the better swapfile will work.

I second,third,integer some others here that the fragility of SSDs is rather overblown.
SSDs have become more robust and reliable, much more so, than the first generation.
Generally speaking … even if you R/W gigs of data every day … it could still take a decade or more to wear out the lifespan of the SSD. For most users, in most cases, the drive will be abandoned or replaced long before it hits maximum R/W.
If you really want to minimize R/W, then you can tune swappiness and other variables … some generally good optimizations will also have the side-effect of reducing this, such as keeping browser profiles in tmpfs (RAM) … but please dont use the lifespan argument to justify avoiding swap entirely.