Skip to main content

destroy_encrypted_volume

Function destroy_encrypted_volume 

Source
pub async fn destroy_encrypted_volume(id: u32) -> Result<()>
Expand description

Tear down everything create_encrypted_volume set up. Idempotent — never errors on “already gone”. Order matters:

  1. umount the ext4 (releases the kernel block device handle)
  2. luksClose (releases the mapper entry + the LUKS key from keyring memory)
  3. luksErase (overwrites all keyslots → the underlying file’s ciphertext is unrecoverable, even if the operator copied the file before this step ran)
  4. rm the sparse file (free disk space; defense-in-depth even after luksErase)
  5. rmdir the mountpoint (cosmetic; keeps /var/lib/paygress/mounts tidy)