Info über Wechseldatenträger: Unterschied zwischen den Versionen

Aus Si:Wiki von Siegrist SystemLösungen - Informatik und Rezepte
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: « Get some info about removable devices like Device, Vendor, Model, Serial etc. Useful for creating UDEV-Rules. <syntaxhighlight lang="sh"> #!/bin/bash REMOVAB…»)
 
K
 
(3 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="sh">
+
 
 +
<syntaxhighlight lang="bash">
  
 
#!/bin/bash
 
#!/bin/bash
Zeile 14: Zeile 15:
 
         _path=`echo $_device | cut -f5 -d/ --complement`
 
         _path=`echo $_device | cut -f5 -d/ --complement`
 
         _id_devname=`udevadm info --export --query=all --path=$_path | grep DEVNAME= | cut -f2 -d=`
 
         _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_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_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_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=`
 
         _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"
 
         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"
 
         REMOVABLE_DRIVES="$REMOVABLE_DRIVES $_disk"
 
         ((i++))
 
         ((i++))

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"