06-unmount-vault.sh
Unmounts and locks the LUKS2 encrypted code vault. Unmounts ~/Code and closes the cryptsetup container.
Usage
bash
bash scripts/06-unmount-vault.sh [--dry-run] [--help]| Flag | Description |
|---|---|
--dry-run | Preview all actions without modifying the system |
--help | Show usage information and exit |
What It Does
- Unmount — if
~/Codeis a mount point (detected viafindmnt), unmounts it - Close LUKS container — if
/dev/mapper/code_vaultexists, closes it viacryptsetup close
Busy Device Handling
If umount fails (typically because a terminal or process has its working directory inside ~/Code), the script exits with an error message. To resolve:
- Close any terminals or applications using files inside
~/Code - Run
lsof +D ~/Codeto identify remaining processes - Re-run the script
Idempotent Behaviour
Safe to run multiple times. If the vault is not mounted, the unmount step is skipped. If the LUKS container is already closed, the script reports success.
Files Modified
| Path | Purpose |
|---|---|
~/Code | Unmounted |
/dev/mapper/code_vault | LUKS device mapper entry (closed) |
Prerequisites
cryptsetupinstalledsudoaccess forumountandcryptsetup close
Source
View the full source on GitHub.