Skip to content

Instantly share code, notes, and snippets.

@klingtnet
Created November 22, 2016 17:23
Show Gist options
  • Save klingtnet/c972b8182e4e2818d6d551b0cbeac44b to your computer and use it in GitHub Desktop.
Save klingtnet/c972b8182e4e2818d6d551b0cbeac44b to your computer and use it in GitHub Desktop.
Enable hiberate in Arch Linux usind kernel 4+, grub2 and a swapfile

This guide is based on the hibernate article from the Arch wiki.

  • edit /etc/default/grub and add resume as well as resume_offset kernel parameters
    • resume=UUID=abcd-efgh contains the UUID of the partition on which the swapfile resides. In most cases the swapfile resides in root, to identify the root parition's UUID run blkid or lsblk -O.
    • resume_offset=1234 is the offset of the swapfile from the partition start. The offset is the first entry in the physical_offset column of the output of filefrag -v /swapfile.
    • update grub: grub-mkconfig -o /boot/grub/grub.cfg
    • example: GRUB_CMDLINE_LINUX_DEFAULT="resume=UUID=75972c96-f909-4419-aba4-80c1b74bd605 resume_offset=1492992"
  • add the resume module hook to /etc/mkinitcpio.conf:
    • HOOKS="base udev resume autodetect ...
    • rebuild the initramfs mkinitcpio -p linux
  • check if everything works: systemctl hibernate
@sarveshpro
Copy link

how to enable it with a swap partition?

@klingtnet
Copy link
Author

The linked Arch Wiki article is quite clear about that, you just need to pass resume=UUID=abcd-efgh as kernel parameter where abcd-efgh is the UUID of your swap partition. Of course, you can also specify the partition by LABEL etc.

@gastonmatias
Copy link

very nice! thx!!

@arnavgr
Copy link

arnavgr commented May 14, 2022

best guide on hibernation. only thing i had to change was run mkinitcpio as root

@abhaypatil2000
Copy link

Thanks for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment