This Bash script facilitates the creation of encrypted storage drives at rest using LUKS encryption. It provides a user-friendly CLI to select a drive, choose a file system type, and performs the necessary steps for formatting, encrypting, and mounting the encrypted drive.
- Developed on Ubuntu Server 22.04 LTS
- Should be compatible with Debian-based distributions
- Checks for
cryptsetup
installation and prompts the user to install if not found. - Allows the user to select a drive from a list of available drives.
- Prompts the user to enter a custom name for the encrypted drive (default includes drive details).
- Offers a selection of common file system types (ext4, xfs, btrfs, f2fs, zfs, vfat).
- Formats, encrypts, and mounts the selected drive using the chosen file system.
- Optionally updates user's
~/.bashrc
and~/.bash_logout
for automating drive unlock/lock. - Provides error handling and exits gracefully on user cancellation or failure.
- Includes comprehensive logging throughout using the system
logger
.
cryptsetup
: The script checks for the presence ofcryptsetup
and prompts the user to install it if not found.lsblk
: Used to list available drives and their details.numfmt
: Used to format drive sizes into human-readable units.
- -h, --help Display this help message and exit.
- -v, --version Display version information.
- -l, --log_dir LOG_DIR Set the log directory. Default is "/var/log/edar_drive_setup".
- Make sure the script is executable:
chmod u x create-edar-drive.sh
- Run the script in the terminal:
./create-edar-drive.sh [-h, --help]
- Follow the prompts to select a drive, choose a file system, and confirm the formatting process.
This script involves drive formatting and encryption. Use it at your own risk. Make sure to back up important data before proceeding. The author is not responsible for any data loss or issues caused by the use of this script.
Your feedback is valuable. Please report any issues or suggest improvements on the GitHub repository.
This script is licensed under the MIT License.
- Aaron
Tripp
N. Josserand Austin