Advertisement
cryptofascist

Untitled

Sep 24th, 2022
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. # Mount root btrfs to create swap subvolume
  2. sudo mount /dev/mapper/your-btrfs-decrypted-device /mnt
  3. sudo btrfs subvol create /mnt/swap
  4. sudo chmod 700 /mnt/swap
  5.  
  6. # Create mountpoint for the subvolume that will contain the swapfile
  7. sudo mkdir /swap
  8. sudo mount -o subvol=swap /dev/mapper/your-btrfs-decrypted-device /swap
  9.  
  10. # Create the swapfile and set required parameters
  11. sudo truncate -s 0 /swap/swapfile
  12. sudo chattr +C /swap/swapfile
  13. sudo btrfs property set /swap/swapfile compression none
  14. # Make the swapfile 20 gigabytes, change this to whatever
  15. sudo fallocate -l 20G /swap/swapfile
  16. sudo chmod 600 /swap/swapfile
  17. sudo mkswap /swap/swapfile
  18.  
  19. # Now that you have a swapfile ready, you need to find the location of it using the special btrfs program
  20. # I assume you've compiled it already as described:
  21. # https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file_on_Btrfs
  22. ./btrfs_map_physical /swap/swapfile
  23.  
  24. 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:
  25. (operating-system
  26. (kernel-arguments
  27. '("resume=/dev/mapper/your-decrypted-btrfs-name"
  28. "resume_offset=<that number you calculated above>"))
  29. (file-systems
  30. (cons*
  31. (file-system
  32. (mount-point "/")
  33. (device "/dev/mapper/your-btrfs-device")
  34. (flags '(no-atime))
  35. (options "subvol=swap,nodatacow,nospace-cache")
  36. (type "btrfs")
  37. (check? #f)
  38. (create-mount-point? #t)
  39. (needed-for-boot? #f)
  40. (dependencies mapped-devices))
  41. ... your other filesystem declarations
  42. %base-file-systems))
  43. (swap-devices
  44. (list
  45. (swap-space
  46. (target "/swap/swapfile")
  47. (dependencies file-systems)))))
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement