$ cd /tmp
$ wget https://raw.githubusercontent.com/osandov/osandov-linux/master/scripts/btrfs_map_physical.c
$ gcc -O2 -o btrfs_map_physical btrfs_map_physical.c
# переместим исполняемый файл
$ sudo mv btrfs_map_physical /usr/local/bin
$ sudo chmod +x /usr/local/bin/btrfs_map_physical
$ sudo btrfs_map_physical /swap/swapfile
FILE OFFSET FILE SIZE EXTENT OFFSET EXTENT TYPE LOGICAL SIZE LOGICAL OFFSET PHYSICAL SIZE DEVID PHYSICAL OFFSET
0 4096 0 regular 268435456 91029504 268435456 191029504
...
# Смещение поделил на размер блока 4096
# For some reason the output of the script is misaligned, but it's not that difficult to find the proper value: it's the first number in the rightmost column shifted slightly to the left. For me it's 44418101248. Divide this value by 4096 and that's your resume_offset. Mine is 44418101248 / 4096 = 10844263
$ echo $((`sudo btrfs_map_physical /swap/swapfile | head -n 2 | tail -n 1 | cut -f9` / 4096))
22224
В /etc/default/grub прописал:
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet resume=UUID=06572f2c-bd18-494f-a2b6-904704d5222e resume_offset=22224"
В хуки /etc/mkinitcpio.conf
добавил resume после filesystems.
Выполнил:
sudo mkinitcpio -p linux
sudo grub-mkconfig -o /boot/grub/grub.cfg
$ systemctl hibernate
Failed to hibernate system via logind: Not enough swap space for hibernation
$ cat /sys/power/resume_offset
22224
$ cat /proc/swaps
Filename Type Size Used Priority
/swap/swapfile file 8388604 0 -2
$ free -h
total used free shared buff/cache available
Mem: 15Gi 1.7Gi 12Gi 115Mi 1.2Gi 13Gi
Swap: 8.0Gi 0B 8.0Gi
$ journalctl | grep offset
Feb 12 02:26:59 sergey-pc systemd-logind[605]: /sys/power/resume and /sys/power/resume_offset has no matching entry in /proc/swaps; Hibernation will fail: resume=259:2, resume_offset=22224
У кого-нибудь есть решение?
UPD:
$ sudo systemctl edit systemd-logind.service
# Создал такой файл c таким содержимым
[Service]
Environment=SYSTEMD_BYPASS_HIBERNATION_MEMORY_CHECK=1
# Попробовал выполнить и комп просто перегрузился. В журнале та же самая ошибка
$ systemctl hibernate