Скрипт для просмотра свойств USB-дисков

Найдено на http://www.unix.com

Автор: Corona688

Код:

#!/bin/bash

for DEV in /sys/block/sd*
do
    if readlink $DEV/device | grep -q usb
        then
        DEV=`basename $DEV`
        echo "$DEV is a USB device, info:"
        udevinfo --query=all --name $DEV
            if [ -d /sys/block/${DEV}/${DEV}1 ]
                then
                echo "Has partitions " /sys/block/$DEV/$DEV[0-9]*
                else
                echo "Has no partitions"
            fi
        echo ""
    fi
done

exit 0

Вывод для одной флешки с двумя разделами:

sdc is a USB device, info:
P: /block/sdc
N: sdc
S: disk/by-id/usb-JetFlash_TS16GJFV85_HUW7YBCQ-0:0
S: disk/by-path/pci-0000:00:1d.7-usb-0:6:1.0-scsi-0:0:0:0
E: ID_VENDOR=JetFlash
E: ID_MODEL=TS16GJFV85
E: ID_REVISION=8.07
E: ID_SERIAL=JetFlash_TS16GJFV85_HUW7YBCQ-0:0
E: ID_SERIAL_SHORT=HUW7YBCQ
E: ID_TYPE=disk
E: ID_INSTANCE=0:0
E: ID_BUS=usb
E: ID_PATH=pci-0000:00:1d.7-usb-0:6:1.0-scsi-0:0:0:0
Has partitions /sys/block/sdc/sdc1 /sys/block/sdc/sdc2

Назад