3 # reports whether the disk partition provided is spinning physical media or solid state.
4 # if no partition is specified, then /dev/sda is the default.
6 source "$FEISTY_MEOW_SCRIPTS/core/functions.sh"
10 # plug in a default drive if none is provided.
11 if [ -z "$drive" ]; then drive="sda"; fi
13 # chop off the /dev/ portion of the disk partition name, if it exists.
14 if [[ "$drive" =~ ^/dev/.*$ ]]; then
15 drive="$(echo "$drive" | sed -e 's/^\/dev\///')"
16 # echo "after mangle, drive is: '$drive'"
19 #hmmm: could do the check on multiple drives if weren't so lazy.
21 # let's make sure that the drive exists...
22 if [ ! -e "/sys/block/${drive}/queue/rotational" ]; then
23 false || exit_on_error "failed to find a record for drive '$drive'"
26 # the value for the block device's rotational parameter should be 1 for hard
27 # disks and 0 for SSDs. apparently the linux kernel has supported this check
28 # since version 2.6.29.
29 if [ $(cat /sys/block/${drive}/queue/rotational) -eq 0 ]; then
30 echo "drive $drive is a solid state disk."
32 echo "drive $drive is a spinning physical disk."