mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-09-27 12:06:36 +02:00
Fixing detection of HDD/SSD without partition (#1603)
This commit is contained in:
committed by
rootzoll
parent
a584d4687e
commit
666605d26b
@@ -79,18 +79,37 @@ if [ "$1" = "status" ]; then
|
|||||||
echo "# SETUP INFO"
|
echo "# SETUP INFO"
|
||||||
|
|
||||||
# find the HDD (biggest single partition)
|
# find the HDD (biggest single partition)
|
||||||
|
hdd=""
|
||||||
sizeDataPartition=0
|
sizeDataPartition=0
|
||||||
lsblk -o NAME,SIZE -b | grep "[^|*][s|v]d[a-z][0-9]" > .lsblk.tmp
|
lsblk -o NAME,SIZE -b | grep -P "[s|v]d[a-z][0-9]?" > .lsblk.tmp
|
||||||
while read line; do
|
while read line; do
|
||||||
testdevice=$(echo $line | cut -d " " -f 1)
|
|
||||||
testsize=$(echo $line | cut -d " " -f 2)
|
# cut line info into different informations
|
||||||
if [ ${testsize} -gt ${sizeDataPartition} ]; then
|
testname=$(echo $line | cut -d " " -f 1 | sed 's/[^a-z0-9]*//g')
|
||||||
sizeDataPartition=${testsize}
|
testdevice=$(echo $testname | sed 's/[^a-z]*//g')
|
||||||
hddDataPartition="${testdevice:2:4}"
|
testpartition=$(echo $testname | grep -P '[a-z]{3,5}[0-9]{1}')
|
||||||
hdd="${hddDataPartition:0:3}"
|
testsize=$(echo $line | sed "s/ */ /g" | cut -d " " -f 2 | sed 's/[^0-9]*//g')
|
||||||
|
#echo "# line($line)"
|
||||||
|
#echo "# testname(${testname}) testdevice(${testdevice}) testpartition(${testpartition}) testsize(${testsize})"
|
||||||
|
|
||||||
|
# if no matching device found yet - take first for the beginning (just in case no partions at all)
|
||||||
|
if [ ${#hdd} -eq 0 ]; then
|
||||||
|
hdd="${testdevice}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# if a partition was found - make sure to use the biggest
|
||||||
|
if [ ${#testpartition} -gt 0 ] && [ ${testsize} -gt ${sizeDataPartition} ]; then
|
||||||
|
sizeDataPartition=${testsize}
|
||||||
|
hddDataPartition="${testpartition}"
|
||||||
|
hdd="${testdevice}"
|
||||||
|
fi
|
||||||
|
|
||||||
done < .lsblk.tmp
|
done < .lsblk.tmp
|
||||||
rm -f .lsblk.tmp 1>/dev/null 2>/dev/null
|
rm -f .lsblk.tmp 1>/dev/null 2>/dev/null
|
||||||
|
if [ ${#hddDataPartition} -lt 4 ]; then
|
||||||
|
echo "# WARNING: found invalid partition (${ddDataPartition}) - redacting"
|
||||||
|
hddDataPartition=""
|
||||||
|
fi
|
||||||
isSSD=$(sudo cat /sys/block/${hdd}/queue/rotational 2>/dev/null | grep -c 0)
|
isSSD=$(sudo cat /sys/block/${hdd}/queue/rotational 2>/dev/null | grep -c 0)
|
||||||
|
|
||||||
echo "hddCandidate='${hdd}'"
|
echo "hddCandidate='${hdd}'"
|
||||||
@@ -125,7 +144,7 @@ if [ "$1" = "status" ]; then
|
|||||||
mountError=""
|
mountError=""
|
||||||
sudo mkdir -p /mnt/hdd
|
sudo mkdir -p /mnt/hdd
|
||||||
if [ "${hddFormat}" = "ext4" ]; then
|
if [ "${hddFormat}" = "ext4" ]; then
|
||||||
hddDataPartitionExt4=$hddDataPartition
|
hddDataPartitionExt4=$hddDataPartition
|
||||||
mountError=$(sudo mount /dev/${hddDataPartitionExt4} /mnt/hdd 2>&1)
|
mountError=$(sudo mount /dev/${hddDataPartitionExt4} /mnt/hdd 2>&1)
|
||||||
isTempMounted=$(df | grep /mnt/hdd | grep -c ${hddDataPartitionExt4})
|
isTempMounted=$(df | grep /mnt/hdd | grep -c ${hddDataPartitionExt4})
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user