ordered into /lib

put all subscripts into lib for readability
This commit is contained in:
2026-07-14 16:56:28 +02:00
parent 925c624351
commit 20781c9d90
11 changed files with 6 additions and 20 deletions

25
lib/drives.sh Normal file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
function drives(){
local OUT_FILE=$1
DISKS=$(lsblk -d -n -o NAME,TYPE | awk '$2=="disk"{print $1}')
for disk in $DISKS; do
DEV="/dev/$disk"
SIZE=$(lsblk -d -n -o SIZE "$DEV")
MODEL=$(lsblk -d -n -o MODEL "$DEV" | sed 's/ *$//')
TRAN=$(lsblk -d -n -o TRAN "$DEV")
ROTA=$(cat /sys/block/$disk/queue/rotational 2>/dev/null)
TYPE="Unknown"
# NVMe drives are typically M.2 (or PCIe SSD)
if [[ "$disk" == nvme* ]]; then
TYPE="M.2 / NVMe SSD"
else
if [[ "$ROTA" == "1" ]]; then
TYPE="HDD"
elif [[ "$ROTA" == "0" ]]; then
TYPE="SSD"
fi
fi
echo -e "DEV:$DEV\tSIZE:$SIZE\tTYPE:$TYPE" >>"$OUT_FILE"
done
}