From ab0fbef5fc97198c45e27a5ff20393eaf47ca648 Mon Sep 17 00:00:00 2001 From: openoms <43343391+openoms@users.noreply.github.com> Date: Tue, 14 Sep 2021 10:43:03 +0100 Subject: [PATCH] blitz.datadrive: detect and protect bootPartition (#2538) --- home.admin/config.scripts/blitz.datadrive.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/home.admin/config.scripts/blitz.datadrive.sh b/home.admin/config.scripts/blitz.datadrive.sh index 36d8b07b6..0b5dd3805 100755 --- a/home.admin/config.scripts/blitz.datadrive.sh +++ b/home.admin/config.scripts/blitz.datadrive.sh @@ -82,7 +82,13 @@ if [ "$1" = "status" ]; then # will then be used to offer formatting and permanent mounting hdd="" sizeDataPartition=0 - OSPartition=$(sudo df /usr | grep dev | cut -d " " -f 1 | sed "s/\/dev\///g") + OSPartition=$(sudo df /usr | grep dev | cut -d " " -f 1 | sed "s#/dev/##g") + # detect boot partition on UEFI systems + bootPartition=$(sudo df /boot/efi | grep dev | cut -d " " -f 1 | sed "s#/dev/##g") + if [ ${#bootPartition} -eq 0 ]; then + # for non UEFI + bootPartition=$(sudo df /boot | grep dev | cut -d " " -f 1 | sed "s#/dev/##g") + fi lsblk -o NAME,SIZE -b | grep -P "[s|vn][dv][a-z][0-9]?" > .lsblk.tmp while read line; do @@ -110,11 +116,12 @@ if [ "$1" = "status" ]; then #echo "# testpartitioncount($testpartitioncount)" #echo "# testpartitioncount(${testpartitioncount})" #echo "# OSPartition(${OSPartition})" + #echo "# bootPartition(${bootPartition})" #echo "# hdd(${hdd})" if [ $testpartitioncount -gt 0 ]; then - # if a partition was found - make sure to skip OS partition - if [ "$testpartition" != "$OSPartition" ]; then + # if a partition was found - make sure to skip the OS and boot partitions + if [ "$testpartition" != "$OSPartition" ] && [ "$testpartition" != "$bootPartition" ]; then # make sure to use the biggest if [ ${testsize} -gt ${sizeDataPartition} ]; then sizeDataPartition=${testsize}