From 0b570ba324a3e48815407443d0bc0fec7a7c4a3c Mon Sep 17 00:00:00 2001 From: nbros652 Date: Thu, 15 Aug 2019 13:58:59 +0800 Subject: [PATCH] NVMe fix and disallow blank encryption passphrases Creating partitions on NVMe drives appears to take place so quickly that when the script was attempting to access the new partition, the OS was not yet aware of it. This is fixed by waiting until the partition is visible to return its path (new lines 169-172). Blank encryption passphrases are pointless, throw error on blank passphrase in case someone is just hitting the Enter key to select all the defaults for the preceding queries. --- LGMP.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/LGMP.sh b/LGMP.sh index 642f04b..3966185 100644 --- a/LGMP.sh +++ b/LGMP.sh @@ -110,8 +110,8 @@ do read -sp "Encryption passphrase: " luksPass && echo read -sp "Confirm encryption passphrase: " confirm clear - [ "$luksPass" == "$confirm" ] && break -echo "passphrases didn't match! Try again" + [ "$luksPass" == "$confirm" ] && [ "$luksPass" == "" ] break +echo "passphrases didn't match or passphrase was blank! Try again" done echo -e 'In addition to the passphrase you provided, a keyfile can be generated that can \nalso be used for decryption. It is STRONGLY RECOMMENDED that you create this \nfile and store it in a secure location to be used in the event that you ever \nforget your passphrase!\n' read -p "Key file size in bytes, or 'none' to prevent key file creation [512]: " keyfileSize @@ -164,6 +164,13 @@ getDiskPartitionByNumber() { # partitions for this disk follow a SATA, IDE, SCSI naming standard part="${disk}${partNum}" fi + + # wait until partition is visible to the system; fixes NVMe race condition following partition creation + while [ ! -e "${part}" ] + do + sleep .5 + done + echo "$part" }