Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/sh -e
#
# Make a btrfs layout Qubes installation use ephemeral swap.
# Tested with R3.2
#
# Rerun anti-evil-maid-install afterwards for your external AEM devices!
dev=/dev/sda2
map=luks-`cryptsetup luksUUID "$dev"`
lsblk -dnr -o MOUNTPOINT /dev/mapper/"$map" | grep -qxF '[SWAP]' # sanity check
swapoff -a
dmsetup remove --retry --force "$map"
head -c 10M /dev/urandom >"$dev"
bak=.luks-swap
sed -e "s/rd.luks.uuid=$map //" -i$bak /etc/default/grub
sed -e "s#$map#swap #" -i$bak /etc/fstab
sed -e "/$map/s#.*#swap $dev /dev/urandom swap,cipher=aes-xts-plain64,size=512#" -i$bak /etc/crypttab
dracut --force --regenerate-all
grub2-mkconfig -o /boot/grub2/grub.cfg
@jpouellet

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet May 26, 2017

We do now have systemd > 218 (222 currently)

We do now have systemd > 218 (222 currently)

@rustybird

This comment has been minimized.

Show comment
Hide comment
@rustybird

rustybird Oct 22, 2017

Thanks @jpouellet, updated - at last.

Owner

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