Finished luks setup

This commit is contained in:
Kevin Veen-Birkenbach 2020-05-20 12:47:30 +02:00
parent 76f1a35a46
commit a03a4adc96
4 changed files with 33 additions and 23 deletions

View File

@ -82,6 +82,17 @@ set_device_path(){
error error
} }
overwritte_device_with_zeros(){
question "Should $device_path be overwritten with zeros before copying?(y/N)" && read -r copy_zeros_to_device
if [ "$copy_zeros_to_device" = "y" ]
then
info "Overwritting..." &&
dd if=/dev/zero of="$device_path" bs="$OPTIMAL_BLOCKSIZE" status=progress || error "Overwritting $device_path failed."
else
info "Skipping Overwritting..."
fi
}
HEADER(){ HEADER(){
echo echo
echo "${COLOR_YELLOW}The" echo "${COLOR_YELLOW}The"

View File

@ -4,8 +4,9 @@ echo "Mounts encrypted storages"
set_device_mount_and_mapper_paths set_device_mount_and_mapper_paths
partition_path="$device_path""1"
info "Unlock partition..." && info "Unlock partition..." &&
sudo cryptsetup luksOpen $device_path $mapper_name || sudo cryptsetup luksOpen $partition_path $mapper_name ||
error error
info "Mount partition..." && info "Mount partition..." &&

View File

@ -3,38 +3,43 @@ echo "Setups disk encryption"
set_device_mount_and_mapper_paths set_device_mount_and_mapper_paths
info "Overwritting device \"$device_path\" with zeros..." && overwritte_device_with_zeros
sudo dd if=/dev/zero of=$device_path bs=$OPTIMAL_BLOCKSIZE status=progress conv=fdatasync ||
error
info "Creating new GPT partition table..." info "Creating new GPT partition table..."
( echo "g" # create a new empty GPT partition table ( echo "g" # create a new empty GPT partition table
echo "w" # Write partition table echo "w" # Write partition table
)| sudo fdisk "$device_path" || error )| sudo fdisk --wipe always "$device_path" ||
error
info "Creating partition table..." info "Creating partition table..."
( echo "n" # Create GPT partition table ( echo "n" # Create new partition
echo "" # Accept default
echo "" # Accept default
echo "" # Accept default
echo "p" # Create GPT partition table echo "p" # Create GPT partition table
echo "w" # Write partition table echo "w" # Write partition table
)| sudo fdisk "$device_path" || error )| sudo fdisk --wipe always "$device_path" ||
error
info "Show memory devices..." &&
sudo fdisk -l || error
partition_path="$device_path""1"
info "Encrypt $device_path..." && info "Encrypt $device_path..." &&
sudo cryptsetup -v -y luksFormat $device_path sudo cryptsetup -v -y luksFormat $partition_path ||
error
info "Unlock partition..." && info "Unlock partition..." &&
sudo cryptsetup luksOpen $device_path $mapper_name sudo cryptsetup luksOpen $partition_path $mapper_name ||
error
info "Create btrfs file system..." && info "Create btrfs file system..." &&
sudo mkfs.btrfs $mapper_path || error sudo mkfs.btrfs $mapper_path || error
info "Creating mount folder unter \"$mount_path\"..." && info "Creating mount folder unter \"$mount_path\"..." &&
mkdir -p $mount_path || error sudo mkdir -p $mount_path || error
info "Mount partition..." && info "Mount partition..." &&
sudo mount $mapper_path $mount_path || error sudo mount $mapper_path $mount_path ||
error
info "Own partition by user..." && info "Own partition by user..." &&
sudo chown -R $USER:$USER $mount_path || error sudo chown -R $USER:$USER $mount_path ||
error

View File

@ -214,14 +214,7 @@ question "Should the image be transfered to $device_path?(y/n)" && read -r trans
if [ "$transfer_image" = "y" ] if [ "$transfer_image" = "y" ]
then then
question "Should $device_path be overwritten with zeros before copying?(y/n)" && read -r copy_zeros_to_device overwritte_device_with_zeros
if [ "$copy_zeros_to_device" = "y" ]
then
info "Overwritting..." &&
dd if=/dev/zero of="$device_path" bs="$OPTIMAL_BLOCKSIZE" status=progress || error "Overwritting $device_path failed."
else
info "Skipping Overwritting..."
fi
info "Starting image transfer..." info "Starting image transfer..."
if [ "$os" = "arch" ] if [ "$os" = "arch" ]