Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Mount root btrfs to create swap subvolume
- sudo mount /dev/mapper/your-btrfs-decrypted-device /mnt
- sudo btrfs subvol create /mnt/swap
- sudo chmod 700 /mnt/swap
- # Create mountpoint for the subvolume that will contain the swapfile
- sudo mkdir /swap
- sudo mount -o subvol=swap /dev/mapper/your-btrfs-decrypted-device /swap
- # Create the swapfile and set required parameters
- sudo truncate -s 0 /swap/swapfile
- sudo chattr +C /swap/swapfile
- sudo btrfs property set /swap/swapfile compression none
- # Make the swapfile 20 gigabytes, change this to whatever
- sudo fallocate -l 20G /swap/swapfile
- sudo chmod 600 /swap/swapfile
- sudo mkswap /swap/swapfile
- # Now that you have a swapfile ready, you need to find the location of it using the special btrfs program
- # I assume you've compiled it already as described:
- # https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file_on_Btrfs
- ./btrfs_map_physical /swap/swapfile
- So now you get a number as described, you need to multiply that number by pagesize to get the final offset, after that, here's my guix configuration:
- (operating-system
- (kernel-arguments
- '("resume=/dev/mapper/your-decrypted-btrfs-name"
- "resume_offset=<that number you calculated above>"))
- (file-systems
- (cons*
- (file-system
- (mount-point "/")
- (device "/dev/mapper/your-btrfs-device")
- (flags '(no-atime))
- (options "subvol=swap,nodatacow,nospace-cache")
- (type "btrfs")
- (check? #f)
- (create-mount-point? #t)
- (needed-for-boot? #f)
- (dependencies mapped-devices))
- ... your other filesystem declarations
- %base-file-systems))
- (swap-devices
- (list
- (swap-space
- (target "/swap/swapfile")
- (dependencies file-systems)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement