The Computer Oracle

How do I figure out which /dev is a USB flash drive?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Quirky Dreamscape Looping

--

Chapters
00:00 Question
01:03 Accepted answer (Score 89)
01:20 Answer 2 (Score 60)
01:44 Answer 3 (Score 57)
02:54 Answer 4 (Score 26)
04:05 Thank you

--

Full question
https://superuser.com/questions/361885/h...

Answer 2 links:
[udev]: http://wiki.archlinux.org/index.php/Udev

Answer 3 links:
[1]: https://lists.debian.org/debian-user/201...
[1]: https://lists.debian.org/debian-user/201...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#linux #usb

#avk47



ACCEPTED ANSWER

Score 95


Easiest way: Look at the output of dmesg after connecting the USB device. It should show you what /dev node was assigned to it.




ANSWER 2

Score 63


All of these are good suggestions, but the quickest and least verbose method is to just type the following in the terminal:

mount

which will give a list of all the mounted devices (this assumes the USB drive is mounted, which is usually the case with modern Linux distros).




ANSWER 3

Score 57


As long as you are running udev, you can do this easily by referencing /dev/disk/by-id/usb-manufacturername_serialnumber. These appear as symbolic links which you can either directly reference within your fstab, or which you can dereference using readlink -e to determine the associated block device.

Here's a real world example. On my machine, I have 3 USB hard drives connected. These each show up in /dev/disk/by-id with unique serial numbers (although they share a common manufacturer string). I have created symbolic links to each of these three unique entries, and can now quickly determine which drive is which (and which device is associated with each drive) by running readlink -e linkname. For example, running readlink -e /root/disk2 on my machine currently displays "/dev/sde", while readlink -e /root/disk3 produces no output whatsoever.




ANSWER 4

Score 29


Try the command udevinfo -q all -n /dev/sda, where /dev/sda is the path to your disk. This gives you a boatload of info about the disk you're looking at - there's an entry that tells you about the bus it's connected to.

This of course saves you from having to grep through dmesg and/or logs.

Update

udevadm info --query=all -n /dev/sda 

From at least Jul 2010 [1] udevinfo was substituted in Debian (and derived) by udevadm info with a little transient with which there were symlinks soon deprecated and removed (you can still found them in old not updated machine). Always from [1] we can read:

In udev 117, udevadm was introduced and udevinfo and other programs turned into compatibility symlinks. The symlinks were deprecated in udev 128 and removed for good in udev 147.