0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ブロックデバイス名からUSBPortを探る

Last updated at Posted at 2021-06-01

概要

ブロックデバイス名からUSBデバイスの特定が面倒だったので手順を記す。

方法

まずはlsblkでブロックデバイス名を探します。
デフォルトではSERIALが表示されないので指定します。

$ lsblk -o NAME,TYPE,MOUNTPOINT,SERIAL
NAME                      TYPE MOUNTPOINT          SERIAL

略

sdh                       disk /mnt/hdd16          Z0I1S2NPABCD
sdi                       disk /mnt/hdd4           1910E1EF0000
sdj                       disk                     5643484854000000
sdk                       disk /mnt/hdd7           JMicron_Generic_0123456789ABCDEF
sdl                       disk /mnt/hdd10          56474A4745000000

/dev/sdjがマウントされていないので探します。

lsusbでツリー表示してみましょう。

$ lsusb -t
/:  Bus 12.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
    |__ Port 2: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
/:  Bus 11.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
/:  Bus 10.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
/:  Bus 09.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
/:  Bus 08.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 5000M
        |__ Port 3: Dev 7, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
        |__ Port 1: Dev 4, If 0, Class=Mass Storage, Driver=uas, 5000M
        |__ Port 4: Dev 9, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
        |__ Port 2: Dev 5, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
    |__ Port 2: Dev 3, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
    |__ Port 3: Dev 6, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
    |__ Port 4: Dev 8, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
/:  Bus 07.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
/:  Bus 06.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 5000M
        |__ Port 2: Dev 4, If 0, Class=Mass Storage, Driver=uas, 5000M
        |__ Port 3: Dev 5, If 0, Class=Mass Storage, Driver=uas, 5000M
        |__ Port 4: Dev 7, If 0, Class=Mass Storage, Driver=uas, 5000M
    |__ Port 2: Dev 3, If 0, Class=Mass Storage, Driver=uas, 5000M
    |__ Port 3: Dev 6, If 0, Class=Mass Storage, Driver=uas, 5000M
/:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    |__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
    |__ Port 2: Dev 3, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
    |__ Port 3: Dev 4, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
    |__ Port 4: Dev 5, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M

多すぎてさっぱりわかりません。

usb-devicesにはSerialNumberがあるので、

$ sudo usb-devices | grep -B 5 5643484854000000
T:  Bus=04 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#=  3 Spd=5000 MxCh= 0
D:  Ver= 3.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs=  1
P:  Vendor=1058 ProdID=25a3 Rev=10.30
S:  Manufacturer=Western Digital
S:  Product=Elements 25A3
S:  SerialNumber=5643484854000000

これでT:の行からBUS 04のPort 1が判明しました。

USBホストの位置はsub-devicesでBusのHOSTを探して、lspciであたりを付ければよいかと思います。

$ usb-devices | grep -A 5 "Bus=04 Lev=00"
T:  Bus=04 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=5000 MxCh= 4
D:  Ver= 3.00 Cls=09(hub  ) Sub=00 Prot=03 MxPS= 9 #Cfgs=  1
P:  Vendor=1d6b ProdID=0003 Rev=05.04
S:  Manufacturer=Linux 5.4.0-73-generic xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:00:14.0

$ lspci | grep USB
00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04)
00:1a.0 USB controller: Intel Corporation 7 Series/C216 Chipset Family USB Enhanced Host Controller #2 (rev 04)
00:1d.0 USB controller: Intel Corporation 7 Series/C216 Chipset Family USB Enhanced Host Controller #1 (rev 04)
01:00.0 USB controller: Renesas Technology Corp. uPD720201 USB 3.0 Host Controller (rev 03)
09:00.0 USB controller: Renesas Technology Corp. uPD720201 USB 3.0 Host Controller (rev 03)
0a:00.0 USB controller: ASMedia Technology Inc. ASM1042 SuperSpeed USB Host Controller
0f:00.0 USB controller: ASMedia Technology Inc. ASM1042 SuperSpeed USB Host Controller

追記

USBホストコントローラーによっては正しくシリアルナンバーを返さない場合があります。
もっと簡単な方法がある気がしますのでコメントにお願いします。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?