[SOLVED] command line; how identify which /dev/??? a device is on
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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.
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
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)
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.
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
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.
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.