Comment 3 for bug 1402280

Revision history for this message
Rob Thomas (xrobau) wrote :

As that was a bit of an interesting puzzle:

#!/bin/bash

# Basic HDD detection script.
# Written by Rob Thomas, <email address hidden>
# Code available under the licence of your choice.

ALLDISKS=$(parted -lms | awk 'found{ if(!/dev\/mapper/){print};found=0} /^BYT;$/{found=1}')

while read -r l; do
        RAWDISK=`echo "$l" | cut -d: -f1 | sed -r 's/\//!/g; s/!dev!//'`
        SSD="?"
        if [ -e "/sys/block/$RAWDISK/queue/rotational" ]; then
                SSD=`cat /sys/block/$RAWDISK/queue/rotational`
        fi
        echo $l$SSD
done <<< "$ALLDISKS"

That will append ? (if there's an error), 0 or 1 to the end of the string