Skip to content

Instantly share code, notes, and snippets.

@dcampos
Last active October 8, 2025 12:59
Show Gist options
  • Select an option

  • Save dcampos/65616920254fa00d42bbe371b24fb6ed to your computer and use it in GitHub Desktop.

Select an option

Save dcampos/65616920254fa00d42bbe371b24fb6ed to your computer and use it in GitHub Desktop.
Create a swap file on a btrfs subvolume and use it for hibernation in openSUSE. Reference: https://forums.opensuse.org/t/create-btrfs-subvolume/167047/2
# Create subvolume and swap file
# <dev> is the volume of the btrfs partition
sudo mount -o subvol=/ /dev/<dev> /mnt/
sudo btrfs subvolume create /mnt/@/swap
sudo umount /mnt
sudo mkdir /swap
sudo mount -o subvol=/@/swap /dev/<dev> /swap/
# This creates ~12GB swap file
# Check /sys/power/image_size for the minimum needed
sudo btrfs filesystem mkswapfile --size 12g --uuid clear /swap/swapfile
# Change kernel paramaters
# File: /etc/default/grub
GRUB_CMDLINE_LINUX="resume=UUID=<uuid> resume_offset=<offset>"
# How to get the resume offset
sudo btrfs inspect-internal map-swapfile -r /swap/swapfile
# ...
UUID=<uuid> /swap btrfs subvol=/@/swap 0 0
/swap/swapfile swap swap nofail 0 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment