I’ve recently upgraded from a low-end Intel system to a high-end AMD machine, moving over the same SSD to the new computer without formatting or reinstalling Fedora. I only removed the manually installed intel-media-driver package and assumed that Linux handles everything else.
htop shows that the swap space appears to be constantly “maxed out”, running free -h confirms this:
total used free shared buff/cache available
Mem: 27Gi 14Gi 299Mi 9.6Gi 12Gi 2.8Gi
Swap: 8.0Gi 8.0Gi 0B
The former machine had 8GB of RAM (4/4GB split between the iGU and OS as I understood), the current has 32GB (DDR4 @ 3600mhz). A 2020 opensource.com article recommends setting the swap at ‘0.5 times the amount of RAM’ (for 8GB - 64GB), but the Btrfs filesystem (the Fedora default since the release 33) isn’t mentioned and the instructions are for ext4.
I haven’t found current information for Fedora. Reinstalling the system is one solution and may be worthwhile in any case, but will take a lot of time to set up everything again.
Fedora is using zram, not traditional swap in most cases.
That being said, you shouldn’t need swap at 50% of your RAM for most desktop applications.
Adding more ram shouldn’t be consuming more swap.
You seem to be consuming a lot of memory there with only 2.8 GiB available. Are you running memory intensive workloads? If not, it looks like something is wrong there to me.
You can see the actual usage of swap with the command zramctl.
My system is 32G RAM constantly running at 30 - 50% cpu usage with 2 VMs and this is the output of my swap
# zramctl
NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo-rle 8G 3.3G 1.2G 1.2G 12 [SWAP]
As you can see I have the standard 8G of zram, in which 3.3G swap data is compressed into an occupied 1.2G actual space.
That can easily be modified to change the size of the created zram0 swap device.
It is also easy to manually create a swap device on disk if you are set of moving from virtual swap to physical.
BTW, one suggestion above is to remove the defaults package for the zram generator. IMHO that is not required since it only establishes a default config for a new system and the changes you make later are not affected in any way by updates.
I see from that that usage of swap (with 16 threads) is almost maxed out. After making that change to the generator file, did you reboot?
If you did then running zramctl again should show the new size of the swap and it should be ~14G from what the output of ‘free’ showed.
Hi everyone, I want to increase zram size.
I followed the steps in this post.
My /etc/systemd//zram-generator.conf file has this content:
# This config file enables a /dev/zram0 device with the default settings:
# — size — same as available RAM or 8GB, whichever is less
# — compression — most likely lzo-rle
#
# To disable, uninstall zram-generator-defaults or create empty
# /etc/systemd/zram-generator.conf file.
[zram0]
zram-size = min(ram, 16384)
zram-fraction = 1
max-zram-size = none
compression-algorithm=zstd
How do I apply the changes? If I run sudo systemctl restart swap-create@zram0 I get this error:
Failed to restart swap-create@zram0.service: Unit swap-create@zram0.service not found.
Try systemctl with an available service. On my system I have this.
# systemctl list-units | grep zram
sys-devices-virtual-block-zram0.device loaded active plugged /sys/devices/virtual/block/zram0
systemd-zram-setup@zram0.service loaded active exited Create swap on /dev/zram0
system-systemd\x2dzram\x2dsetup.slice loaded active active Slice /system/systemd-zram-setup
dev-zram0.swap loaded active active Compressed Swap on /dev/zram0
and my /etc/sytemd/zram-generator.conf has only this.
[zram0]
max-zram-size=8192
zram-fraction=1.0
I also think you will need to reboot to change the size of the existing zram0 swap space.
There is also a file /usr/lib/systemd/zram-generator.conf that has an affect on that.