How can I get a list of removable drives (plugged into USB) in Linux? I'm fine with using KDE, GNOME or other DE libraries if it would make things easier.
Enter the following command: Get-PnpDevice -PresentOnly | Where-Object { $_. InstanceId -match '^USB' } . That command will show a list of all present USB devices.
The number one way an Ubuntu user can view all connected USB devices is with the lsusb command. This command literally means “list USB,” and it does exactly that — it lists all of your USB devices, their IDs, names, etc. To get started, open up a terminal window on the Ubuntu desktop.
I think a nice idea is to use udev interface from python.
Small example (of course in your case you have adjust some filtering):
In [1]: import pyudev
In [2]: pyudev.Context()
In [3]: ctx = pyudev.Context()
In [4]: list(ctx.list_devices(subsystem='usb'))
Out[4]:
[Device(u'/sys/devices/pci0000:00/0000:00:1a.0/usb2'),
Device(u'/sys/devices/pci0000:00/0000:00:1a.0/usb2/2-0:1.0'),
Device(u'/sys/devices/pci0000:00/0000:00:1a.0/usb2/2-2'),
It is a good way in most cases as new systems use udev.
After all this time the question got unlocked again…
In the end I used UDisks via the D‐Bus interface like shown here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With