21.5. 분리된 헤더로 LUKS2를 사용하여 블록 장치에서 기존 데이터 암호화
LUKS 헤더를 저장하기 위한 여유 공간을 생성하지 않고 블록 장치의 기존 데이터를 암호화할 수 있습니다. 헤더는 분리된 위치에 저장되며 추가 보안 계층 역할을 합니다. 절차에서는 LUKS2 암호화 형식을 사용합니다.
사전 요구 사항
- 블록 장치에는 파일 시스템이 있습니다.
데이터가 백업됩니다.
주의하드웨어, 커널 또는 사람의 오류로 인해 암호화 프로세스 중에 데이터가 손실될 수 있습니다. 데이터 암호화를 시작하기 전에 신뢰할 수 있는 백업이 있는지 확인합니다.
절차
장치의 모든 파일 시스템을 마운트 해제합니다. 예를 들면 다음과 같습니다.
# umount /dev/<nvme0n1p1>&
lt;nvme0n1p1>을 마운트 해제하려는 파티션에 해당하는 장치 식별자로 바꿉니다.암호화를 초기화합니다.
# cryptsetup reencrypt --encrypt --init-only --header </home/header> /dev/<nvme0n1p1> <nvme_encrypted> WARNING! ======== Header file does not exist, do you want to create it? Are you sure? (Type 'yes' in capital letters): YES Enter passphrase for </home/header>: Verify passphrase: /dev/mapper/<nvme_encrypted> is now active and ready for online encryption.교체:
-
LUKS
헤더가 분리된 파일 경로가 있는 </home/header>입니다. 분리된 LUKS 헤더는 나중에 암호화된 장치를 잠금 해제하려면 액세스할 수 있어야 합니다. -
암호화 후 생성된 장치 매퍼의 이름이 <
nvme_encrypted>입니다.
-
LUKS
장치를 마운트합니다.
# mount /dev/mapper/<nvme_encrypted> /mnt/<nvme_encrypted>/etc/crypttab파일에 영구 매핑 항목을 추가합니다.# <nvme_encrypted> /dev/disk/by-id/<nvme-partition-id> none header=</home/header>&
lt;nvme-partition-id>를 NVMe 파티션의 식별자로 바꿉니다.dracut을 사용하여 initramfs를 다시 생성 :# dracut -f --regenerate-all -v영구 마운트 항목을
/etc/fstab파일에 추가합니다.활성 LUKS 블록 장치의 파일 시스템의 UUID를 찾습니다.
$ blkid -p /dev/mapper/<nvme_encrypted> /dev/mapper/<nvme_encrypted>: UUID="37bc2492-d8fa-4969-9d9b-bb64d3685aa9" BLOCK_SIZE="4096" TYPE="xfs" USAGE="filesystem"텍스트 편집기에서
/etc/fstab를 열고 이 파일에 장치를 추가합니다. 예를 들면 다음과 같습니다.UUID=<file_system_UUID> /home auto rw,user,auto 0&
lt;file_system_UUID>를 이전 단계에서 찾은 파일 시스템의 UUID로 바꿉니다.
온라인 암호화를 다시 시작하십시오.
# cryptsetup reencrypt --resume-only --header </home/header> /dev/<nvme0n1p1> Enter passphrase for /dev/<nvme0n1p1>: Auto-detected active dm device '<nvme_encrypted>' for data device /dev/<nvme0n1p1>. Finished, time 00m51s, 10 GiB written, speed 198.2 MiB/s
검증
분리된 헤더와 함께 LUKS2를 사용하는 블록 장치의 기존 데이터가 암호화되었는지 확인합니다.
# cryptsetup luksDump </home/header> LUKS header information Version: 2 Epoch: 88 Metadata area: 16384 [bytes] Keyslots area: 16744448 [bytes] UUID: c4f5d274-f4c0-41e3-ac36-22a917ab0386 Label: (no label) Subsystem: (no subsystem) Flags: (no flags) Data segments: 0: crypt offset: 0 [bytes] length: (whole device) cipher: aes-xts-plain64 sector: 512 [bytes] [...]암호화된 빈 블록 장치의 상태를 확인합니다.
# cryptsetup status <nvme_encrypted> /dev/mapper/<nvme_encrypted> is active and is in use. type: LUKS2 cipher: aes-xts-plain64 keysize: 512 bits key location: keyring device: /dev/<nvme0n1p1>