Info über Wechseldatenträger: Unterschied zwischen den Versionen

Aus Si:Wiki von Siegrist SystemLösungen - Informatik und Rezepte
Wechseln zu: Navigation, Suche
K
 
(2 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
  
Get some info about removable devices like Device, Vendor, Model, Serial etc.
+
:Script for getting some info about removable devices eg. Device, Vendor, Model, Serial etc.
Useful for creating UDEV-Rules.
+
:Useful for creating UDEV-Rules.
 +
 
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">

Aktuelle Version vom 17. Januar 2020, 02:25 Uhr

Script for getting some info about removable devices eg. Device, Vendor, Model, Serial etc.
Useful for creating UDEV-Rules.


#!/bin/bash
 
REMOVABLE_DRIVES=""
i=0
for _device in /sys/block/*/device; do
    if echo $(readlink -f $_device)|egrep -q "usb"; then
        _disk=`echo $_device | cut -f4 -d/`
        _path=`echo $_device | cut -f5 -d/ --complement`
        _id_devname=`udevadm info --export --query=all --path=$_path | grep DEVNAME= | cut -f2 -d=`
        _id_model=`udevadm info --export --query=all --path=$_path | grep ID_MODEL= | cut -f2 -d=`
        _id_fs_type=`udevadm info --export --query=all --path=$_path | grep ID_FS_TYPE= | cut -f2 -d=`
        _id_vendor=`udevadm info --export --query=all --path=$_path | grep ID_VENDOR= | cut -f2 -d=`
        _id_serial=`udevadm info --export --query=all --path=$_path | grep ID_SERIAL= | cut -f2 -d=`
 
        echo -e "\nDevice : $_id_devname\nModel  : $_id_model\nVendor : $_id_vendor\nFS-Type: $_id_fs_type\nSerial : $_id_serial\nPath   : $_path"
 
        REMOVABLE_DRIVES="$REMOVABLE_DRIVES $_disk"
        ((i++))
    fi
done
echo -e "\n$i Removable drive(s) found: $REMOVABLE_DRIVES\n"