#354 update of swapfile creation instructions for hibernation
Closed: published 2 months ago by rlengland. Opened 3 months ago by zbyszek.

https://fedoramagazine.org/hibernation-in-fedora-36-workstation/ is now outdated. We recently had a bug reported (https://bugzilla.redhat.com/show_bug.cgi?id=2324811, now non-public on the request of the submitter) about the reported steps now working. We fixed various details, and now the instructions should be updated, and can also be simplified. I'm proposing to write an article that is essentially the same as the previous one, just modernized.


+1. We can also add a reference to the new article at the top of the old one.

Thanks!

Metadata Update from @glb:
- Issue assigned to zbyszek
- Issue tagged with: article, needs-image

3 months ago

https://fedoramagazine.org/wp-admin/post.php?post=41543&action=edit
https://fedoramagazine.org/?p=41543&preview=true&preview_id=41543

I added a few code blocks for selecting and pasting, but unforunately they look quite bad in the preview. I'm not sure if I did something different then before…

It'd probably be if somebody gave this a spin on their own machine before publishing… I'm pretty sure the commands are correct, but a second check is always good.

Oh, and < are displayed as &lt;. I don't know how that happened.

Metadata Update from @rlengland:
- Custom field preview-link adjusted to https://fedoramagazine.org/?p=41543&preview=true

3 months ago

@zbyszek the best thing to use for code is to declare it as "preformatted". That should keep things like
&lt;
from appearing. I've modified your code lines. Check them out and verify that they are still correct.

Thanks, looks great now.

@zbyszek we'll give it another review and schedule it for publication. Thank you for the article.

Metadata Update from @glb:
- Custom field editor adjusted to glb

3 months ago

Metadata Update from @glb:
- Custom field image-editor adjusted to glb

3 months ago

Metadata Update from @glb:
- Custom field publish adjusted to 2025-01-24

3 months ago

This has been edited and scheduled to go out on Friday.

https://fedoramagazine.org/update-on-hibernation-in-fedora-workstation/

Just let us know if you would like anything revised further.

Thanks!

It looks like I messed up the instructions and missed a few things that need to be done.
I think it's best to edit the article to insert the corrections.

Unfortunately it looks I cannot do this myself. I also cannot approve the comments. (I can see the pending comments, but no matter what I do, I don't see any way to approve them. I tried in a private browsing window and under chromium, so I don't think this is a question of the browser. I just don't seem to have the permissions under my account.)

Could somebody please do the following:

  sudo btrfs subvolume create /var/swap
+ sudo chattr +C /var/swap
+ sudo restorecon /var/swap
  sudo mkswap --file -L SWAPFILE --size $SWAPSIZE /var/swap/swapfile
  sudo bash -c 'echo /var/swap/swapfile none swap defaults 0 0 >>/etc/fstab'
  sudo swapon -av
+ sudo bash -c 'echo add_dracutmodules+=resume >>/etc/dracut.conf.d/resume.conf'
+ sudo dracut -f
  sudo swapoff -v /var/swap/swapfile
  sudo sed -r -i '/.var.swap.swapfile/d' /etc/fstab
- sudo btrfs subvolume rm /var/swap
+ sudo btrfs subvolume delete /var/swap
+ sudo rm /etc/dracut.conf.d/resume.conf

(Sorry for the trouble. I should have tested this from scratch on a clean install :(. )

Oh, and the whole section about SecureBoot was completely wrong. It turns out I was confused by a selinux denial. So this whole chunk needs to go:

- Another severe limitation is that SecureBoot must be disabled. The kernel does not allow hibernation with SecureBoot! Disabling SecureBoot reduces the security of the machine somewhat. Thus, do this only if you think that hibernation is more worth it.
- First, check whether Secure Boot is on:
-
- bootctl
-
- If this prints “Secure Boot: disabled” then SB is off. Otherwise, reboot the machine, go into UEFI settings, and disable Secure Boot.
-
- Second, create and enable a swap file:
+ Create and enable a swap file:

I've attempted to make the changes you've requested with one modification. I changed:

sudo bash -c 'echo add_dracutmodules+=resume >>/etc/dracut.conf.d/resume.conf'

to:

sudo bash -c 'echo add_dracutmodules+=\" resume \" > /etc/dracut.conf.d/resume.conf'

add_dracutmodules is a Bash string. You must include spaces at the beginning and end of the string(s) you append to add_dracutmodules or else they can become merged in a way that will prevent them from working. For example, if there was another .conf file in the user's dracut drop-in config directory containing something like add_dracutmodules+=zfs (again no surrounding spaces), then the end result would be add_dracutmodules=resumezfs which isn't a valid dracut module.

Let me know if anything else needs to be revised.

sudo bash -c 'echo add_dracutmodules+=\" resume \" > /etc/dracut.conf.d/resume.conf'

Thanks.

I'm being told that hibernation working with SB is a bug. Apparently lockdown was disabled by mistake (https://pagure.io/fedora-workstation/issue/228#comment-953206). If that turns out to be true, then the part about disabling SB would need to be restored. Arrrgh.

OTOH, there is some good news: mkswap will set no-CoW automatically soon (https://github.com/util-linux/util-linux/pull/3386). We can't rely on this yet, but maybe the next iteration of this article can be simplified a bit ;)

Issue status updated to: Closed (was: Open)
Issue close_status updated to: published

2 months ago

Log in to comment on this ticket.

Metadata
Boards 1
articles Status: published