Re: new F41 install: is swap partition no longer needed for hibernate?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2024-12-09 at 05:07 -0600, Ranjan Maitra via users wrote:
> Thank you!
> 
> So, in the past, for an ext4 system, which is what I have, I used to do the following:
> 
> 
> sudo vi /etc/default/grub
> 
> add --> resume=UUID="****" <-- to the line GRUB_CMDLINE_LINUX= (anywhere, i do it before the rhgb)
> 
> where the uuid is obtained using blkid.
> 
> then
> 
> sudo bash -x grub2-mkconfig
> 
> # # for efi-based systems: #
> 
> sudo bash -x grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
> 
> and then reboot.
> 
> So, we basically ignore the zram0?

Keep the zram. It makes a real difference to performance. However you
can add some systemd units to disable it when hibernating, e.g.:

$ cat /etc/systemd/system/hibernate-preparation.service
[Unit]
Description=Enable swap file and disable zram before hibernate
Before=systemd-hibernate.service

[Service]
SyslogIdentifier=%N
User=root
Type=oneshot

ExecStartPre=/bin/bash -c ' \
        swapon -a; \
        swapoff /dev/zram0; \
        exit 0; \
        '

ExecStart=/bin/true

The 'swapon -a' line is because I would normally only have zram
enabled, but you can remove this if you're going to keep the swap
partition (or file) active all the time.

$ cat /etc/systemd/system/hibernate-resume.service
[Unit]
Description=Enable zram swap after resuming from hibernation
After=hibernate.target

[Service]
SyslogIdentifier=%N
User=root
Type=oneshot
ExecStart=/bin/bash -c ' \
        if ! swapon --show=NAME --noheadings | grep -q /dev/zram0; then \
                swapon /dev/zram0; \
        fi; \
        exit 0; \
        '

[Install]
WantedBy=hibernate.target

You put those in the appropriate places and call 'systemctl enable ...'
for each of them, then reboot.

Disclaimer: I set this up in F40 and used it for a while but had some
issues with getting it to work reliably with BTRFS so now I'm just
doing suspend rather than hibernate (I have a desktop). However it
should be OK with ext4.

poc
-- 
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux