Last active
October 8, 2025 12:59
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ... | |
| 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