If it finds a device there both is true it prints the device node with the corresponding device serial. This script checks for every block device if it is attached to the USB bus (via property ID_BUS) and if it is a disk (via property ID_TYPE). Serial=$(udevadm info -query=property -path="/sys/block/$block_device" | grep "^ID_SERIAL=" | cut -d "=" -f 2)Įcho "/dev/$block_device ($serial) is an USB disk." Is_disk=$(udevadm info -query=property -path="/sys/block/$device" | grep -i "^ID_TYPE=disk$") Is_usb_attached=$(udevadm info -query=property -path="/sys/block/$device" | grep -i "^ID_BUS=usb$") Here is a short script which checks every device under /sys/block if it is an USB drive: #!/bin/bash ![]() An USB thumb drive should show up in sysfs under /sys/block/ and should be named sd*.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |