Skip to content

Commit 4cb56d4

Browse files
committed
WiP cryptsetup 2.6.1: add helper script to format block device partition 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]>
1 parent bf2891c commit 4cb56d4

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
echo "Mounting USB drive to /media"
2+
mount-usb --mode rw
3+
4+
#Prompt user to specify block device's partition to format and reencrypt with big fat warning
5+
echo "WARNING: This script will format and reencrypt specified partition next. Please make sure you have backed up your data before proceeding."
6+
echo "Please specify block device's partition to format and reencrypt. Example: /dev/sda2"
7+
read DISK
8+
9+
#validate one last time with user prior of proceeding
10+
echo "You have specified $DISK. Are you sure you want to proceed? (y/n)"
11+
read CONFIRM
12+
if [ "$CONFIRM" != "y" ]; then
13+
echo "Aborting..."
14+
exit 1
15+
fi
16+
17+
#echo "PLACEHOLDER - Creating 8GB file in /tmp" | tee -a /media/ram_reencrypt.log
18+
#dd if=/dev/zero of=/tmp/disk8gb.raw bs=1M count=8k | tee -a /media/ram_reencrypt.log
19+
echo "This is test passphrase used to create LUKS key" > /tmp/passphrase.txt
20+
21+
#Doing benchmarking
22+
echo "PLACEHOLDER - Running benchmark..." | tee /media/block_reencrypt.log
23+
24+
cryptsetup benchmark | tee -a /media/block_reencrypt.log
25+
26+
echo "PLACEHOLDER - Creating LUKS container on $DISK..." | tee -a /media/block_reencrypt.log
27+
time cryptsetup luksFormat "$DISK" --debug --batch-mode --key-file /tmp/passphrase.txt | tee -a /media/block_reencrypt.log
28+
29+
echo "PLACEHOLDER - Reeencrypting LUKS container on $DISK..." | tee -a /media/block_reencrypt.log
30+
time cryptsetup reencrypt "$DISK" --disable-locks --force-offline-reencrypt --debug --batch-mode --key-file /tmp/passphrase.txt | tee -a /media/block_reencrypt.log
31+
32+
echo "PLACEHOLDER - Unmounting USB drive from /media"
33+
umount /media
34+
echo "Done. You can remove USB drive now and upload ram_reencrypt.log from another computer to github PR."

initrd/bin/test_reencrypt_ram.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
echo "Mounting USB drive to /media"
22
mount-usb --mode rw
33

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

0 commit comments

Comments
 (0)