Sample Header Ad - 728x90

Why should copying luks headers with dd cause errors on the drive I am reading?

1 vote
1 answer
533 views
**Summary of the problem.** I want to use a detached luks header for a luks-encrypted block device, /dev/nvme0n1p1, by making it into a USB flash drive partition, and afterwards erasing the keys that are on the header of the block device. I have limited details on how to do it, but my plan is to (1) set the size of the flash drive partition, /dev/sda3, to exactly the size of the header. Then (2) use dd if=/dev/nvme0n1p1 of=/dev/sda3 bs=4096 count=4096 to overwrite the space on the new partition with the header information. (3) Enter the header into the options of /etc/crypttab and generate new initramfs. I hoped this would work. But after I ran the dd-command (without yet editing crypttab) I tried to rebuild initramfs, but received the following error: $ update-initramfs -u -k all update-initramfs: Generating /boot/initrd.img-5.10.0-18-amd64 cryptsetup: ERROR: nvme0n1p1_crypt: Source mismatch update-initramfs: Generating /boot/initrd.img-5.10.0-9-amd64 cryptsetup: ERROR: nvme0n1p1_crypt: Source mismatc My questions are: (1) Why am I getting these errors? I don't understand why copying data should cause an error on the file system from which I am reading. (2) What's the right way to write the header to flash drive, if it is not with dd. **Details and any research.** I have searched google and stack exchange, and the seemingly most relevant thing was this . When I ran the command, I received the following information. $ dmsetup info -c --noheadings -o devnos_used -- "nvme0n1p1_crypt" 259:1 Also this guide that I linked to above (in my opinion) seems to suggest that I should do it in this way.
Asked by Mikkel Rev (253 rep)
Oct 3, 2022, 12:33 AM
Last activity: Nov 27, 2022, 03:04 PM