💡 Because sometimes you just wanna close the lid, go make noodles, and come back like nothing happened.
1️⃣ Check your RAM & plan the swap
Hibernation stores all your RAM into the swap.
Rule: swap size ≥ RAM × 1.2
(just to be safe).
Mine:
free -h
Mem: 7.6G total
👉 I’ll make a 9G swapfile.
2️⃣ Create the swapfile
Let’s make it, lock it, and enable it:
sudo fallocate -l 9G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
3️⃣ Make it permanent in /etc/fstab
echo '/swapfile none swap defaults 0 0' | sudo tee -a /etc/fstab
No more "oops my swap disappeared after reboot".
4️⃣ Grab the UUID and offset
The kernel needs to know where your swap lives:
# UUID of the partition containing swapfile
findmnt -no UUID -T /swapfile
# Offset of the swapfile
filefrag -v /swapfile | awk '{if($1=="0:"){print $4}}' | sed 's/\.\.//'
Write those down — we’ll need them in the GRUB step.
5️⃣ Tell GRUB about it
Edit /etc/default/grub
:
sudo nano /etc/default/grub
Find:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
Change to:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=<your_uuid_here> resume_offset=<your_offset_here>"
Update GRUB:
sudo grub-mkconfig -o /boot/grub/grub.cfg
6️⃣ Teach Dracut to resume
Create /etc/dracut.conf.d/resume.conf
:
echo 'add_dracutmodules+=" resume "' | sudo tee /etc/dracut.conf.d/resume.conf
Rebuild initramfs:
sudo dracut --regenerate-all --force
7️⃣ Test the magic ✨
sudo systemctl hibernate
If your PC powers off and comes back with everything exactly where you left it,
congratulations — you’re now a hibernation wizard 🧙♂️.
🔥 Bonus: Suspend-then-Hibernate
Suspend to RAM first, then hibernate after a delay (battery saver’s dream):
sudo mkdir -p /etc/systemd/sleep.conf.d
sudo nano /etc/systemd/sleep.conf.d/hibernate.conf
Put:
[Sleep]
HibernateDelaySec=30min
Run:
sudo systemctl suspend-then-hibernate
🏆 Done!
Now your Arch/EndeavourOS box can sleep like a cat 🐈 and wake up like it’s got super memory powers.
Top comments (0)