Is swap recommended for a 4gb ram pc?If yes what is the recommended size?


New Member
Jul 22, 2022
Reaction score
I have installed linux in my old pc.It has 4 gb ddr3 ram.Should i create a swap partition?I will be happy to know the recommended size.

It depends which Distro are you using? If it's a laptop I would set aside about 2 to 4 gbs swap for suspend and hibernate if you use them. If not with most distros today there is little need for a separate swap partition. One of the old rules of thumb was a swap 1/2 the size of installed ram. Some Distro use swap files in the root / partition as a swap area.
I'd recommend it. I'd recommend it regardless of how much RAM you have. Swap isn't just some place the kernel stuffs things when the RAM is running out.

free -m
              total        used        free      shared  buff/cache   available
Mem:          15905       12964         756        1028        2185        1585
Swap:          2047        1769         278
What KGill says. "Old PC" suggests "old rule" which was 2xRAM for swap space. My view is to let the kernel have the room to be as efficient as possible. The kernel is generally smarter than the user. Increasing the RAM size itself is a great benefit to the computer, so I'd do that if possible ... and still run 2xRAM if I could, though in the past I've increased RAM but left the swap space as it was because it was inconvenient to increase it.
Use zram instead of a swap file. It works much better on low-end hardware.
               total        used        free      shared  buff/cache   available
Mem:            3793        2122         697         312         973        1281
Swap:           4095        1056        3039
Total:          7889        3179        3737

Staff online