18.5 USB 儲存裝置

Contributed by Marc Fonvieille.

在現在,有許多外部儲存裝置採用 USB(Universal Serial Bus) 介面, 例如硬碟、USB 拇指碟、CD-R 燒錄機等。 FreeBSD 提供對這些裝置的支援。

18.5.1 設定

USB mass 儲存裝置驅動程式(umass(4))提供 USB 儲存裝置的支援。 但如果是用 GENERIC kernel,就不需要做任何設定變動 。 若是自訂 kernel,請確認 kernel 設定檔含有下面這幾行:

device scbus
device da
device pass
device uhci
device ohci
device usb
device umass

umass(4) 驅動程式透過 SCSI 子系統存取 USB 儲存裝置, 您的 USB 裝置會被系統辨識成 SCSI 裝置。 依照您主機板上 USB 晶片型號, 您只需要 device uhcidevice ohci 其中一個。 然而,將兩者都編進 kernel 也無妨。 只要別忘了在修改 kernel 設定後重新編譯及安裝新的 kernel 就行了。

Note: 如果您的 USB 裝置是 CD-R 或 DVD 燒錄機,則 SCSI 光碟機驅動程式 cd(4) 必須寫入 kernel 設定檔,像這樣:

device cd

因為燒錄機會被當成 SCSI 裝置,所以 atapicam(4) 驅動程式不需要編入 kernel。

USB 2.0 控制器的支援由 FreeBSD; 提供,然而必須在 kernel 設定檔增加下面這行以提供 USB 2.0 支援:

device ehci

注意,如果您需要 USB 1.x 支援,您仍然需要將 uhci(4)ohci(4) 驅動程式編入 kernel。

18.5.2 測試設定

The configuration is ready to be tested: plug in your USB device, and in the system message buffer (dmesg(8)), the drive should appear as something like:

umass0: USB Solid state disk, rev 1.10/1.00, addr 2
GEOM: create disk da0 dp=0xc2d74850
da0 at umass-sim0 bus 0 target 0 lun 0
da0: <Generic Traveling Disk 1.11> Removable Direct Access SCSI-2 device
da0: 1.000MB/s transfers
da0: 126MB (258048 512 byte sectors: 64H 32S/T 126C)

Of course, the brand, the device node (da0) and other details can differ according to your configuration.

Since the USB device is seen as a SCSI one, the camcontrol command can be used to list the USB storage devices attached to the system:

# camcontrol devlist
<Generic Traveling Disk 1.11>      at scbus0 target 0 lun 0 (da0,pass0)

If the drive comes with a file system, you should be able to mount it. The Section 18.3 will help you to format and create partitions on the USB drive if needed.

If you unplug the device (the disk must be unmounted before), you should see, in the system message buffer, something like the following:

umass0: at uhub0 port 1 (addr 2) disconnected
(da0:umass-sim0:0:0:0): lost device
(da0:umass-sim0:0:0:0): removing device entry
GEOM: destroy disk da0 dp=0xc2d74850
umass0: detached

18.5.3 Further Reading

Beside the Adding Disks and Mounting and Unmounting File Systems sections, reading various manual pages may be also useful: umass(4), camcontrol(8), and usbdevs(8).

本文及其他文件,可由此下載:ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/

若有 FreeBSD 方面疑問,請先閱讀 FreeBSD 相關文件,如不能解決的話,再洽詢 <questions@FreeBSD.org>。
關於本文件的問題,請洽詢 <doc@FreeBSD.org>。