This script automates the complete setup of hibernation on an Omarchy installation with a Btrfs root filesystem and the Limine bootloader.
The script performs the following actions:
- Creates a dedicated Btrfs subvolume at
/swap
. - Creates a swapfile within the subvolume, sized to match the system's total RAM.
- Adds a corresponding low-priority swap entry to
/etc/fstab
. - Ensures the
resume
hook is present in themkinitcpio
configuration. - Calculates the swap file's physical offset and configures kernel resume parameters.
- Updates
/etc/default/limine
withresume
andresume_offset
parameters. - Refreshes the initramfs and bootloader configuration using
limine-update
.
This script is designed exclusively for Btrfs filesystems and will NOT work with other filesystems (ext4, XFS, etc.). It is intended specifically for Omarchy installations (as of August 29, 2025), which use Btrfs by default. The script uses Btrfs-native swapfile creation (btrfs filesystem mkswapfile
) and automatically calculates the required resume_offset
parameter for proper hibernation support.
If you are not using Btrfs, this script will fail during the filesystem check and you will need a different hibernation setup approach.
- System: An Omarchy installation.
- Filesystem: A Btrfs root filesystem.
- Bootloader: Limine bootloader installed and configured:
/boot/EFI/limine/limine.conf
must be present/etc/default/limine
must be present for kernel cmdline configuration
- Systemd: The
systemd-hibernate-resume-generator
must be available. - mkinitcpio: The
omarchy_hooks.conf
file must be present at/etc/mkinitcpio.conf.d/omarchy_hooks.conf
. - Tools:
btrfs-progs
(withfilesystem mkswapfile
),filefrag
,sed
,numfmt
, andlimine-update
must be installed.
-
Real run (makes changes):
sudo ./hibernate.sh
-
Dry run (no changes, prints actions):
DRY_RUN=1 ./hibernate.sh
-
Updating the swapfile: If you change the amount of RAM in your system, you will need to recreate the swapfile. You can do this with the
--update
flag:sudo ./hibernate.sh --update
-
Getting help: To see the available commands, use the
--help
flag:./hibernate.sh --help
- The script will not run if
/swap
or/swap/swapfile
already exist. - The script will abort if any non-zram swap is already active.
- The script creates timestamped backups of
/etc/fstab
and the mkinitcpio hooks file before modifying them.
After a successful real run, test hibernation with the following command:
systemctl hibernate
- Ensure that
btrfs filesystem mkswapfile
is available (requires a recent version ofbtrfs-progs
). - If
limine-update
is missing, install and configure Limine properly or adjust the script for your boot setup. - If your mkinitcpio hooks file path differs, update the
HOOKS_CONF_PATH
variable inhibernate.sh
.
This script modifies system files and can potentially lead to data loss or an unbootable system. Use it at your own risk. It is highly recommended to perform a dry run and back up your data before running the script.