[Howto] - Hibernate into swap file

This tutorial will show you how to configure a swapfile for Hibernation in Fedora 31.

First you will need a swap file, for that you can follow these steps on this tutorial on Youtube.

Next you will need to add the resume module to dracut.
You can add this into following line into /etc/dracut.conf


Like so:

And then re-generate your initramfs using:

dracut -f

Why this is not added by default, and why resume from swap partition works without adding resume to dracut, I will never know. If you know the upstream maintainers or are one, please ask them or let me know.

Next we have to add the resume and resume_offset into the GRUB_CMDLINE_LINUX so that Grub can instruct the kernel to resume from the swap file.

It is best to add the disk by uuid.

You can do this by running:

ll /dev/disk/by-uuid

It should produce an output like:

Now if you are using LUKS encryption then select the disk that points to the un-encrypted disk or rather the device mapped by the kernel after it has opened it using your passphrase at the time of boot. In my case it is the one linked to dm-1

So the resume parameter should point to the disk which has the swap file. You don’t need to give the swap file name itself.

So the final resume parameter is


Notice the swap file name is not needed. We have the resume_offset parameter for that. To find that just run the filefrag command on the swap file like so:

sudo filefrag -v /fedora.swap | head -n 4 | tail -n 1 | awk '{print $4}'

You should get an output like:

Copy out that number and add it to resume_offset parameter in grub like so:


So the final GRUB_CMDLINE_LINUX should be something like:

GRUB_CMDLINE_LINUX="rd.luks.uuid=luks-2ec7f1a-6f9=b-896-a2-b80e9d2f4 rd.lvm.lv=vgfedora/fedora resume=/dev/disk/by-uuid/03aef3ba-dca1-4cba-a3f5-36c5c0fe948e resume_offset=65536"

On UEFI systems you may want to disable the grub2-osprober, which is why I have added the line:


After all this is done we can make the grub config by

grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

Note: On MBR systems you may need to find out where your grub.cfg is located, the above command works for me on UEFI.

And that’s it. Test out hibernate by
systemctl hibernate

Hope this helps.


Thanks for writing this. It helped me with the issue I was having. Particularly, I was missing the “resume” module in dracut. GRUB_CMDLINE_LINUX already had the right values for me.

I used whitespace around the “resume” value however, otherwise dracut commands printed a warning about it.

add_dracutmodules+=" resume "

I also placed it in a separate /etc/dracut.conf.d/resume.conf file, as the comment in /etc/dracut.conf recommended doing so.

I wrote a guide summarizing this and other issues I learned of from hibernate bug tracker issues.