非ブロックUSBデバイスのUUIDを見つける方法は?

非ブロックUSBデバイスのUUIDを見つける方法は?

簡単に言えば、私が持っているデバイスがブロックデバイスではないため、blkidコマンドは機能しません。ただし、少なくともlsusb -vコマンドを使用してデバイスに関するいくつかの情報を取得することはできます。デバイスにUUIDが含まれていなくても。

私は私のデバイスを知っていますするUUIDがあります。問題は、VBoxManage list usbhostコマンドを実行しようとすると、一部のUSBデバイス(非ブロックデバイスを含む)が表示されることです。彼らのUUID。しかし、何らかの理由でコマンドの出力がリストの先頭で突然停止するため(返されたコードがゼロであるにもかかわらず、末尾の改行がなくても)、私のデバイスのUUIDを見る機会はありません。私はなぜそのようなことが起こったのかを調べるのに苦労したくありません。代わりに、私のデバイスのUUIDを見つける他の方法を知りたいです。簡単だと思うからです。

この情報が誰かに興味深い場合に備えて:Gentoo、Linux 3.7.10

/sys/kernel/debug/usb/devices

T:  Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480  MxCh= 2
B:  Alloc=  0/800 us ( 0%), #Int=  1, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev= 3.07
S:  Manufacturer=Linux 3.7.10-gentoo-r1 ehci_hcd
S:  Product=EHCI Host Controller
S:  SerialNumber=0000:00:1d.0
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

T:  Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480  MxCh= 8
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=8087 ProdID=0024 Rev= 0.00
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   2 Ivl=256ms

T:  Bus=02 Lev=02 Prnt=02 Port=02 Cnt=01 Dev#=  3 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=048d ProdID=1336 Rev= 1.00
S:  Manufacturer=Generic   
S:  Product=Mass Storage Device
S:  SerialNumber=00000000000006
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=125us
E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480  MxCh= 2
B:  Alloc=  0/800 us ( 0%), #Int=  4, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev= 3.07
S:  Manufacturer=Linux 3.7.10-gentoo-r1 ehci_hcd
S:  Product=EHCI Host Controller
S:  SerialNumber=0000:00:1a.0
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480  MxCh= 6
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=8087 ProdID=0024 Rev= 0.00
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   1 Ivl=256ms

T:  Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#=  3 Spd=12   MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=1366 ProdID=0101 Rev= 1.00
S:  Manufacturer=SEGGER
S:  Product=J-Link
S:  SerialNumber=000038000375
C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms

T:  Bus=01 Lev=02 Prnt=02 Port=03 Cnt=02 Dev#=  4 Spd=12   MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=0403 ProdID=6001 Rev= 6.00
S:  Manufacturer=FTDI
S:  Product=TTL232R-3V3
S:  SerialNumber=FTF5T2QJ
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr= 90mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=ftdi_sio
E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms

T:  Bus=01 Lev=02 Prnt=02 Port=04 Cnt=03 Dev#=  5 Spd=12   MxCh= 0
D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=046d ProdID=0a01 Rev=10.13
S:  Manufacturer=Logitech
S:  Product=Logitech USB Headset
C:* #Ifs= 3 Cfg#= 1 Atr=80 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 0 Cls=01(audio) Sub=01 Prot=00 Driver=(none)
I:* If#= 1 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=00 Driver=(none)
I:  If#= 1 Alt= 1 #EPs= 1 Cls=01(audio) Sub=02 Prot=00 Driver=(none)
E:  Ad=01(O) Atr=09(Isoc) MxPS= 192 Ivl=1ms
I:  If#= 1 Alt= 2 #EPs= 1 Cls=01(audio) Sub=02 Prot=00 Driver=(none)
E:  Ad=01(O) Atr=09(Isoc) MxPS=  96 Ivl=1ms
I:* If#= 2 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=00 Driver=(none)
I:  If#= 2 Alt= 1 #EPs= 1 Cls=01(audio) Sub=02 Prot=00 Driver=(none)
E:  Ad=84(I) Atr=09(Isoc) MxPS=  96 Ivl=1ms

T:  Bus=01 Lev=02 Prnt=02 Port=05 Cnt=04 Dev#=  6 Spd=480  MxCh= 7
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=2001 ProdID=f103 Rev= 1.00
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   1 Ivl=256ms

T:  Bus=01 Lev=03 Prnt=06 Port=01 Cnt=01 Dev#=  7 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=13fe ProdID=3600 Rev= 1.00
S:  Manufacturer=        
S:  Product=                
S:  SerialNumber=90B217007BC11098
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=200mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

T:  Bus=01 Lev=03 Prnt=06 Port=03 Cnt=02 Dev#= 12 Spd=1.5  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=045e ProdID=071d Rev= 2.50
S:  Manufacturer=Microsoft
S:  Product=Microsoft�� 2.4GHz Transceiver V1.0
C:* #Ifs= 2 Cfg#= 1 Atr=a0 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=01 Driver=usbhid
E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=10ms
I:* If#= 1 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid
E:  Ad=82(I) Atr=03(Int.) MxPS=   8 Ivl=10ms

興味のあるデバイスは次のとおりです。
T: Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 3 Spd=12 MxCh= 0

既存の非ブロックデバイスのUUID:

[krokoziabla@ktulhu]:0:/home/krokoziabla> VBoxManage list usbhost

Host USB Devices:

UUID:               f864c487-2a25-4649-84cd-39dc67be695a
VendorId:           0x0403 (0403)
ProductId:          0x6001 (6001)
Revision:           6.0 (0600)
Port:               3
USB version/speed:  2/1
Manufacturer:       FTDI
Product:            TTL232R-3V3
SerialNumber:       FTF5T2QJ
Address:            sysfs:/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4//device:/dev/vboxusb/001/004
Current State:      Busy

UUID:               b03a6680-ecc5-4f48-8103-3e387cf4cb28
VendorId:           0x045e (045E)
ProductId:          0x071d (071D)
Revision:           2.80 (0280)
Port:               3
USB version/speed:  2/1
Manufacturer:       Microsoft
Product:            Microsoft[krokoziabla@ktulhu]:0:/home/krokoziabla> 

ベストアンサー1

装備UUIDはありません。 分割する。 UUIDは、ファイルシステムがフォーマットされたときに生成されます。これが変更される可能性があり、再フォーマット時に変更される理由です。

つまり、UUIDはハードウェアの特性ではなく、存在しない情報を「見つける」方法はありません。

デバイスにUUIDを持つ1つ以上のパーティションがある可能性があるため、以前に関連したパーティションを見たことがある場合は、これはパーティションのUUIDです。複数のパーティションがある場合、各パーティションにはUUIDがあるかもしれませんが(または必要ではないのでそうでないかもしれません)、それらのどれもハードウェアの特性ではありません(ただし保存された変更可能なデータの一部にすぎません)。 USBフラッシュドライブには、通常、事前フォーマットされた大型FAT32またはNTFSパーティションが付属しています。再フォーマットするとUUIDが変わります。

パーティションのUUIDを見つけるには、そのIDをブロックデバイスとして見つける必要があります。 cat /proc/partitionsインストールの有無にかかわらず、カーネルが知っているすべての内容をリストする必要があります。システムに何十ものドライブが接続されていないと仮定すると、どのドライブがUSBであるかを見つけるのは簡単です。 /proc/partitionsドライブも実際にリストされます。ドライブの末尾に数字がなく(sda対sda1)、出力がfile -s異なるため、パーティションと区別できます。

> file -s /dev/sda
/dev/sda: x86 boot sector; partition 1: ID=0x83, active, starthead 32, startsector 2048, 134217728 sectors; 
partition 2: ID=0x83, starthead 202, startsector 134219776, 58720256 sectors; 
partition 3: ID=0x83, starthead 245, startsector 192940032, 46137344 sectors; 
partition 4: ID=0x82, starthead 223, startsector 239077376, 10992304 sectors, code offset 0x63

> file -s /dev/sda1
/dev/sda1: Linux rev 1.0 ext4 filesystem data, UUID=cd8e11b5-07ac-7741-ae0c-36e63eacf8a1, volume name "_Fedora-17-x86_6/" (needs journal recovery) (extents) (large files) (huge files)

あらかじめフォーマットされたドライブが単に大型デバイスの場合もあります。たとえば、次のようになります。

> file -s /dev/sdb
/dev/sdb: x86 boot sector, Microsoft Windows XP Bootloader NTLDR, code offset 0x3c, 
OEM-ID "MSDOS5.0", sectors/cluster 64, root entries 512, 
Media descriptor 0xf8, sectors/FAT 246, heads 255, sectors 4026368 (volumes > 32 MB) , reserved 0x1, serial number 0xe06de56f, 
unlabeled, FAT (16 bit)

これは実際には「タグが指定されておらず」UUIDがないようです(必須ではありません)。

おすすめ記事