LUKS. Главное
LUKS, это заголовок, header. К которому цепляется блочное устройство, block device. Это самое главное, что надо знать о LUKS.
Заголовок можно подготовить отдельно, используя временное устройство, например файл образа, image file. После этого, с его помощью можно открыть другое устройство. Можно несколько, зная что делаешь.
Create LUKS header. Backup it after that.
dd if=/dev/urandom of=luks-test1.ima bs=1M count=10
cryptsetup luksFormat luks-test1.ima \
--header luks-test1.luks
# Header created, delete the temporary backing image.
rm -f luks-test1.ima
cp -a luks-test1.luks /path/to/headers-backups/
Create a new image, open it using the existing header, make FS, close. Or just use any existing block device.
dd if=/dev/urandom of=luks-test1-second.ima bs=1M count=10
# No need to format the image, just open it
cryptsetup open luks-test1-second.ima luks-test1-second \
--header luks-test1.luks
mkfs.ext4 /dev/mapper/luks-test1-second
cryptsetup close luks-test1-second
Open the device. Optionally delete the header. Mount the device and use it.
cryptsetup open luks-test1-second.ima luks-test1-second \
--header luks-test1.luks
mkdir -p /mnt/luks-test1-second
mount /dev/mapper/luks-test1-second /mnt/luks-test1-second
Готовый заголовок используется лишь в момент открытия устройства cryptsetup open, после этого его можно удалить. Конечно, если есть копия в надёжном месте. Для закрытия устройства заголовок не нужен.