How to find the /dev name of my USB device

46

21

I am running a Ubuntu 11 guest on a Windows XP host with VMware. I want to format an SD card in Ubuntu, but I can't figure out which /dev/xxx device the SD card is.

I plug the card into the built-in socket of my laptop. I "safely remove" the device in Windows. Then, I "connect" the PCMCIA reader in VMware. Now, I was supposed to see a new device like /dev/sdx, but it doesn't appear.

How can I find what the name of my USB device's name and mount it?

/var/log/message is empty.

Here is the output of dmesg:

[ 5268.927308] usb 2-1: new full speed USB device number 12 using uhci_hcd

And, here are the last lines of /var/log/syslog:

Oct 31 18:51:21 ubuntu kernel: [ 5268.927308] usb 2-1: new full speed USB device number 12 using uhci_hcd

Oct 31 18:51:21 ubuntu mtp-probe: checking bus 2, device 12: "/sys/devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-1"

Oct 31 18:51:21 ubuntu mtp-probe: bus: 2, device: 12 was not an MTP device

mustafa

Posted 2011-10-31T17:03:36.037

Reputation: 564

This should be on askubuntu.com or unix.stackexchange.com

– Martin Thoma – 2015-05-13T10:11:38.613

Ubuntu 11 does not have /var/log/messages... – None – 2011-10-31T17:12:27.113

Answers

69

Try lsblk. This is the output from my current setup:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465.8G  0 disk 
├─sda1   8:1    0 195.3G  0 part 
├─sda2   8:2    0     4G  0 part [SWAP]
└─sda3   8:3    0 266.5G  0 part /
sdb      8:16   0 465.8G  0 disk 
└─sdb1   8:17   0 460.8G  0 part /home
sr0     11:0    1  1024M  0 rom  

I'm using Ubuntu 12.10.

kinsago

Posted 2011-10-31T17:03:36.037

Reputation: 691

21

ls -1 /dev > ~/before.txt

plug it in, then

ls -1 /dev > ~/after.txt

diff ~/before.txt ~/after.txt

Koen

Posted 2011-10-31T17:03:36.037

Reputation: 211

1Like a true programmer solution. +1 – GeneCode – 2018-08-10T00:15:57.103

3

lsblk seems to work:

rishi@rishi-Inspiron-1018:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 232.9G  0 disk 
├─sda1   8:1    0 230.9G  0 part /
├─sda2   8:2    0     1K  0 part 
└─sda5   8:5    0     2G  0 part [SWAP]
sdb      8:16   1   7.4G  0 disk 
└─sdb1   8:17   1   7.4G  0 part /media/3765-3233

So now I know my SD card is in /dev/sdb1.

Rishi

Posted 2011-10-31T17:03:36.037

Reputation: 31

Suspect. When using Debian live, I saw sdc (my usb device) listed in lsblk output but not in /dev. – user982671 – 2014-10-28T18:47:24.173

1It'll appear in /dev only if udev is present (or an equivalent), and as a rule to create the node in it. Does not mean it can't be used, you can create the node where you want, since you have the Major/Minor number in lsblk. – xryl669 – 2016-06-03T11:34:33.447

2

Try using lsusb to see if the sd card reader is picked up in virtualbox. Another option would be to use palimpsest (also known by its menu entry, Disk Utility.)

Don't be afraid to use the GUI programs - they do work! If palimpsest sees your device, it will tell you the device node, so you can use the CLI utilities.

Broam

Posted 2011-10-31T17:03:36.037

Reputation: 3 831

1

You could use bootiso utility, which has a flag to do exactly that:

> bootiso -l
Listing USB drives available in your system:
NAME                HOTPLUG   SIZE STATE   TYPE
sdd                       1  14,7G running disk
sde                       1   961M running disk

To install it:

curl -L https://rawgit.com/jsamr/bootiso/latest/bootiso -O
chmod +x bootiso

Jules Randolph

Posted 2011-10-31T17:03:36.037

Reputation: 347

1

If it has a label use /dev/disk/by-label/[USB label] to format the disk

EDIT: Try /dev/disk/by-id/usb*

Will03uk

Posted 2011-10-31T17:03:36.037

Reputation: 173

no, it doesn't have :( – None – 2011-10-31T17:30:38.843

aren't there any other methods? – None – 2011-10-31T20:35:06.843

USBs are usually /dev/sb followed by a number, or something along thoses lines if I'm not completely correct, it might be /dev/sdb followed by a number but not normally /dev/sda, so if there's only one plugged in that should do it – Will03uk – 2011-10-31T23:32:00.793

1

Open a terminal and run ls /dev before you enable that USB device in vmware. Run ls /dev/ again after you enabled it and look for what pops up

xiamx

Posted 2011-10-31T17:03:36.037

Reputation: 420

this is the most painful way of doing it, not to mention, many devices have numerous instances in /dev/ once they get initialized. – j0h – 2016-12-09T02:19:09.833

0

I am new to linux, but so far I have found 3 ways to find out a device name:

1) lsblk (already mentioned above, lists device names and the folder they are mounted on)

2) sudo fdisk -l (lists device names, here you can also see the names of partitions)

3) dmesg immediately after you have inserted an usb stick (a lot of output, don't really know yet what they are for, but the last entries show the name of the inserted name somewhere)

mkdrive2

Posted 2011-10-31T17:03:36.037

Reputation: 101

0

It is important to differentiate between two scenarios:

  1. The USB stick is plugged in, and recognized and accessible in the file browser, then it got automatically mounted;
  2. After the device was plugged in and got mounted, you have ejected/unmounted the device, and now it is safe to unplug.

In the first case, using lsblk will list all the mounted devices. Under the MOUNTPOINT column you should see your USB device listed being mounted somewhere under /run/media/.

In the second case (after you have ejected the device), even though lsblk will not list anything, the dev file should be still the same as when it was mounted. You can verify it is still there with lsblk --all. But as it is unmounted now, the MOUNTPOINT column will be empty.

For example, suppose you want to dd an iso image to a USB stick. First plug in the stick, then look with lsblk for the associated dev file (based on the MOUNTPOINT), then unmount/eject the mounted device and use dd if=stuff.iso of=/dev/sdX to write your image. These steps are important, as it is not a good idea to overwrite a mounted device.

Daniel Dinnyes

Posted 2011-10-31T17:03:36.037

Reputation: 393

0

sudo fdisk -l will list the partition table on all available hard disks; it uses the Linux naming scheme for disks, handy for troubleshooting and remembering which partition is where.

Use man fdisk for more information on the parameters of fdisk.

Rob

Posted 2011-10-31T17:03:36.037

Reputation: 2 152

0

# dir /dev/disk/by-path/
total 0
drwxr-xr-x. 2 root root 180 Aug 26 15:51 .
drwxr-xr-x. 6 root root 120 Aug 25 17:20 ..
lrwxrwxrwx. 1 root root   9 Aug 25 17:12 pci-0000:00:03.2-usb-0:3:1.0-scsi-0:0:0:0 -> ../../sr0
lrwxrwxrwx. 1 root root   9 Aug 26 15:51 pci-0000:00:03.2-usb-0:4.1.1:1.0-scsi-0:0:0:0 -> ../../sdb
lrwxrwxrwx. 1 root root  10 Aug 26 15:51 pci-0000:00:03.2-usb-0:4.1.1:1.0-scsi-0:0:0:0-part1 -> ../../sdb1
lrwxrwxrwx. 1 root root  10 Aug 26 15:51 pci-0000:00:03.2-usb-0:4.1.1:1.0-scsi-0:0:0:0-part2 -> ../../sdb2
lrwxrwxrwx. 1 root root  10 Aug 26 15:51 pci-0000:00:03.2-usb-0:4.1.1:1.0-scsi-0:0:0:0-part3 -> ../../sdb3
lrwxrwxrwx. 1 root root   9 Aug 25 17:12 pci-0000:07:00.0-scsi-0:2:0:0 -> ../../sda
lrwxrwxrwx. 1 root root  10 Aug 25 17:12 pci-0000:07:00.0-scsi-0:2:0:0-part1 -> ../../sda1

and

# dir /dev/disk/by-id/
total 0
drwxr-xr-x. 2 root root 280 Aug 27 01:20 .
drwxr-xr-x. 6 root root 120 Aug 25 17:20 ..
lrwxrwxrwx. 1 root root  10 Aug 25 17:20 dm-name-VG_RAID_201010081812-LV_RAID_201010081617 -> ../../dm-0
lrwxrwxrwx. 1 root root  10 Aug 27 01:20 dm-name-top4 -> ../../dm-2
lrwxrwxrwx. 1 root root  10 Aug 25 17:20 dm-uuid-LVM-XCQXKaPB3snmEgx9ZNGRssIxGmJPje6TXKMLyop5meKH3x3KiJ1H1q3aoqgXpci1 -> ../../dm-0
lrwxrwxrwx. 1 root root   9 Aug 25 17:12 scsi-36842b2b04963f900144207e1091bf90c -> ../../sda
lrwxrwxrwx. 1 root root  10 Aug 25 17:12 scsi-36842b2b04963f900144207e1091bf90c-part1 -> ../../sda1
lrwxrwxrwx. 1 root root   9 Aug 25 17:12 usb-ASUS_SBW-06D2X-U_3248433031354B4A30303030-0:0 -> ../../sr0
lrwxrwxrwx. 1 root root   9 Aug 26 15:51 usb-ST916041_2AS_579FFFFFFFFF-0:0 -> ../../sdb
lrwxrwxrwx. 1 root root  10 Aug 26 15:51 usb-ST916041_2AS_579FFFFFFFFF-0:0-part1 -> ../../sdb1
lrwxrwxrwx. 1 root root  10 Aug 26 15:51 usb-ST916041_2AS_579FFFFFFFFF-0:0-part2 -> ../../sdb2
lrwxrwxrwx. 1 root root  10 Aug 26 15:51 usb-ST916041_2AS_579FFFFFFFFF-0:0-part3 -> ../../sdb3
lrwxrwxrwx. 1 root root   9 Aug 25 17:12 wwn-0x6842b2b04963f900144207e1091bf90c -> ../../sda
lrwxrwxrwx. 1 root root  10 Aug 25 17:12 wwn-0x6842b2b04963f900144207e1091bf90c-part1 -> ../../sda1

Jason Pyeron

Posted 2011-10-31T17:03:36.037

Reputation: 101