This guide shows how to configure hibernation on Omarchy or Arch Linux for e.g. a Framework laptop. This guide was tested on a Framework 13 AMD Ryzen 7040 laptop, but you should be able to adapt the instructions for any Linux distribution that has a modern kernel and uses systemd.
Here suspend-then-hibernate is chosen over hybrid-sleep. You can look up the differences between them elsewhere but this configures the behavior that I want on my laptop:
sudo -i
Calculate swap file size based on physical RAM size
SWAPSIZE=$(free | awk '/Mem/ {x=$2/1024/1024; printf "%.0fG", (x<2 ? 2*x : x<8 ? 1.5*x : x) }')
Create a btrfs subvolume for swap and disable Copy on Write
btrfs subvolume create /var/swap
chattr +C /var/swap
Create the swap file
btrfs filesystem mkswapfile --size $SWAPSIZE /var/swap/swapfile
Add the swap file to /etc/fstab and enable it
echo '/var/swap/swapfile none swap defaults 0 0' | tee -a /etc/fstab
swapon -a
Add the resume hook
cat << 'EOF' > /etc/mkinitcpio.conf.d/resume.conf
HOOKS+=(resume)
EOF
limine-mkinitcpio
cat << 'EOF' >> /etc/systemd/logind.conf
HandleLidSwitch=suspend-then-hibernate
EOF
cat << 'EOF' >> /etc/systemd/sleep.conf
HibernateDelaySec=30min
HibernateOnACPower=no
EOF
systemctl hibernate