To back up a laptop's LUKS header, confirm the device, save its header to a file, and store the copy safely.
Key takeaways
- Confirm the encrypted partition before running the backup command.
- Save the header backup to removable storage and record its checksum.
- Protect the copy and keep the passphrase separately.
- Practise recovery on a spare disk before you need it.
This block is the LUKS header. It holds the settings the system needs to open the disk, along with the key slots that hold the master key, each one unlocked by a passphrase or key. Keep a header backup alongside your other backups. A header backup is a copy of that block that gives you a way back from this kind of failure, and making one takes little time.
If you look after a handful of laptops on your own, this task is easy to skip. Nobody asks for it until a machine fails to boot, and by then a copy made after the fact does not help. This post covers the work in three short steps: confirm that the device really uses LUKS, write its header to a backup file, and then store and check that file somewhere safe. The examples come from the cryptsetup manual, so keep that page open in another window while you read.
Why the header deserves a copy
The cryptsetup manual page describes the header backup action this way: "Stores a binary backup of the LUKS header and keyslot area." That short description tells you two things. The backup covers more than the header alone, because the keyslots come with it. It is also binary, so you cannot open it in a text editor and read it. Treat it as data that needs careful handling, not as a document you can skim.
The failure this protects against usually looks ordinary at first. The laptop asks for the passphrase, you type what you know is right, and the disk still will not open. It is easy to lose a morning checking the keyboard layout, the boot menu, and the passphrase again before anyone looks at the disk structure itself. A header backup gives you a known copy to compare against and to put back, so the question changes from "why won't this open?" to "which copy do I restore?" This post covers making and keeping that copy.
The file also needs protection. It contains keyslot data, which is part of how the disk decides who can unlock it, so it is sensitive. The easy habit is to treat the backup as a harmless leftover, copied to a random drive and forgotten. The NIST guide on storage encryption makes a general point that applies here: "To prevent such disclosures of information, the information needs to be secured." (NIST SP 800-111)
There is also a people risk. If you are the only person who knows how a laptop was set up, a backup that is written down and stored where a colleague or successor can find it is part of the handover. The backup does not replace documentation, but clear records help someone else find the copy while you are away.
A normal file-level backup copies the files you put on the disk, not the encrypted layer that holds them. So the header backup is a companion to your other backups, not a substitute for them. User files still need their own backups. For that separate task, see our guide to file recovery options. Keep the scope in view: this post is about the header backup only. It does not cover imaging the whole disk, backing up user files, or setting up encryption on a new laptop from scratch. Each of those is a separate task with its own planning.
Before you start
Gather what you need before you touch a laptop. You need root access on the machine, because the backup step reads the raw device. You need the cryptsetup tool installed, and it helps to read its manual page for the version you have, since options can differ between releases. If a flag is rejected, check the help output on your own machine rather than guessing.
You also need a removable drive for the backup file, and a notes file or asset record where you will log each laptop's result. A spare disk is useful too. The test in the last step should happen on a disk you can afford to lose, not on a machine in service.
Pick a quiet time to do the work. Plug the laptop into power, close other programs, and do not start the job right before a meeting or a shutdown. The steps are short, but they are easier to get right when you are not rushing. If something looks wrong, stop and come back to it later. A paused job is better than a wrong command.
Decide on a naming pattern now, before the first backup. Use something that identifies the machine, such as an asset number or a short hostname, followed by a plain description and the file extension. Consistent names make it much easier to find the right file in a year, when you may no longer remember which laptop used which device name. Use finance-laptop-header.img as an example file name.
Step 1: Confirm the device is a LUKS device
Start by making sure you have the right partition. A laptop often has several partitions, including the boot partition and a swap area, and only the encrypted one carries a LUKS header. Run a listing of block devices with file system types, such as lsblk -f. An encrypted partition usually shows a type that names LUKS, and you can match it against the size and label you expect.
Write the device name down before you go further. Device names can change between boots when drives are added or removed, so check the name on the day you run the job rather than relying on one you remember from a previous session. If a laptop has more than one encrypted partition, repeat the check for each one. Each LUKS device gets its own backup file and its own line in your notes, so you never have to work out later which header belongs to which partition.
The cryptsetup manual includes a check for this.
sudo cryptsetup isLuks /dev/sdX
Replace /dev/sdX with the device name you chose. If the check says the device is not LUKS, stop. Either you picked the wrong partition, or this machine uses a different setup for its disk. Do not guess your way forward. Go back to the partition listing, check the device again, and continue only when the result agrees with what you expect from the machine.
The check asks a question about the device and does not change the disk, but the habit it builds matters later. Many disk mistakes come from running a correct command against the wrong device. Checking first, every time, is what keeps the backup step and any future repair step on the right target.
While you have the device in front of you, note the LUKS version. The manual states that "LUKS2 uses locks, other formats do not use this mechanism." (cryptsetup manual page) That line is a reminder that the formats do not behave the same way, so the version is worth recording. Put it in your asset record next to the device name, the machine's identifier, and the date you checked.
Keep this step short in practice. You are not trying to audit the whole disk. You want one answer, which is that this partition is a LUKS device, and one record, which is the name you will use for the backup. When both are written down, you are ready for step two.
Step 2: Write the header to a backup file
The manual's third example shows the operation you need: "Example 3: Create LUKS header backup and save it to file." (cryptsetup manual page) The command takes the device and an output file. Replace the device name and output path in this example before running it:
sudo cryptsetup luksHeaderBackup /dev/sdX --header-backup-file finance-laptop-header.img
Put the backup file on the removable drive, not on the laptop's own disk. If the backup lives only on the machine it protects, a failed disk, a theft, or a wipe can remove both at once. Mount the drive first, then give the full path to the file so there is no doubt about where it lands. A label on the drive, written the same way as the file name, helps you avoid picking the wrong one.
Before writing, make sure the drive has room for the file and that it mounts cleanly. A drive that is nearly full or throwing errors can leave you with a partial file, which is worse than no file because it looks finished. Check the result before you trust it, as described below.
Before you run the command, check whether the file name already exists on the drive. If it does, look at that file and at the notes that go with it before you do anything else. A backup for another laptop should never be overwritten by accident. If you are not sure a file can be replaced, pick a new name.
Watch the output as it runs. If it reports an error, do not retry blindly. Read the message, confirm the device name again with the listing from step one, and only then run the command again. Repeating the same command against an error you have not understood is how small problems grow.
When the command finishes, check that the file exists and is not empty. List the file with its size and timestamp, and confirm both look reasonable for the job you just did. Where the file system supports it, limit who can read the file, so that only your account can read or write it. This small step keeps the copy from being opened by whoever next plugs in the drive.
Next, record a checksum of the file. A SHA-256 hash is a short fingerprint of the file's contents. Run a checksum tool on the file, such as sha256sum, and write the result in your notes. Later, when you need to confirm that a copy on the drive still matches the original, you can compare fingerprints instead of guessing. The checksum does not make the file secret, so the protection in step three still applies.
Write the result in your asset notes: the device name, the file name, the checksum, the laptop's identifier, the LUKS version from step one, and the date. Keep these notes off the laptop itself, in the same place as your other asset records. A note on the machine tells you nothing if the machine is the problem.
Do this on every laptop in the fleet, including the ones that seem healthy. The right time is while the laptop still opens normally. If you have a backlog, start with the machines that hold the most important work, then work through the rest on a schedule you can keep.
Step 3: Store the backup safely and test it
For a one-person team, that usually means a small encrypted drive in a locked drawer, plus a second copy somewhere else you control. The second copy matters because one drive can fail on the shelf too.
Label the drive with the laptop identifier and plug it in only for copy and check tasks. Leaving a backup drive permanently attached to a desk or a laptop dock undoes the point of keeping it apart.
The same general principle applies to storage as to the file itself. Encrypt the storage the backup sits on, limit who can open the drive, and keep a short list of who has access. If you share the drive with anyone, write down who it is and when they got access.
Keep the passphrase separate from the backup. The manual is plain on this point: "For unlocking with the open, a password must be provided." (cryptsetup manual page) A header backup does not replace the password. Store the passphrase or key in a password manager or sealed record that you control, and make sure you can reach it without the laptop, since the laptop may be the thing that is down.
The manual's second example shows that you can add a passphrase to a specific key slot: "Example 2: Add an additional passphrase to key slot 5." (cryptsetup manual page) That is a separate operation with its own risk. Adding a passphrase changes the live disk, so it is not part of the backup routine. If you decide a spare passphrase is worth having, plan it as its own change, test it on a spare device first, and write down which slots are in use.
Test the backup before you rely on it. Check the restore procedure on a spare disk rather than a laptop that is in service. The manual's first example shows how to create a LUKS 2 container on a block device: "Example 1: Create LUKS 2 container on block device /dev/sdX." (cryptsetup manual page) Create a test container on the spare disk, make a header backup of it using the same steps as this post, and then practise the restore on that spare device until the steps feel routine.
As part of the test, confirm that the test container opens with its passphrase after the restore. If it does, you have shown that the steps work on that disk. If it does not, stop and read the output carefully before you try again.
Keep the test notes short. Write down the commands you used, what the output looked like, and any step that surprised you. The next time you need to restore a real laptop, you will be working from your own notes rather than trying to remember them under pressure. Use our backup restore test guide to help organise that separate test.
Decide early what happens to the backup when a laptop is retired. If the disk will be wiped or destroyed, handle the header backup the same way. If the disk is being reused, keep the backup with the laptop's record until the machine has been re-encrypted and backed up again.
Finally, run a short check on each laptop once it has a backup: the file exists, its checksum matches your notes, the copy sits away from the machine, the notes name the right device, and you know where the passphrase is kept. If any of these is missing, the backup may not help when you need it.
Illustrative example: checking a stored copy
Suppose you manage 10 laptops and are checking a stored header backup. Compare its checksum with the value in that laptop's asset notes. If they differ, stop and investigate before relying on the copy. Record what you found against that device, then continue through the remaining laptops.
Make it part of setting up each new laptop, and add it to your routine when you rotate or re-image machines. Revisit the stored copies on a schedule you can keep, so you know they still exist when you need them.
Today, choose a laptop that opens normally and confirm its encrypted device name before making the backup.
Common questions
Does a header backup include user files?
No, it covers the LUKS header and keyslot area; keep separate backups of your user files.
Does this guide cover a full disk repair?
No, it covers making, storing and checking a header backup, with restore practice kept to a spare disk.