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.
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.
zram-size = min(ram, 16384)
zram-fraction = 1
max-zram-size = none
How do I apply the changes? If I run sudo systemctl restart swap-create@zram0 I get this error:
Failed to restart email@example.com: Unit firstname.lastname@example.org 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
email@example.com 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.
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.