btrfs-progs icon indicating copy to clipboard operation
btrfs-progs copied to clipboard

Hibernate on dedicated part-n & SWAP in BTRFS file. Possible?

Open Heavygrass opened this issue 5 months ago • 2 comments

Hi, Is it possible to separate hibernate on dedicated partition & put SWAP in BTRFS file/subvolume?

There's a dedicated partition for Hibernate & SWAP, which is 0.1 GiB larger than the physical RAM size (16GB):

lsblk /dev/sda6 NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda6 8:6 0 16.1G 0 part [SWAP]

lsblk -b /dev/sda6 NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda6 8:6 0 17287872512 0 part [SWAP]

However sometimes (not always) when lots of windows is opened, there's no hibernate option in GUI.

Hibernate in terminal in this case gives error: Call to Hibernate failed: Not enough suitable swap space for hibernation available on compatible block devices and file systems.

free in the sample such case: total used free shared buff/cache available Mem: 16190660 11406432 1461460 1400400 5319852 4784228 Swap: 16882684 11051708 5830976

If I close a bunch of windows/free RAM, the hibernate option appears. I think its b/c SWAP uses a part of the dedicated partition and there's sometimes no space to write whats in RAM.

Sometimes there's the hibernate option in GUI and it tries to hibernate, but (probably due to not enough space on dedicated partition) resumes almost immediately.

I've read btrfs SWAP/hibernate docs, and couldn't find what's the recommended setup in case one wants to use hibernate?

I tried creating 8GB swapfile (keeping dedicated partition), did swapon and SWAP worked, but the hibernate option disappeared from GUI no matter how many windows opened.

There's about 65GiB right in front of BTRFS/LUKS partition, but inet pages say it's unsafe to try to resize LUKS partition.

SWAP/hibernate partition goes right after BTRFS/LUKS partition and goes all the way to the end of the disk.

What are my options here to keep hibernate working even when memory/SWAP is heavily used?

Kernel 6.8.x. btrfs-progs v6.6.3.

Thank you.

Heavygrass avatar Jun 25 '25 19:06 Heavygrass

I'm not sure I understand what you want to achive, do you mean to use partition and also a swapfile for hibernation? Ie. some kind of a split, which I think may not work at all. Regarding the size, I think there are recommendations to have the swap space 1.5-2x size of RAM. 0.1G margin is probably too small.

kdave avatar Jul 18 '25 00:07 kdave

do you mean to use partition and also a swapfile for hibernation?

To use swapfile on BTRFS solely for SWAP (not use swapfile for hibernation). swapfile can be any size. And to use currently existing separate partition 16.1GB solely for hibernation (currently existing separate partition should be enough for hibernation alone). My understanding/hope is that whatever in swapfile does not need to be hibernated cause its already on disk, right?

In my experience hibernation doesn't work to a swapfile on btrfs. Any solution that would allow not to recreate LUKS/BTRFS partitions and allow hibernation to work with lots of apps opened would work.

Heavygrass avatar Jul 18 '25 02:07 Heavygrass