Skip to content

Instantly share code, notes, and snippets.

@rustybird
Last active May 7, 2023 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rustybird/917ac2560fe4e9541d1f to your computer and use it in GitHub Desktop.
Save rustybird/917ac2560fe4e9541d1f to your computer and use it in GitHub Desktop.
#!/usr/bin/sudo bash
set -xeuo pipefail
# Make a Btrfs layout Qubes R4.1 installation use ephemeral swap.
dev=/dev/sda2
grub_cfg=/boot/grub2/grub.cfg # BIOS boot
#grub_cfg=/boot/efi/EFI/qubes/grub.cfg # EFI boot
test -e "$grub_cfg" # sanity check 1
map=luks-$(cryptsetup luksUUID "$dev")
LC_ALL=C lsblk -dnr -o MOUNTPOINT /dev/mapper/"$map" | grep -qxF '[SWAP]' # sanity check 2
swapoff -a
dmsetup remove --retry --force "$map"
head -c 16M /dev/random >"$dev"
bak=.bak-with-luks-swap
sed -e "s/rd.luks.uuid=$map //" -i"$bak" /etc/default/grub
sed -e "s#$map#swap #" -e '/ swap /s# defaults,#&discard=once,#' -i"$bak" /etc/fstab
sed -e "/$map/s#.*#swap $dev /dev/random swap,discard,sector-size=4096,cipher=aes-xts-plain64,size=512#" -i"$bak" /etc/crypttab
dracut --force --regenerate-all
grub2-mkconfig -o "$grub_cfg"
@jpouellet
Copy link

We do now have systemd > 218 (222 currently)

@rustybird
Copy link
Author

rustybird commented Oct 22, 2017

Thanks @jpouellet, updated - at last.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment