2024-11-26

slavach: (Default)

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, после этого его можно удалить. Конечно, если есть копия в надёжном месте. Для закрытия устройства заголовок не нужен.

Profile

slavach: (Default)
slavach

March 2025

M T W T F S S
     12
3456789
10111213141516
171819 20212223
24252627282930
31      

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated 2025-06-12 12:01
Powered by Dreamwidth Studios