List Pen Drives on Linux Lazarus lazarus / 32-Linux ---------------------------------------------------------------------- junioraxis · 2021-02-02 16:42 Would anyone know how I can list the connected flash drives, this on Linux? I researched in the brazilian community  and had no answers. And would it be possible to know the storage size of this flash drive? ---------------------------------------------------------------------- MarkMLl · 2021-02-02 18:04 What's a pen drive? I'm not trying to be funny, but you need to ask yourself: what distinguishes it from any other type of (storage) device? If your pogrom is guaranteed to be active then you could probably hook hotplug events... I've done that for mouse-type devices and it wasn't difficult, although I don't know what's available pre-packaged. If it's not guaranteed to be active, then you will probably need to look in the /sys tree, but be warned that parsing that can end up being very hard work. Alternatively you could run lsblk periodically, or (better) look to see what it's doing. Ditto lsusb. MarkMLl ---------------------------------------------------------------------- winni · 2021-02-02 19:24 Hi! Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i cat /sys/kernel/debug/usb/devices gives you a comfortable list of all USB devices (example at bottom). In the lines prefixed with S: you can see the needed information like: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i S:  Manufacturer=TOSHIBAS:  Product=External USB 3.0S:  SerialNumber=xxxxxxxxxxxxxxx  Here a part of the list: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i .....T:  Bus=03 Lev=01 Prnt=01 Port=03 Cnt=02 Dev#=  3 Spd=1.5  MxCh= 0D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1P:  Vendor=046d ProdID=c077 Rev=72.00S:  Manufacturer=LogitechS:  Product=USB Optical MouseC:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mAI:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=02 Driver=usbhidE:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=10ms....  Winni ---------------------------------------------------------------------- MarkMLl · 2021-02-02 19:29 Quote from: winni on February 02, 2021, 08:24:54 pmCode: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i cat /sys/kernel/debug/usb/devices  Needs root access (or equivalent capability) on at least some distreaux. MarkMLl ---------------------------------------------------------------------- winni · 2021-02-02 21:01 Quote from: MarkMLl on February 02, 2021, 08:29:37 pmQuote from: winni on February 02, 2021, 08:24:54 pmCode: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i cat /sys/kernel/debug/usb/devices  Needs root access (or equivalent capability) on at least some distreaux. MarkMLl Hi! You are right . They call it progress but it is full of disadvantages. Good old /proc filesystem can be read by everybody. I forgot about that "progress". But to show all connected devices you could use Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i df -h | grep /dev/sd  Now you must know your internal drives. The rest are external USB devices. Winni ---------------------------------------------------------------------- MarkMLl · 2021-02-02 21:30 Quote from: winni on February 02, 2021, 10:01:43 pmBut to show all connected devices you could use Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i df -h | grep /dev/sd  df shows filesystems, not devices. Sorry :-) lsblk, or very tedious parsing of other parts of /sys (I think it's only /sys/kernel/debug which is unreadable). MarkMLl ---------------------------------------------------------------------- winni · 2021-02-02 22:06 Quote from: MarkMLl on February 02, 2021, 10:30:15 pmQuote from: winni on February 02, 2021, 10:01:43 pmBut to show all connected devices you could use Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i df -h | grep /dev/sd  df shows filesystems, not devices. Sorry :-) MarkMLl df  shows both, the devicess and the filesystem. Otherwise I could not grep for /dev/sd* Sorry ---------------------------------------------------------------------- MarkMLl · 2021-02-02 22:14 Quote from: winni on February 02, 2021, 11:06:38 pmdf  shows both, the devicess and the filesystem. Otherwise I could not grep for /dev/sd* Yes, and it does things like showing multiple entries for a device if it's partitioned, and it won't show a device which has been plugged in but not mounted. It's not the right tool for the job. MarkMLl ---------------------------------------------------------------------- winni · 2021-02-02 22:21 Oh oh oh A) Perhaps you can distinguish sda1 from sda2. The Linux system anyway is able. B) In Linux terms everything in /dev is a device. No matter if it is sda, sda1 or sda5 C) Junioraxis aked for connected drives. That's why I used df ---------------------------------------------------------------------- lucamar · 2021-02-02 22:57 Quote from: winni on February 02, 2021, 11:21:42 pmC) Junioraxis aked for connected drives. That's why I used df "Connected" doesn't mean "mounted". If a pen-drive is connected (i.e. physically plugged, powered and recognized by the system) but not mounted, df will completely ignore it. Look at the image: Quite a lot of partitions in the internal disk and a connected thumb-drive; what shows your command? Just the two currently mounted partitions. ---------------------------------------------------------------------- winni · 2021-02-02 23:12 Hi! No. "Connected" is ambiguous. Does it mean logical connected to the filesystem aka mounted? Or does it just mean "plugged in" - but not mounted. Before this peanut discussion goes any further this must be decided. By junioraxis. Winni ---------------------------------------------------------------------- Guva · 2021-03-24 13:27 Quote from: junioraxis on February 02, 2021, 05:42:11 pmWould anyone know how I can list the connected flash drives, this on Linux? I researched in the brazilian community  and had no answers. And would it be possible to know the storage size of this flash drive? look here https://github.com/GuvaCode/formatmydrive-pascal https://github.com/itmitica/laddiso ---------------------------------------------------------------------- benohb · 2021-03-25 02:52 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ls /dev/disk/by-id/You will find all kinds of discs And the beginning of the name is the type usb-xxxxxxxxxx ata-xxxxxxxxxx wwn-xxxxxxxxxx It is an Shortcut of the real name of the disk and its partitions ---------------------------------------------------------------------- MarkMLl · 2021-03-25 08:42 Quote from: benohb on March 25, 2021, 03:52:42 am Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ls /dev/disk/by-id/You will find all kinds of discs And the beginning of the name is the type usb-xxxxxxxxxx ata-xxxxxxxxxx wwn-xxxxxxxxxx It is an Shortcut of the real name of the disk and its partitions But that identifies *PARTITIONS*, and OP asked for *DISKS*. What's more he specifically asked for pen drives, and while these are almost always USB-connected there's other types of USB-connected media which he probably wants to exclude. As several of us have concluded, we can't really arrive at an answer until OP clarifies what he actually wants... and he seems to have wandered off. MarkMLl