Last active
November 7, 2022 16:47
-
-
Save Felix-Kyun/ca29fd4ec8a60ab74ba8b4613885f369 to your computer and use it in GitHub Desktop.
calculate kernel args for swap file on btrfs
This file contains 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
# taken from https://superuser.com/questions/1581885/btrfs-luks-swapfile-how-to-hibernate-on-swapfile | |
wget "https://raw.githubusercontent.com/osandov/osandov-linux/61679ecd914d653bab14d0e752595e86b9f50513/scripts/btrfs_map_physical.c" && | |
gcc -O2 -o btrfs_map_physical btrfs_map_physical.c && | |
./btrfs_map_physical $1 | sed -n "2p" | awk "{print \$NF}" >/tmp/swap_physical_offset | |
SWAP_PHYSICAL_OFFSET=$(cat /tmp/swap_physical_offset) | |
SWAP_OFFSET=$(echo "${SWAP_PHYSICAL_OFFSET} / $(getconf PAGESIZE)" | bc) | |
SWAP_UUID=$(findmnt -no UUID -T $1) | |
RESUME_ARGS="resume=UUID=${SWAP_UUID} resume_offset=${SWAP_OFFSET}" | |
echo "${RESUME_ARGS}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment