How do I figure out which /dev is a USB flash drive?
I want to mount a USB drive, two of them and I need two different mount points. Unfortunately, the Linux kernel underwent a name change and I can't figure out which /dev
location is the right one. Is there a way to look through dmesg
or /proc
or somewhere else to find out which device node is a USB drive.
(I'm using ArchLinux if that helps any.../dev/sda
is the first hard drive, /dev/sr0
is a dvd drive, etc.)
edit: The USB drive is connected to a USB hub. I looked through dmesg
and it says the hub was connected and it scanned for the 3 devices connected to it. Still can't see where my USB drive is though.
Solution 1:
Easiest way: Look at the output of dmesg
after connecting the USB device. It should show you what /dev
node was assigned to it.
Solution 2:
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).
Solution 3:
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.
Solution 4:
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 andudevinfo
and other programs turned into compatibility symlinks. The symlinks were deprecated in udev 128 and removed for good in udev 147.
Solution 5:
the simplest method to see what's going on is just typing (as root of course):
blkid -c /dev/null
this gives you a complete overview about all block devices even if not mounted