Skip to content

Instantly share code, notes, and snippets.

@MazeW
Last active August 4, 2025 11:58
Show Gist options
  • Save MazeW/4852f88edcfa5c8bc9286ed188b2a4c6 to your computer and use it in GitHub Desktop.
Save MazeW/4852f88edcfa5c8bc9286ed188b2a4c6 to your computer and use it in GitHub Desktop.
How to enable hibernation on Arch linux 6.12.4

Enabling Swap and Hibernation on Arch Linux

This only works if you use systemd-boot and not GRUB or anything else.

Follow these steps to enable swap and hibernation on Arch Linux.

1. Check Your RAM and Swap Size

First, check your current RAM and swap usage to ensure the swap file is large enough to store the contents of your RAM:

free -h

If your swap file size doesn't match your RAM size, you'll need to create one.

2. Create a Swap File

While you can use a swap partition, using a swap file is easier. To create a swap file, run the following commands:

sudo fallocate -l <size> /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

Replace <size> with the size of your RAM (e.g., 8G for 8 GB).

3. Enable Swap File

To make sure your swap file is enabled on boot, add it to /etc/fstab by running:

echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

4. Configure Hibernation

Modify hibernate.conf

Create or modify the file /etc/systemd/system.conf.d/hibernate.conf and add the following configuration:

[Sleep]
HibernateMode=platform
HibernateDelaySec=0

Configure Initramfs

Edit /etc/mkinitcpio.conf to add the resume hook:

HOOKS=(base udev autodetect modconf block filesystems keyboard fsck resume)

Then regenerate the initramfs:

sudo mkinitcpio -P

5. Update Bootloader

Navigate to the /boot/loader/entries/ directory and open the relevant boot entry file (e.g., 2024-01-01-linux.conf):

sudo nano /boot/loader/entries/2024-01-01-linux.conf

At the end of the options line, add the following (replace <swap-UUID> with your actual swap UUID):

resume=UUID=<swap-UUID>

To find the UUID of your swap, run:

blkid

Update Bootloader

Finally, update the bootloader with:

sudo bootctl update

6. Test Hibernation

To test if everything is working correctly, run:

sudo systemctl hibernate

If your system hibernates and restores with all programs left open, hibernation is successfully configured!


Note: If you're using encryption for your home directory, additional steps may be required to configure hibernation properly.

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