My first Fedora 42 forced reboot

Yesterday I had to force a reboot on my Fedora 42 workstation (MATE desktop) for the first time. I do have nVidia card but its older card and works very well with the stock open source driver (I don’t game).

I didn’t post yesterday after it happened because I think I know what caused it, and I just wanted to wait to make sure it didn’t happen again.

Way back in the dark ages when dinosaurs still roamed the earth and CentOS 7.1 was new, I built this system. Two SSDs (one for distro / and one for LFS /) and two platter drives (one for /home and one for misc stuff like /usr/local and /opt/teXlive)

That misc stuff drive has a 64GB swap partition. When I installed Fedora 42, I forgot to add the swap partition to /etc/fstab and yesterday noticed, so I added it. The Fedora 42 /etc/fstab file has a warning to run systemctl daemon-reload after editing it and I did that and was planning to reboot but got distracted first by life and did not reboot and forgot to.

Hours later, after taking a nap, the system would not come back from from sleep. When that has happened before (not sure if ever happened in F42) turning a monitor off and on fixes it—I get the login screen. No such luck. However the disk activity light on my PC cash was pulsating like mad. This continued for quite some time until I forced a reboot.

When it rebooted, all works well, my swap partition is being used, and the issue did not repeat.

I suspect that the command systemctl daemon-reload caused systemd to think the swap partition had been activated when it hadn’t actually been activated yet, I never ran swapon or rebooted, and I suspect that when the system then went to sleep it tried to use the swap partition to write memory to disk but it couldn’t because the swap partition had never been activated.

Anyway, if that sounds plausible to the gurus, maybe there’s a bug in the power management software where it fails to verify that a swap partition in /etc/fstab is actually active before it tries to use it. It should have continued to use the swap file instead of the swap partition—assuming that’s what actually happened.

Today, no problems whatsoever waking up from sleep.

Quite possibly. There is a service systemd-suspend-then-hibernate that potentially tried to activate if systemd thought there was swap space to use for hibernation.

If added to fstab, but never activated, the problem could occur. You also may have an issue should the system actually hibernate but be unable to resume, since enabling hibernation requires an option in the kernel command line resume=.... that points to the physical swap partition so the previous stated can be recovered.

If the additional swap space is not actually required it is better to not have it enabled.

Do you now have both a swap file and a swap partition? swapon should tell you what is active or available.

For me, since fedora switched to using ZRAM for swap I have never needed a physical swap. (I do not hibernate my systems)

Yes, the swap file is still there at /dev/zram0

What’s kind of annoying is historically, the Red Hat / Fedora installer during install would detect swap partitions and just add them from the start but it seems the Fedora installer has experienced significant technical regression.

Okay, read Changes/SwapOnZRAM - Fedora Project Wiki and then read up on zram vs zswap vs swap partition.

Turned off the zram, I don’t want it, from that article it looks like it was chosen just because systemd offers it and it was an opportunity to experiment with something written in Rust which to be honest is a poor reason to do it.

Looks like zram is actually not compatible with hibernation. Laptops therefore shouldn’t use it as hibernation is particularly useful for laptops. Why it is now the default in Fedora is a question.

I’ll have to play with my setup (not a laptop) to see if I can get actual hibernation to work, I know I had actual hibernation working in CentOS 7. Looks like at a minimum I’ll have to add a kernel option that specifies the resume ID for the swap partition.

Change for the sake of change is something I’ve never been fond of. Ah well.

Zram is actually 100% compatible with hibernation, but cannot be the only swap used when hibernating. There must be a physical swap partition at least as large as system RAM in addition to the zram swap space before hibernation can be used.

Advantages to zram vs physical swap include much faster swapping since it only occurs in RAM as well as compressing the swapped data. The default 8GB of swap space can easily hold 16GB or more of actual swapped data.

AFAIK, up through f41 the installer still automatically would configure existing swap. With the switch to the newer installer it seems to not do so automatically, though the user can still do that by editing the storage config during install.

  1. use swapon to activate the swap partition
  2. edit fstab to add the swap partition. The partition UUID should probably be used here
  3. use swapon to deactivate zram then run the command shown in the linked document to disable zram if you wish to do so.
🔗 How can it be disabled?
Immediately:
sudo systemctl stop swap-create@zram0

Permanently:
sudo touch /etc/systemd/zram-generator.conf or sudo dnf remove zram-generator-defaults
  1. use grubby to add the resume option to the command line. That should be of the form sudo grubby --update-kernel-ALL --args=" resume=UUID " where the UUID is the one for the swap partition as shown with lsblk -f for that partition. The same UUID should be used in fstab for swap.
  2. it may be necessary to use dracut to finalize the config so the swap partition will always be active at boot (though I do not recall ever needing to do so.) As I recall adding the partition, activating it with swapon, plus adding it into fstab was enough to always start it at boot time.

But since it only occurs in RAM, doesn’t that take away from RAM available for other things?

I can see the value of it on systems with large amounts of memory and perhaps it even extends the life of an SSD if SSD is your only option for a file or partition swap.

What I don’t understand is why Fedora has decided to stop detecting existing swap partition during install and adding them to the fstab. They could still do the zram too, but if there is an existing swap partition, why not use it? It’s easy to detect during install as it uses a very specific partition type and if it exists, the user almost certainly wants it.

To a certain extent, but is flexible and only consumes the space needed for what has actually been moved to swap. A system with small amounts of ram (<8GB) might suffer, but most do not.

My server

$ free
               total        used        free      shared  buff/cache   available
Mem:        32777076    11781748      431560        8704    20026244    20995328
Swap:        8388604      988836     7399768

$ uptime
 17:18:31 up 24 days,  7:56,  3 users,  load average: 4.05, 4.04, 4.07

My desktop daily driver

$ free
               total        used        free      shared  buff/cache   available
Mem:        32773848    11838248     1303228      364912    20467224    20935600
Swap:        8388604       47120     8341484
$ uptime
 17:21:04 up 6 days, 21:48,  2 users,  load average: 4.22, 4.18, 4.24

With a system that has enough memory, then all swap is being used for is to squeeze a little more file read cache out of memory but in that case, swapping to file or partition will squeeze even more file read cache out of memory, so I guess I just do not understand the problem it is supposed to solve.

I’m old, so maybe it’s just my lack of imagination.

Ah, okay, if booting off of something like an SD card or a USB thumb drive then I definitely understand how zram is a better option than swapping to file or a partition. A lot of people do that, especially with raspberry pi and other micro systems.

Okay I am definitely getting old, it just clicked and should have clicked earlier.

If you have X amount of real memory, zram is a way to effectively have more available by using CPU resources to compress/decompress on the fly.

So while for most tasks many of us do it doesn’t necessarily give a noticeable boost, in those times we do something that actually wants more physical memory than we have available, a little extra is there before swapping to disk is necessary.

So it definitely is a good thing to have enabled by default, even if we don’t normally need it.

Detecting existing swap partitions and adding them to /etc/fstab is still something Anaconda did that the new installer should do but that’s minor, just remember to do it yourself if you have a physical swap partition and remember to activate it with swapon before running systemctl daemon-reload. Or reboot,

I added the anaconda-webui tag to get the attention of the new installer team.

I also think, if you try to use old school config, then you definitely need a bit more knowledge as a average user.
With the new type of disk ssd/nvme swap partitions/files are getting more and more obsolete.

By the way, did you test with the everithing Iso, to see if the old gui supported that?

1 Like

They may be getting obsolete but sometimes in summer, we get a power outages because of a fire or whatever, so the ability to hibernate when it looks like it might be lengthy power outage rather is nice to have even for desktop systems so you can keep the UPS charged for things like charging a phone or powering an AM/FM radio if the radio batteries went dead.

Yeah, could shut down too, but then all apps get closed.