-
Notifications
You must be signed in to change notification settings - Fork 0
hibernate
XADE edited this page Dec 10, 2023
·
1 revision
initramfs with module : resume is needed for hibernation to work
after creating a swap file [in this example /.swap/swap]
curl -OL https://raw.githubusercontent.com/osandov/osandov-linux/master/scripts/btrfs_map_physical.c
gcc -O2 -o btrfs_map_physical btrfs_map_physical.c
# replace /.swap/swap below with path to swapfile
OFFSET="$(./btrfs_map_physical /.swap/swap | awk -v SIZE="$(getconf PAGESIZE)" 'NR==2 {printf $NF/SIZE}')"
GC=$(cat /etc/default/grub)
# now add kernel parameters needed for hibernation and performance
printf '%s' "${GC%%\"} resume=UUID=$(findmnt / -o UUID -n) resume_offset=$OFFSET zswap.enabled=1 mitigations=off psi=1\"" > /etc/default/grub
- to update grub menu
grub-mkconfig -o /boot/grub/grub.cfg
after a reboot, to hibernate run
printf disk > /sys/power/state
even with swap smaller than RAM, successfull hibernation is possible by reducing the value of
/sys/power/image_size
printf 0 > /sys/power/image_size