Which swap option do you use?

3x 4GB partitions striped across 3 SSDs for a total of 12GB swap, and 16GB ram.

Anyone ever used a swap partition and a swapfile at the same time?

no, but I dont see why you couldnt in so far as you are OK having multiple swap.
(also note priorities of each swap mount if useful)

That’s what I was thinking, just popped into my head and was wondering if anyone had tried it. :slight_smile:

12gb RAM which almost always gets full, using systemd-swap.

Only 8GB here (max on this system unfortunately) and it’s usually heavily loaded. The browser is the biggest memory hog, in particular when viewing YouTube videos, but I always have watch -n5 free -h running on one of the Terminal tabs to keep an eye on things & restart the browser when necessary, esp. when I’m running virtual machines.

I have a 10GB swap partition & performance starts to suffer when it gets around half full, which is to be expected.

Because my system has 32GiB RAM, i’m not using any physical swap at all.
I make use of Improved zramswap for an in-memory swap…

Swap partition, since btrfs doesn’t support swap file. But I think swap partition is superior after all. It doesn’t have the overhead of another filesystem on top of it and dedicated partition means it won’t interfere with other partitions. systemd-swap looks like a nice option, I’m just too lazy to set it up. If it finally joins systemd project officially, I might switch to it.

2 Likes

It’s actually the other way around IIRC, and that only for suspend/resume/hibernate :wink:

It is not an official part of systemd not even planned AFAIK, the name made me think so also in first place but it is just a user made utility :wink:

I agree on those points. Probably a hangover from my Windows days but in that case, having all “cache-type” stuff in its own partition radically reduced fragmentation on the NTFS filesystems … I don’t know if there is any benefit for Linux filesystems (e.g. ext4 which I use) in this regard, though.

It does avoid unexpected filling of the partition a swap file may be on.

1 Like

Option 1 here, classic swap partition even though my pc never touched it once as far as I can tell xD
I do have only 8gb of ram but my pc it’s not that powerful so I don’t find myself in heavy load situations very often… even when I game I rarely use more than 5gb, so yeah
It is there though, whenever I’ll need it xD

If a laptop, you might need it for hibernation in event of a low battery … :wink:

Same here. In fact, I’ve never done it.

I’ve kept whatever was selected by default when installing and don’t really worry or care more than that.

Yeah I forgot about hibernation!
I rarely use it but still, can be really useful in certain situations
Good call :joy:

1 Like

Hi !
I use systemd-swap on all my installs, whatever RAM size.
Even if a partition might be a little faster, not having to care about partition size and not having a permanent fixed space toll pleases me.
In addition, I suspect zswap of being efficient :wink:
I also setup swappiness so as to maximize RAM usage.
Systemd-swap insists on zram & zswap being mutually exclusive (zram never improved my systems)

[sum@ordi1 ~]$ sudo swapon -s
Nom de fichier				Type		Taille	Utilisé	Priorité
/var/lib/systemd-swap/swapfc/1         	file    	262140	0	50
[sum@ordi1 ~]$ cat /etc/systemd/swap.conf.d/overrides.conf
swapfc_enabled=1
swapfc_min_count=1
[sum@ordi1 ~]$ cat /proc/sys/vm/swappiness
5
[sum@ordi1 ~]$ cat /proc/sys/vm/vfs_cache_pressure
50
[sum@ordi1 ~]$

Btw, swap is always needed :

I made a french tutorial on systemd-swap setup (easily translatable):

2 Likes

Ah, but in this case, you still have to allow for space which might be needed for swap. Otherwise you might end up in a pickle :wink:

1 Like

You’re right, even if practice showed very small use (I once saw four 256 Mo files) and that I have plenty room:

[sum@ordi1 ~]$ sudo df -Th
Sys. de fichiers Type     Taille Utilisé Dispo Uti% Monté sur
dev              devtmpfs   5,8G       0  5,8G   0% /dev
run              tmpfs      5,8G    1,4M  5,8G   1% /run
/dev/sda2        ext4        96G     32G   59G  36% /
tmpfs            tmpfs      5,8G    201M  5,6G   4% /dev/shm
tmpfs            tmpfs      4,0M       0  4,0M   0% /sys/fs/cgroup
none             tmpfs      5,8G     49M  5,7G   1% /tmp
/dev/sda1        vfat       247M    278K  246M   1% /boot/efi
/dev/sda3        ext4       820G    409G  370G  53% /home
tmpfs            tmpfs      1,2G    148K  1,2G   1% /run/user/1000
[sum@ordi1 ~]$ 

Could also link to /home if needed.

Zswap should be used on 12gb or more ram, however i got good results on 8gb systems zswap - Wikipedia

1 Like

I’ve had good results down to 4Gb DDR3 :wink:
It’s also true that more RAM is a massive performance & confort parameter on a Linux desktop.

Here my system with systemd-swap:

[me@ordi1 ~]$ free
              total       utilisé      libre     partagé tamp/cache   disponible
Mem:          11756        5645         370        1191        5740        4611
Partition d'échange:         767         493         274
[me@ordi1 ~]$ sudo swapon -s
Nom de fichier				Type		Taille	Utilisé	Priorité
/var/lib/systemd-swap/swapfc/1         	file    	262140	262140	50
/var/lib/systemd-swap/swapfc/2         	file    	262140	242880	49
/var/lib/systemd-swap/swapfc/3         	file    	262140	0	48
[me@ordi1 ~]$ cat /proc/sys/vm/swappiness
5
[me@ordi1 ~]$ 

I have always used a swap partition on a hard disk device.

However my main system is old, circa 2008, with just 4GB RAM and a netbook with 2GB RAM neither of which is enough these days and they get slow when swapping to disk, so I would like to consider a faster option, zswap perhaps or systemd-swap which I have not looked into yet and they would need to support sleep and hibernate.

Then your only option is a faster HD…