Backup/Restore LUKS Header

In this quick blog post, we will try to backup or restore a LUKS header for emergency purposes. As you know, LUKS header is A MUST BACKUP file, if you using encryption with LUKS (Linux Unified Key Setup) or dm-scrypt.

Create LUKS Header:

$ sudo cryptsetup luksHeaderBackup /dev/DEVICE \
--header-backup-file /path/to/backupfile
$ sudo cryptsetup luksHeaderBackup /dev/sdb2 \
--header-backup-file /home/emka/mylaptop.luks.bin
$ sudo cryptsetup luksHeaderBackup /dev/md1 \
--header-backup-file /root/mylaptop.luks.bin

Restoring LUKS Header

# cryptsetup luksHeaderRestore /dev/DEVICE --header-backup-file /path/to/backup_header_file
## Assuming that you mounted /nas/ using NFS ##
# cryptsetup luksHeaderRestore /dev/md1 --header-backup-file /nas/vivek/laptop.thinkpad.luks.bin

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: