Skip to content

Instantly share code, notes, and snippets.

@zuloo
Last active August 29, 2015 14:08
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 zuloo/12b645f25ec42de396ad to your computer and use it in GitHub Desktop.
Save zuloo/12b645f25ec42de396ad to your computer and use it in GitHub Desktop.
Bash Command 4 Luks Header Backup
cat /etc/crypttab |\
grep uuid |\
sed -r 's/[\t ]+/ /g' |\
cut -d ' ' -f 2 |\
while read line; do
dev=$(ls -la $line);
ser=$(smartctl -a $line | grep 'Serial Number');
cryptsetup \
luksHeaderBackup /dev/${dev##*/} \
--header-backup-file \
/mnt/usb/luks-header_${ser##* }_$(( 0 + 0${dev##*/sd[a-z]} ));
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment