I want to reliably and thoroughly identify that a usb pendrive has been connected. I'm using a reduced version¹ of Debian Buster packed in a live ISO image running in VirtualBox.
The process of scanning and identifying is made through a bash script, basically a while loop that is triggered after some user action. The script will always run in the mentioned OS above. It's not that I just want to visually and occasionaly know the information.
Problem:
lsblk
,fdisk
only detect the already connected pendrives; when adding a new one, the commands won't see it.lsusb
,dmesg
,usb-devices
: the output of these commands are somewhat confusing to me, and I can't really find a distinctive pattern that lets me identify that the usb is a pendrive and not other usb device. Maybe you can point me to what pattern should I look like in any of these commands.udevadm
needs to be running before the pendrive is plugged. I can ask the user if they is going to plug a pendrive, tell them to wait a few seconds to plug, then runudevadm monitor
. But this seems to me a little cumbersome.
The solutions I'm pondering right know are in the lines of comparing a before and after of the output of the latter commands. But alas, I really don't like that kind of approach.
As you see I have a lot of options to work with, but my question is more about to find the most optimal and reliable solution.
¹ Details of this are important? I'm not sure.
kill -s
or IPC. – iFreilicht Oct 17 '20 at 22:50