0

On Windows it is possible to use hibernation while not using any swap.

I wonder if this is possible on Linux?

Because on my Debian 11 I find this line in /etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="... resume=/dev/mapper/luks-4205519b-f3fe-468f-b05e-44f25f6882a4"

As you can see the "resume=" option specifies the swap partition which is used for hibernation.

Now if I delete this swap partition (to disabe swap), what am I gonna write into /etc/default/grub?

Is it possible to use a hibernate file as on Windows?

Because I have 32GB RAM and if I use a 32GB swap partition only for hibernation it's a waste of space.

zomega
  • 821
  • 7
  • 19

1 Answers1

2

You can’t hibernate without active swap on Linux, and in particular, whatever device or file you want to use for hibernation has to be enabled for swap when you hibernate.

You can hibernate to a file, at least on some file systems. The resume parameter needs to point to the device holding the file, and you need to add a resume_offset giving the offset to the file (which you can determine using filefrag).

You can ask the kernel to avoid using swap by reducing the swappiness value, vm.swappiness. See How to set and understand fs.notify.max_user_watches for instructions on how to set that.

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164