Skip to content

Commit

Permalink
Update luks scripts
Browse files Browse the repository at this point in the history
Update luks scripts

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
  • Loading branch information
bensuperpc committed Jul 28, 2021
1 parent 8cd2b4d commit 31fd7d2
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions partition/luks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,24 @@ else
fi

if (( $# == 2 )); then
PARTITION=$1
LABEL=$2
shift 2

if [ $# -eq 0 ]; then
read -r -p "you are going to format a partition/device with LUKS and BTRFS.
All data on the partition/devices will be erased ! Do you want to continue ? [Y/n]: " answ
if [ "$answ" == 'n' ]; then
exit 1
fi
fi

UUID=$(uuidgen)
echo "UUID: ${UUID}"
sudo umount "$1" || true
sudo cryptsetup -v --type luks --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 1000 --use-urandom --verify-passphrase luksFormat --label="$2" "$1"
sudo cryptsetup -v luksOpen "$1" "${UUID}"
sudo mkfs.btrfs --force --checksum crc32c --label "$2" /dev/mapper/"${UUID}"
sudo umount "$PARTITION" || true
sudo cryptsetup -v --type luks --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 1000 --use-urandom --verify-passphrase luksFormat --label="$LABEL" "$PARTITION"
sudo cryptsetup -v luksOpen "$PARTITION" "${UUID}"
sudo mkfs.btrfs --force --checksum crc32c --label "$LABEL" /dev/mapper/"${UUID}"

sudo cryptsetup -v luksClose "${UUID}"
echo "Partition: OK"
Expand Down

0 comments on commit 31fd7d2

Please sign in to comment.