forked from BloodBlight/CephNotes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ListDisks
17 lines (17 loc) · 874 Bytes
/
ListDisks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
fdisk -l | grep Disk | sort | grep --color=auto '\/sd\|\/nvm' | while read line ; do
Device=`echo $line | cut -d ' ' -f 2 | cut -d ':' -f 1`
udevadm info --query=all -n $Device > /dev/shm/tmp.ListDisks
if [[ $Device == *nvme* ]]; then
Mode="NVMe"
else
ID_PATH=`cat /dev/shm/tmp.ListDisks | grep 'ID_PATH='`
echo $ID_PATH | grep -i USB &> /dev/null && Mode="USB"
echo $ID_PATH | grep -i ATA &> /dev/null && Mode="ATA"
echo $ID_PATH | grep -i SAS &> /dev/null && Mode="SAS"
fi
ID_MODEL=`cat /dev/shm/tmp.ListDisks | grep 'ID_MODEL=' | sed 's\[\]x20\ \g' | cut -d '=' -f 2`
ID_SERIAL_SHORT=`cat /dev/shm/tmp.ListDisks | grep 'ID_SERIAL_SHORT=' | cut -d '=' -f 2`
Size=`echo $line | cut -d ' ' -f 3-4`
echo "Device: $Device, Size: $Size Model: $ID_MODEL, Serial: $ID_SERIAL_SHORT, Mode: $Mode" | tr -s ' ' | sed 's\ ,\,\g'
done