Commit 4924227d authored by Vitaly Lipatov's avatar Vitaly Lipatov

print_disks.sh: print drive info

parent 4bbfa5a1
......@@ -27,6 +27,20 @@ print_dev_type()
is_hdd "$1" && echo "HDD" || echo "SSD"
}
# file field
# Example: /tmp/lala "Serial Number"
get_smart_field()
{
cat "$1" | grep "$2: " | tail -n1 | sed -e "s/.*$2: *//g"
}
print_drive_info()
{
local TF=$(mktemp)
smartctl -i $1 >$TF
echo "Model: $(get_smart_field $TF "Model Family") $(get_smart_field $TF "Device Model") Serial: $(get_smart_field $TF "Serial Number") Firmware: $(get_smart_field $TF "Firmware Version")"
rm -f $TF
}
# https://unix.stackexchange.com/questions/65595/how-to-know-if-a-disk-is-an-ssd-or-an-hdd
# lsblk -d -o name,rota
......
......@@ -51,7 +51,7 @@ for i in $PHYSORDER ; do
health $DEV || echo "NACCESS to $DEV"
MD="$(print_md $DEV)"
# TYPE SIZE DEV SERIAL MD
printf "%3s %7s %-10s %4s %10s\n" "$(print_dev_type $DEV)" "$(print_size $DEV)" "$DEV" "$(print_serno $DEV)" "$MD"
printf "%3s %7s %-10s %4s %10s %s\n" "$(print_dev_type $DEV)" "$(print_size $DEV)" "$DEV" "$(print_serno $DEV)" "$MD" "$(print_drive_info $DEV)"
if [ -z "$MD" ] ; then
for pd in $DEV* ; do
MD="$(print_md $pd)"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment