语境

语境

USB 大容量存储的块设备未显示在 中Ubuntu 16.04,而我却可以在 中看到它Ubuntu 14.04。问题:我怎样才能让它显示在 中Ubuntu 16.04

笔记:

  1. 两台机器都是在同一硬件上虚拟的,因此不存在布线、接线、电源、连接等等问题......虚拟化是USB相同的,我已经三次检查过这不是问题。
  2. 事实上...USB 层正确检测到两个都Ubuntu 14.04Ubuntu 16.04(见下面的日志)。
  3. 块设备/dev/sdb出现在Ubuntu 14.04(如预期),但未出现在Ubuntu 16.04(该问题的主题)。
  4. 问题似乎位于名为的某个东西中usb-storage,其中Ubuntu 14.04正在将连接USBSCSI但似乎在我的安装中丢失了Ubuntu 16.04

语境

我有两台 Vagrant/VirtualBox 机器。一台带有 ,Ubuntu 14.04另一台带有Ubuntu 16.04。在主机中,我有一个JMicron基于 的底座,其中插入了 1T HD(芯片产品JMS56x)。

该驱动器未格式化且没有分区,我计划在池中使用原始块设备ZFS

ZFS我想从内部使用它Ubuntu 16.04

在 Ubuntu 14.04 中

我使用 vagrant 镜像config.vm.box = "ubuntu/trusty64"并且已经usbutils安装:

root@vagrant-ubuntu-trusty-64:/home/vagrant# apt list --installed | grep usb

WARNING: apt does not have a stable CLI interface yet. Use with caution in scripts.

libusb-0.1-4/trusty,now 2:0.1.12-23.3ubuntu1 amd64 [installed]
libusb-1.0-0/trusty,now 2:1.0.17-1ubuntu2 amd64 [installed]
usbutils/trusty,now 1:007-2ubuntu1 amd64 [installed]

我告诉 VirtualBox 连接JMicron并且我成功地将块设备作为SCSI磁盘获取。

连接前

在连接磁盘之前,我可以看到sda它的唯一分区sda1

root@vagrant-ubuntu-trusty-64:/home/vagrant# ls -l /dev/sd*
brw-rw---- 1 root disk 8, 0 Nov 26 13:06 /dev/sda
brw-rw---- 1 root disk 8, 1 Nov 26 13:06 /dev/sda1

连接后

连接后,我可以看到sdasdb(在这种情况下,sdb没有分区,正如预期的那样):

root@vagrant-ubuntu-trusty-64:/home/vagrant# ls -l /dev/sd*
brw-rw---- 1 root disk 8,  0 Nov 26 13:06 /dev/sda
brw-rw---- 1 root disk 8,  1 Nov 26 13:06 /dev/sda1
brw-rw---- 1 root disk 8, 16 Nov 26 16:56 /dev/sdb

fdisk给出与列表一致的结果/dev/sd*

因此,Ubuntu 14.04其行为完全符合预期,就像块设备/dev/sdb出现的那样。

在 Ubuntu 16.04 中

我使用 vagrant 镜像config.vm.box = "gbarbieru/xenial",但尚未安装usbutils。我通过以下方式安装它们apt install usbutils,然后得到:

root@vagrant:/home/vagrant# apt list --installed | grep usb

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libusb-0.1-4/xenial,now 2:0.1.12-28 amd64 [installed]
libusb-1.0-0/xenial,now 2:1.0.20-1 amd64 [installed,automatic]
usbutils/xenial,now 1:007-4 amd64 [installed]

JMicron我告诉VirtualBox 连接没有获得任何额外的块设备这就是主要的问题。

连接前

在连接磁盘之前,我可以看到sda它的几个分区sda1sda2以及sda5

root@vagrant:/home/vagrant# ls -l /dev/sd*
brw-rw---- 1 root disk 8, 0 Nov 26 10:55 /dev/sda
brw-rw---- 1 root disk 8, 1 Nov 26 10:55 /dev/sda1
brw-rw---- 1 root disk 8, 2 Nov 26 10:55 /dev/sda2
brw-rw---- 1 root disk 8, 5 Nov 26 10:55 /dev/sda5

连接后

连接后,我看不到Ubuntu 16.04任何sdb我可以看到与Ubuntu 14.04

root@vagrant:/home/vagrant# ls -l /dev/sd*
brw-rw---- 1 root disk 8, 0 Nov 26 10:55 /dev/sda
brw-rw---- 1 root disk 8, 1 Nov 26 10:55 /dev/sda1
brw-rw---- 1 root disk 8, 2 Nov 26 10:55 /dev/sda2
brw-rw---- 1 root disk 8, 5 Nov 26 10:55 /dev/sda5

fdisk给出与列表一致的结果/dev/sd*

因此,Ubuntu 16.04由于块设备未显示,因此其行为不符合预期/dev/sdb。尽管如此,低级 USB 设备事实上被正确检测到了。查看日志:

跟踪和日志

在连接时Ubuntu 14.04我得到以下跟踪:tail -f /var/log/kern.log

Nov 26 16:14:34 vagrant-ubuntu-trusty-64 kernel: [11313.532808] usb 1-1: new high-speed USB device number 3 using xhci_hcd
Nov 26 16:14:34 vagrant-ubuntu-trusty-64 kernel: [11313.553057] usb 1-1: New USB device found, idVendor=152d, idProduct=9561
Nov 26 16:14:34 vagrant-ubuntu-trusty-64 kernel: [11313.553060] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=5
Nov 26 16:14:34 vagrant-ubuntu-trusty-64 kernel: [11313.553062] usb 1-1: Product: JMS56x Series
Nov 26 16:14:34 vagrant-ubuntu-trusty-64 kernel: [11313.553064] usb 1-1: Manufacturer: JMicron
Nov 26 16:14:34 vagrant-ubuntu-trusty-64 kernel: [11313.553065] usb 1-1: SerialNumber: 00000000000000000000
Nov 26 16:14:34 vagrant-ubuntu-trusty-64 kernel: [11313.557954] usb-storage 1-1:1.0: USB Mass Storage device detected
Nov 26 16:14:34 vagrant-ubuntu-trusty-64 kernel: [11313.557991] scsi2 : usb-storage 1-1:1.0
Nov 26 16:14:35 vagrant-ubuntu-trusty-64 kernel: [11314.557915] scsi 2:0:0:0: Direct-Access     WDC WD10 EAVS-00D7B1      0105 PQ: 0 ANSI: 6
Nov 26 16:14:35 vagrant-ubuntu-trusty-64 kernel: [11314.558304] sd 2:0:0:0: Attached scsi generic sg1 type 0
Nov 26 16:14:35 vagrant-ubuntu-trusty-64 kernel: [11314.564883] sd 2:0:0:0: [sdb] 1953525168 512-byte logical blocks: (1.00 TB/931 GiB)
Nov 26 16:14:35 vagrant-ubuntu-trusty-64 kernel: [11314.566221] sd 2:0:0:0: [sdb] Write Protect is off
Nov 26 16:14:35 vagrant-ubuntu-trusty-64 kernel: [11314.566225] sd 2:0:0:0: [sdb] Mode Sense: 47 00 10 08
Nov 26 16:14:35 vagrant-ubuntu-trusty-64 kernel: [11314.571284] sd 2:0:0:0: [sdb] No Caching mode page found
Nov 26 16:14:35 vagrant-ubuntu-trusty-64 kernel: [11314.572366] sd 2:0:0:0: [sdb] Assuming drive cache: write through
Nov 26 16:14:35 vagrant-ubuntu-trusty-64 kernel: [11314.579291] sd 2:0:0:0: [sdb] No Caching mode page found
Nov 26 16:14:35 vagrant-ubuntu-trusty-64 kernel: [11314.579651] sd 2:0:0:0: [sdb] Assuming drive cache: write through
Nov 26 16:14:36 vagrant-ubuntu-trusty-64 kernel: [11315.056332]  sdb: unknown partition table
Nov 26 16:14:36 vagrant-ubuntu-trusty-64 kernel: [11315.066919] sd 2:0:0:0: [sdb] No Caching mode page found
Nov 26 16:14:36 vagrant-ubuntu-trusty-64 kernel: [11315.067273] sd 2:0:0:0: [sdb] Assuming drive cache: write through
Nov 26 16:14:36 vagrant-ubuntu-trusty-64 kernel: [11315.070669] sd 2:0:0:0: [sdb] Attached SCSI disk

相反,我在连接设备时Ubuntu 16.04得到了这些痕迹:tail -f /var/log/kern.log

Nov 26 11:14:59 vagrant kernel: [ 1178.761744] usb 1-1: new high-speed USB device number 4 using xhci_hcd
Nov 26 11:14:59 vagrant kernel: [ 1179.088626] usb 1-1: New USB device found, idVendor=152d, idProduct=9561
Nov 26 11:14:59 vagrant kernel: [ 1179.088632] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=5
Nov 26 11:14:59 vagrant kernel: [ 1179.088636] usb 1-1: Product: JMS56x Series
Nov 26 11:14:59 vagrant kernel: [ 1179.088638] usb 1-1: Manufacturer: JMicron
Nov 26 11:14:59 vagrant kernel: [ 1179.088641] usb 1-1: SerialNumber: 00000000000000000000

第一行缺失的是:

usb-storage 1-1:1.0: USB Mass Storage device detected

因此,比较两个日志,似乎usb-storage没有“名为 的东西”。这个usb-storage东西可能是通往 的桥梁SCSI

问题

  1. usb-storage2016 年还能走这条路吗?还是我应该使用另一座桥梁?
  2. 我如何让其中的usb-storage某物活跃起来,Ubuntu 16.04以便它继续该过程,将存储暴露给,SCSI并且让我得到/dev/sdb列出的块设备?

答案1

在连接 USB 磁盘之前尝试运行modprobe usb-storage或。这会改变什么吗?modprobe usb_storage

答案2

问题是你只使用了通用内核,没有 usb-storage 模块。要使用 usb 存储,只需安装Linux 映像附加包裹

例如在 ubuntu 16.04 上:

apt-get install linux-image-extra-$(uname -r) -y

然后加载 usb 存储模块或断开/连接您的设备

root@ubuntu-xenial:~# modprobe usb-storage
root@ubuntu-xenial:~# dmesg | tail
[  698.649461] scsi host3: usb-storage 1-1:1.0
[  698.650107] usbcore: registered new interface driver usb-storage
[  699.667145] scsi 3:0:0:0: Direct-Access              USB DISK 2.0     PMAP PQ: 0 ANSI: 6
[  699.668667] sd 3:0:0:0: Attached scsi generic sg2 type 0
[  699.679897] sd 3:0:0:0: [sdc] 30289920 512-byte logical blocks: (15.5 GB/14.4 GiB)
[  699.687947] sd 3:0:0:0: [sdc] Write Protect is off
[  699.687951] sd 3:0:0:0: [sdc] Mode Sense: 45 00 00 00
[  699.695974] sd 3:0:0:0: [sdc] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[  699.753448]  sdc: sdc1
[  699.798466] sd 3:0:0:0: [sdc] Attached SCSI removable disk

相关内容