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.
It’s actually the other way around IIRC, and that only for suspend/resume/hibernate
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
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.
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 …
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
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
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):
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
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
I’ve had good results down to 4Gb DDR3
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…
I’m using zram:
free -h
total used free shared buff/cache available
Mem: 15Gi 1,6Gi 12Gi 440Mi 1,8Gi 10Gi
Swap: 7,8Gi 0B 7,8Gi
In /etc/sysctl.d/99-sysctl_tweaks.conf
I set vm.swappiness=1
because, having 16 GB of RAM, also when I attempt to saturate the RAM (lot of tabs in browser and also a lot of tabs in SublimeText, lot of applications opened), and so on, I rarely see swap usage; the funny thing is that, when swap is used, it reach at maximum 10MB; I also noticed that swap is used when the valute “buff/cache” reach 13GB.
I don’t use/I have disabled the suspend to disk; I use suspend to ram.
I don’t understand the meaning of this fact: when the swap is used, it reach a ridicolous size (as I’ve said about 10MB), when I expecting that the available RAM should be used instead.
@cscs how do you managed to avoid swap usage? I also tried to set vm.swappiness to 0, but didn’t change this behaviour.
EDIT:
I opened a discussion about, for avoiding to go offtopic here.
I wonder if there is another option to add to the list and that is:
Option 5)
- Swap on video RAM
as explained here Swap on video RAM - ArchWiki
Additionally as many have a graphics card installed the motherboard built in graphics processor goes unused (I presume) it seems a pity it could not be utilised in some way, perhaps as swap memory?
That kind uses the system’s RAM for the GPU…
Thanks, I was not aware of that as I’ve never previously looked into it.
Well … theres almost no one that wants to use that.
I mean … maybe if for some reason you have very little RAM, but a beefy GPU you never use … then it could make sense. But thats just about never the case.
Like these quotes from that page:
In the unlikely case that you have very little RAM and a surplus of video RAM, you can use the latter as swap.
A graphics card with GDDR SDRAM or DDR SDRAM may be used as swap by using the MTD subsystem of the kernel. Systems with dedicated graphics memory of 256 MB or greater which also have limited amounts of system memory (DDR SDRAM) may benefit the most from this type of setup.
Warning: Unless your graphics driver can be made to use less ram than is detected, Xorg may crash when you try to use the same section of RAM to store textures as swap. Using a video driver that allows you to override videoram should increase stability.
So … I have yet to encounter anyone actually making use of this.
Now that seems odd. Thats not how your system should work.
Normally if someone has iGPU+dGPU the integrated (weaker) card is used by default, then you call the dedicated (stronger) card when you need it … for example a steam games launch options:
prime-run %command%
…some people have too much trouble with such a setup or get confused or simply dont care about the power draw and want their dedicated card on all the time.
This is not usually the preferred method … and without an easy switch in BIOS … it requires some extra work to set.
But maybe in such an instance you could somehow use the ‘disabled’ card as SWAP … though I am not familiar with any such attempt.
This is not usually a safe setting.
But with 16gb … you might never reach it/care.
How did you enable and configure it?
As I showed above I am using a static swapfile.
This is mounted in fstab with a priority of -2.
(If you want some other values… vm.swappiness=10
vm.vfs_cache_pressure=50
)
And in case anyone is interested in a sort of automated tweaking of sysctl things … heres this: