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:

[sourcecode]
$ 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
[/sourcecode]

Restoring LUKS Header

[sourcecode]
# 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
[/sourcecode]