Initial commit
This commit is contained in:
62
create_crypted_disk.sh
Executable file
62
create_crypted_disk.sh
Executable file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
_BACKUP_DEVICE_NAME=backup
|
||||
_LABEL=BACKUP_OPP_03
|
||||
_KEY_FILE=/crypt/home/.keys/zapata.key
|
||||
|
||||
echo ""
|
||||
|
||||
# - Encrypt Disk with given keyfile
|
||||
# -
|
||||
echo ""
|
||||
echo "Encrypt Disk with given keyfile"
|
||||
cryptsetup luksFormat /dev/sde1 $_KEY_FILE
|
||||
|
||||
# - Add Key with Passphrase
|
||||
# -
|
||||
echo ""
|
||||
echo "Add Key (Passphrase) using existent key (keyfile: $_KEY_FILE)"
|
||||
cryptsetup luksAddKey -d $_KEY_FILE /dev/sde1
|
||||
|
||||
# - Open encrypted device
|
||||
# -
|
||||
echo ""
|
||||
echo "Open encrypted device"
|
||||
cryptsetup luksOpen /dev/sde1 $_BACKUP_DEVICE_NAME --key-file $_KEY_FILE
|
||||
|
||||
# - Create Filesystem on crypted device
|
||||
# -
|
||||
echo ""
|
||||
echo "Create ext4 Filesystem on crypted device \"$_BACKUP_DEVICE_NAME\""
|
||||
mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 /dev/mapper/$_BACKUP_DEVICE_NAME
|
||||
|
||||
echo ""
|
||||
echo "Simple sync.."
|
||||
sync
|
||||
|
||||
# - Label crypted device
|
||||
# -
|
||||
echo ""
|
||||
echo "Label crypted device \"$_BACKUP_DEVICE_NAME\". Label: $_LABEL"
|
||||
tune2fs -L $_LABEL /dev/mapper/$_BACKUP_DEVICE_NAME
|
||||
|
||||
# - Set maximal mount count on crypted device
|
||||
# -
|
||||
echo ""
|
||||
echo "Set maximal mount count on crypted device"
|
||||
tune2fs -c 21 /dev/mapper/$_BACKUP_DEVICE_NAME
|
||||
|
||||
# - List settings of crypted device
|
||||
# -
|
||||
echo ""
|
||||
echo "List settings of crypted device \"_BACKUP_DEVICE_NAME\""
|
||||
tune2fs -l /dev/mapper/$_BACKUP_DEVICE_NAME
|
||||
|
||||
# - Close crypted device
|
||||
# -
|
||||
echo ""
|
||||
echo "Close crypted device \"$_BACKUP_DEVICE_NAME\""
|
||||
cryptsetup luksClose $_BACKUP_DEVICE_NAME
|
||||
|
||||
echo ""
|
||||
exit 0
|
||||
Reference in New Issue
Block a user