Simple Hibernate with Arch Linux

There is plenty of documentation with how to hibernate a laptop in Linux. A lot of reading and you'll learn a lot of stuff, but sometimes we just want to make shit work quickly and then come back and understand what happened. So, here you go... a simple step-by-step. It may or may not work for you. If it doesn't, start digging into the documentation on the Arch wiki.

> sudo fallocate -l 16G /swapfile
> sudo chmod 600 /swapfile
> sudo mkswap /swapfile
> sudo swapon /swapfile
> sudo vim /etc/fstab
    /swapfile        none        swap        default        0    0
> sudo filefrag -v /swapfile | sed -n '4p' | awk '{print $4+0}'
    548832 <-- Copy this number
> sudo vim /etc/default/grub
    GRUB_CMDLINE_LINUX_DEFAULT="quiet resume=/dev/your_root_disk resume_offset=the_number_just_copied"
> sudo grub-mkconfig -o /etc/grub/grub.cfg
> sudo vim /etc/mkinitcpio.conf
    HOOKS="base udev resume autodetect modconf block filesystems keyboard fsck"
> sudo mkinitcpio -p linux # or linux-lts if you're using the LTS kernel
> sudo vim /etc/systemd/logind.conf
    HandleLidSwitch=hibernate  # if you want to hibernate when the laptop lid closes
> sudo reboot

That should be it. Now close the laptop lid and it should hibernate. Open it and it should resume. Good luck!