Skip to content

Commit

Permalink
WiP cryptsetup 2.6.1: add helper script to format block device partit…
Browse files Browse the repository at this point in the history
…ion and reencrypt

Script has double warning prior of just doing what user wants with user specified partition.
No validation

Amend test scripts to not append on first write to log files

TODO: Delete this later

Signed-off-by: Thierry Laurion <[email protected]>
  • Loading branch information
tlaurion committed Nov 28, 2023
1 parent bf2891c commit 4cb56d4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 34 additions & 0 deletions initrd/bin/test_reencrypt_block_device_with_double_confirmation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
echo "Mounting USB drive to /media"
mount-usb --mode rw

#Prompt user to specify block device's partition to format and reencrypt with big fat warning
echo "WARNING: This script will format and reencrypt specified partition next. Please make sure you have backed up your data before proceeding."
echo "Please specify block device's partition to format and reencrypt. Example: /dev/sda2"
read DISK

#validate one last time with user prior of proceeding
echo "You have specified $DISK. Are you sure you want to proceed? (y/n)"
read CONFIRM
if [ "$CONFIRM" != "y" ]; then
echo "Aborting..."
exit 1
fi

#echo "PLACEHOLDER - Creating 8GB file in /tmp" | tee -a /media/ram_reencrypt.log
#dd if=/dev/zero of=/tmp/disk8gb.raw bs=1M count=8k | tee -a /media/ram_reencrypt.log
echo "This is test passphrase used to create LUKS key" > /tmp/passphrase.txt

#Doing benchmarking
echo "PLACEHOLDER - Running benchmark..." | tee /media/block_reencrypt.log

cryptsetup benchmark | tee -a /media/block_reencrypt.log

echo "PLACEHOLDER - Creating LUKS container on $DISK..." | tee -a /media/block_reencrypt.log
time cryptsetup luksFormat "$DISK" --debug --batch-mode --key-file /tmp/passphrase.txt | tee -a /media/block_reencrypt.log

echo "PLACEHOLDER - Reeencrypting LUKS container on $DISK..." | tee -a /media/block_reencrypt.log
time cryptsetup reencrypt "$DISK" --disable-locks --force-offline-reencrypt --debug --batch-mode --key-file /tmp/passphrase.txt | tee -a /media/block_reencrypt.log

echo "PLACEHOLDER - Unmounting USB drive from /media"
umount /media
echo "Done. You can remove USB drive now and upload ram_reencrypt.log from another computer to github PR."
2 changes: 1 addition & 1 deletion initrd/bin/test_reencrypt_ram.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
echo "Mounting USB drive to /media"
mount-usb --mode rw

echo "PLACEHOLDER - Creating 8GB file in /tmp" | tee -a /media/ram_reencrypt.log
echo "PLACEHOLDER - Creating 8GB file in /tmp" | tee /media/ram_reencrypt.log
dd if=/dev/zero of=/tmp/disk8gb.raw bs=1M count=8k | tee -a /media/ram_reencrypt.log
echo "This is test passphrase used to create LUKS key" > /tmp/passphrase.txt

Expand Down

0 comments on commit 4cb56d4

Please sign in to comment.