LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   command line; how identify which /dev/??? a device is on (http://www.linuxquestions.org/questions/slackware-14/command-line%3B-how-identify-which-dev-a-device-is-on-4175443026/)

porphyry5 12-26-2012 03:47 PM

command line; how identify which /dev/??? a device is on
 
As root, when I plug in a USB device, like my ebook reader or mp3 player, how do I determine which /dev/??? it is on in order to mount it?

I checked the output of dmesg immediately after inserting the device (below), but am none the wiser.
Code:

[ 5499.914031] usb 1-3: new high-speed USB device number 6 using ehci_hcd
[ 5502.799271] hub 1-0:1.0: unable to enumerate USB device on port 3
[ 5503.109025] usb 1-3: new high-speed USB device number 7 using ehci_hcd
[ 5505.994271] hub 1-0:1.0: unable to enumerate USB device on port 3
[ 5506.303034] usb 1-3: new high-speed USB device number 8 using ehci_hcd
[ 5509.188272] hub 1-0:1.0: unable to enumerate USB device on port 3
[ 5537.126026] usb 1-6: reset high-speed USB device number 4 using ehci_hcd
[ 6816.927032] usb 1-3: new high-speed USB device number 9 using ehci_hcd
[ 6819.812291] hub 1-0:1.0: unable to enumerate USB device on port 3
[ 6820.123027] usb 1-3: new high-speed USB device number 10 using ehci_hcd


kabamaru 12-26-2012 03:54 PM

I use

Code:

fdisk -l

Habitual 12-26-2012 04:17 PM

Code:

df -hT
after it mounts.

michaelk 12-26-2012 04:35 PM

It depends. What is the make/model of your ebook reader? Post the output of the command lsusb.

Some devices use MTP (Media Transfer Protocol) and therefore are not recognised as mass storage devices. Applications to read/write to MTP require the libmtp package and there are many depending on if it is a MP3 player or digital camera etc as well as a fuse filesystem i.e. mtpfs that allows for mounting.

porphyry5 12-26-2012 05:02 PM

habamaru
Code:

fdisk -l
shows only my hard drives, internal and external, that are already mounted

Habitual
Code:

df -hT
can't use, because the objective is to find out how to mount the device by hand

michaelk The ereader is a StoryHD by iriver. Following is the output of lsusb, as it does not show there I assume it is an MTP device; except that my San Disk mp3 player does show and it seems to be am mtp device. libmtp is not installed, but there has to be another method because the file manager Dolphin will recognize the device and mount it
Code:

/home/g # lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 0bc2:2300 Seagate RSS LLC Expansion Portable
Bus 001 Device 004: ID 0bc2:50a5 Seagate RSS LLC FreeAgent GoFlex Desk USB 3.0
Bus 001 Device 005: ID 0bda:8187 Realtek Semiconductor Corp. RTL8187 Wireless Adapter
Bus 003 Device 002: ID 0458:003a KYE Systems Corp. (Mouse Systems) NetScroll+ Mini Traveler / Genius NetScroll 120
Bus 001 Device 013: ID 0781:74d0 SanDisk Corp. Sansa Clip+ (mtp)
Bus 001 Device 016: ID 04da:2372 Panasonic (Matsushita) Lumix Camera

Which suggested to me to have Dolphin mount it and then see what lsusb showed, and now it includes the line
Code:

Bus 001 Device 020: ID 1006:4034 iRiver, Ltd.
So can I maybe access it through its ID #?

ljb643 12-26-2012 07:14 PM

Do your plug-in devices have filesystems with volume labels? I recommend doing this - give them labels, like EBOOK or MP3. Then you can just use commands like this:

Code:

$ udisksctl mount -b /dev/disk/by-label/EBOOK
Mounted /dev/sdc1 at /run/media/yourname/EBOOK

(You do not need to be root for this.)

(Yes, this is a variation on the command I posted to your other question, where we knew the device name but not the volume label or mount point. The above is for when we know the volume label, but not the device name. -b is short for --block-device)

schneidz 12-26-2012 07:59 PM

i run sudo tail -f /var/log/messages (hit enter a few times to show some blank lines) then plug in my devices. the output of messages should contain info regarding those devices.

porphyry5 12-26-2012 08:02 PM

Quote:

Originally Posted by ljb643 (Post 4857380)
Do your plug-in devices have filesystems with volume labels? I recommend doing this - give them labels, like EBOOK or MP3. Then you can just use commands like this:

Code:

$ udisksctl mount -b /dev/disk/by-label/EBOOK
Mounted /dev/sdc1 at /run/media/yourname/EBOOK

(You do not need to be root for this.)

(Yes, this is a variation on the command I posted to your other question, where we knew the device name but not the volume label or mount point. The above is for when we know the volume label, but not the device name. -b is short for --block-device)

udisksctl was the first thing I tried to see if it would show me the /dev concerned, but it also requires that one have the device identified. I've not used labels, I use the UUID instead to mount by, which I get via this command
Code:

/home/g/ToInstall/1.1-release # blkid 
/dev/sda1: UUID="7c7321e2-73dc-4317-b32c-96dd46fa89db" TYPE="ext3"
/dev/sda2: UUID="c5856052-b2e2-4ddf-b922-5aac504ff08b" TYPE="ext4"
/dev/sda3: UUID="CA98993C98992849" TYPE="ntfs"
/dev/sda4: UUID="8fea16cb-844d-4dab-860b-dbece5c8b36d" TYPE="swap"
/dev/sdb1: LABEL="500gb" UUID="20801F50801F2BB2" TYPE="ntfs"
/dev/sdc1: LABEL="3tb" UUID="7A683F8C683F4663" TYPE="ntfs"
/dev/sdd: LABEL="SANSA CLIPP" UUID="6818-26B9" TYPE="vfat"
/dev/sdf: LABEL="Story HD" UUID="0000-001B" TYPE="vfat"

But blkid also only shows things that are already mounted, so I still haven't succeeded in finding the slackware linux command that will identify plug in devices before they are mounted. It has to exist, or these file managers like dolphin wouldn't be able to identify the things they mount.

ljb643 12-26-2012 08:13 PM

UUIDs are OK for things like internal hard disks, where you want to be sure you are talking about the right device, and you put them in fstab or whatever and never touch them. But volume labels are much handier for portable plug-in things.

Quote:

I still haven't succeeded in finding the slackware linux command that will identify plug in devices before they are mounted.
You need some way of referring to the device. If you know the device name, UUID, or volume label, you can get the other parts. But I don't think there is any such command that says: show me info on the most recently plugged in device. That's why I suggest using volume labels.

porphyry5 12-26-2012 08:33 PM

Quote:

Originally Posted by schneidz (Post 4857395)
i run sudo tail -f /var/log/messages (hit enter a few times to show some blank lines) then plug in my devices. the output of messages should contain info regarding those devices.

Thank you, that does show the device even though it is unmounted.

porphyry5 12-26-2012 08:59 PM

Quote:

Originally Posted by ljb643 (Post 4857403)
UUIDs are OK for things like internal hard disks, where you want to be sure you are talking about the right device, and you put them in fstab or whatever and never touch them. But volume labels are much handier for portable plug-in things.


You need some way of referring to the device. If you know the device name, UUID, or volume label, you can get the other parts. But I don't think there is any such command that says: show me info on the most recently plugged in device. That's why I suggest using volume labels.

May have solved the mystery. lsusb shows device information even when the device is unmounted. But it only registers my ereader if the device is turned on when I plug it into the computer. If its turned off when I plug it in, lsusb does not show it, even though the current in the usb plug causes the device to turn on. So both lsusb and schneidz's method using sudo tail -f /var/log/messages do the trick.

As it happens, blkid also shows it even though the device is not mounted, as long as the device is turned on before I plug it into the computer. Seems that was the entirety of the problem. I can mount the thing either by label or by UUID, but udisksctl has a problem.
Code:

/home/g # blkid
/dev/sda1: UUID="7c7321e2-73dc-4317-b32c-96dd46fa89db" TYPE="ext3"
/dev/sda2: UUID="c5856052-b2e2-4ddf-b922-5aac504ff08b" TYPE="ext4"
/dev/sda3: UUID="CA98993C98992849" TYPE="ntfs"
/dev/sda4: UUID="8fea16cb-844d-4dab-860b-dbece5c8b36d" TYPE="swap"
/dev/sdb1: LABEL="500gb" UUID="20801F50801F2BB2" TYPE="ntfs"
/dev/sdc1: LABEL="3tb" UUID="7A683F8C683F4663" TYPE="ntfs"
/dev/sdd: LABEL="Story HD" UUID="0000-001B" TYPE="vfat"
/home/g # mount  LABEL="Story HD" /mnt/dvd
/home/g # ls /mnt/dvd
book  comic  image  system
/home/g # umount /mnt/dvd
/home/g # mount UUID="0000-001B" /media/dvd1
/home/g # ls /media/dvd1
book  comic  image  system
/home/g # umount /media/dvd1
/home/g # su g
~ $ udisksctl mount -b /dev/disk/by-label/"Story HD"
Error looking up object for device /dev/disk/by-label/Story HD
~ $ su
Password:
/home/g # udisksctl mount -b /dev/disk/by-label/"Story HD"
Error looking up object for device /dev/disk/by-label/Story HD

And fdisk -l shows it too, if I turn the device on before connecting to the usb port.

porphyry5 12-26-2012 11:44 PM

Quote:

Originally Posted by kabamaru (Post 4857312)
I use

Code:

fdisk -l

Thank you, this does give me what I asked for, the /dev/ assignment when the device is connected. I got no response the first time I tried it so I assumed, as the device turned on automatically after I plugged it in to the usb port, that fdisk shows only mounted devices. But if I turn on the device first, then plug it into the usb port, fdisk shows it even though it is not mounted, only connected.


All times are GMT -5. The time now is 03:16 PM.