Swap file does not seem to work properly after manually making partitions and installing Fedora 38

I have only 4GB of Ram and I added 10 GB of Swap. From my tests the system kind of freezes when the 4 GB are almost fully used. How can I make absolute sure the Swap is properly enables to be used by my Fedoa 38 installation?
Thank you!

The relevant how-to and Btrfs-specific instruction should apply here as well.

For a beginner the instructions there are majorly lacking.
I do not know if the Swap file that I said was created when I manually made partitions before actually installing Fedora 38 needs to have or not a mount point before activating it.
Kde Partition Managers seems to show there is no mount point existing for the Swap file that was created then.
the command “# swapon /swapfile” can not work because I don’t have anything like /swapfile on my partitions.
What do I need to change to fit my actual context? Thanks!

That’s confusing, try collecting the output

lsblk -o +FSTYPE
grep -v -e "^#" -e "^$" /etc/fstab
sudo swapon -s
sudo ls -l -a -h /

Well I’m the one that’s confused by what you’re asking me to do.
What do commands 1,2,4 do?
Do I just paste all 4 commands in one go and wait for some output?

Each command is separate and should be entered by itself
The commands will provide info that we need to assist.

post the output of each command and its result here as preformatted text using the </> button on the toolbar.

1 Like

BTW, experimenting for yourself and using the man pages for those commands will provide a lot of training experience.

Just an example of the use of command #2 on my system

$ grep -v -e "^#" -e "^$" /etc/fstab
/dev/mapper/fedora-root /                            ext4    defaults,noatime        1 1
UUID=dfeb394f-2d5c-4ff4-a974-105d8551d0a4 /boot      ext4    defaults,noatime        1 2
UUID=9CF6-618E          /boot/efi         vfat    umask=0077,shortname=winnt,noatime 0 2
/dev/mapper/fedora_raid1-home /home                  ext4    defaults                1 2
UUID=3cde1bc1-8248-4c2c-bbb2-9198dfc2f226 /mnt/backup    ext4    defaults            1 2


$ cat /etc/fstab

# /etc/fstab
# Created by anaconda on Tue May  9 10:46:11 2023
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
/dev/mapper/fedora-root /                            ext4    defaults,noatime        1 1
UUID=dfeb394f-2d5c-4ff4-a974-105d8551d0a4 /boot      ext4    defaults,noatime        1 2
UUID=9CF6-618E          /boot/efi         vfat    umask=0077,shortname=winnt,noatime 0 2
/dev/mapper/fedora_raid1-home /home                  ext4    defaults                1 2
UUID=3cde1bc1-8248-4c2c-bbb2-9198dfc2f226 /mnt/backup    ext4    defaults            1 2

sda 8:0 0 298.1G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi vfat
├─sda2 8:2 0 20G 0 part ext4
├─sda3 8:3 0 512M 0 part /boot ext4
├─sda4 8:4 0 30G 0 part /home xfs
├─sda5 8:5 0 22G 0 part / xfs
├─sda6 8:6 0 10G 0 part [SWAP] swap
└─sda8 8:8 0 215.1G 0 part /mnt/olderul ext4
sdb 8:16 0 1.8T 0 disk
└─sdb1 8:17 0 1.1T 0 part ntfs
sdc 8:32 0 1.8T 0 disk
└─sdc1 8:33 0 1.8T 0 part ext4
zram0 252:0 0 8G 0 disk [SWAP]

Blockquote $ grep -v -e “^#” -e “^$” /etc/fstab
UUID=9d1f8461-7bfa-438b-981c-7c71b6b2d491 / xfs defaults 0 0
UUID=070b13bf-737a-4fb5-960b-218b6c22a565 /boot ext4 defaults 1 2
UUID=BF32-EF14 /boot/efi vfat umask=0077,shortname=winnt 0 2
UUID=d85011b7-35f5-4c78-a31a-5396cae69348 /home xfs defaults 0 0
UUID=b2c78648-3aff-4c6c-8c27-7b3bfc7e73e1 none swap defaults 0 0
UUID=7b0930ae-5b84-48c3-9698-1f964aa6522e /mnt/olderul ext4 defaults 0 0

Blockquote sudo swapon -s
[sudo] password for blah:
Filename Type Size Used Priority
/dev/zram0 partition 8388604 46336 100
/dev/sda6 partition 10485756 0 -2

Blockquote sudo ls -l -a -h /
total 32K
dr-xr-xr-x. 21 root root 4.0K Jul 27 23:25 .
dr-xr-xr-x. 21 root root 4.0K Jul 27 23:25 …
dr-xr-xr-x. 2 root root 6 Jan 19 2023 afs
lrwxrwxrwx. 1 root root 7 Jan 19 2023 bin → usr/bin
dr-xr-xr-x. 6 root root 4.0K Jul 27 20:41 boot
drwxr-xr-x. 2 root root 46 Jul 27 19:43 .config
drwxr-xr-x. 20 root root 4.3K Sep 1 18:40 dev
drwxr-xr-x. 149 root root 8.0K Aug 24 19:51 etc
-rw-r–r–. 1 root root 0 Jul 27 23:21 .hcwd
drwxr-xr-x. 3 root root 18 Jul 27 19:39 home
lrwxrwxrwx. 1 root root 7 Jan 19 2023 lib → usr/lib
lrwxrwxrwx. 1 root root 9 Jan 19 2023 lib64 → usr/lib64
drwx------. 2 root root 6 Apr 14 00:40 lost+found
drwxr-xr-x. 2 root root 6 Jan 19 2023 media
drwxr-xr-x. 3 root root 21 Jul 28 00:41 mnt
drwxr-xr-x. 2 root root 6 Jul 27 23:25 none
drwxr-xr-x. 3 root root 21 Jul 30 19:16 opt
dr-xr-xr-x. 322 root root 0 Sep 1 18:40 proc
dr-xr-x—. 7 root root 4.0K Jul 27 19:43 root
drwxr-xr-x. 48 root root 1.4K Sep 1 20:01 run
lrwxrwxrwx. 1 root root 8 Jan 19 2023 sbin → usr/sbin
drwxr-xr-x. 2 root root 6 Jan 19 2023 srv
dr-xr-xr-x. 13 root root 0 Sep 1 18:40 sys
drwxrwxrwt. 17 root root 400 Sep 1 21:53 tmp
drwxr-xr-x. 12 root root 144 Apr 14 00:43 usr
drwxr-xr-x. 20 root root 4.0K Apr 14 00:48 var

You don’t need a swap file since you already have a 10 GB swap partition /dev/sda6 that is mounted, but currently unused.

In addition, the size of /dev/zram0 indicates that you have at least 8 GB of RAM.

If zram is working incorrectly, you can try disabling it to isolate the issue.

Hello @daosans ,
If you type swapon -l in a terminal, it will show you how your system is currently using swap. If you have 8GB, your swap should be okay as zram, but you can disable it and use just your partitioned swap.

The correct option is not -l but -s, and you can check the output above.

Right you are, even after I typed myself I still picked -l!

Please tell me how to activate the Swap file. What is the precise instruction?

Please give me the precise instruction to do that. I want to ALSO use the swap file.
Is Zram my actual Ram capacity that I can currently use? Thank you!

As per this output you posted above from the swapon -s command …

Filename Type Size Used Priority
/dev/zram0 partition 8388604 46336 100
/dev/sda6 partition 10485756 0 -2

You can use sudo swapoff /dev/zram0 to turn off the zram swap. Also if you check what priority is higher larger number or smaller, then you can raise the priority level of your physical disk swap partition.

Why am obligated to disable Zram Swap? Isn’t Zram my actual ram? I have just one Swap that is 10 GB.
KDE Partition Manager does not show any other swap.
What is “zram swap”?
I only want to enable my 10 GB Swap and I do not know what precise command to type to do that.
Please tell me the command that is not generic/hypothetical but actually works on my actual system. Thank you.

The default swap used by fedora is zram, which is part of the installed ram and is virtual swap.
Adding a physical swap partition merely adds to the total swap available and does not disable the zram device.

To disable zram and use only the physical swap device you must first have the physical device identified in /etc/fstab so it loads on boot.
You also would need to modify the config for the zram to prevent creating the zram0 device and using that for swap.

I personally do not know the commands since I have never done so but information is available with the man command for ‘zramctl’, ‘zram-generator’ and 'zram-generator.conf`. The files that control that are referenced in the man page for the conf file.

You should be aware that disabling the zram device and using only a physical swap device may have 2 negative consequences.

  1. Speed of access to swap. A physical device is slower than ram access, and especially so if using a HDD. The cpu is directly connected to ram, and must use other paths to access a physical storage device. This, coupled with device read/write times make swap access times add up when using a physical swap device.

  2. Potential damage or early wear on the physical device. This is normally not a factor on HDD, but if using an SSD or NVME device for swap the extra writes that occur may cause earlier failure than otherwise would occur. I have seen it recommended to avoid using SSD or NVME devices for swap.

Swapoff turns off the swap, so swapon turns on the swap. Try man swapon for details on how to use it.

Your output of “swapon -s” shows that /dev/sda6 is in use with low priority, and /dev/zram0 with high priority.
zram uses cpu power to compress memory contents which is intended for swap, but keeps it in memory, resulting in net gain in RAM memory. If zram is no longer able to do this, the low priority swap device is used.

So your configuration is fine and should be working. The command “top” shows live the total swap and swap usage, plus a process list which can be sorted to memory usage after typing “m”.

In your case it should show 18G total. Only the reported zram space does not match the 4M memory in the first post. The actual amount of RAM is reported by “top” too as “MiB Mem”. zram size is default ram size with a maximum of 8G