📄 usb-disks.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>USB Storage Devices</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD Handbook" href="index.html" /><link rel="UP" title="Storage" href="disks.html" /><link rel="PREVIOUS" title="RAID" href="raid.html" /><link rel="NEXT" title="Creating and Using Optical Media (CDs)"href="creating-cds.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /></head><body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"alink="#0000FF"><div class="NAVHEADER"><table summary="Header navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><th colspan="3" align="center">FreeBSD Handbook</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="raid.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 16 Storage</td><td width="10%" align="right" valign="bottom"><a href="creating-cds.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="USB-DISKS" name="USB-DISKS">16.5 USB Storage Devices</a></h1><i class="AUTHORGROUP"><span class="CONTRIB">Contributed by</span> Marc Fonvieille.</i> <p>A lot of external storage solutions, nowadays, use the Universal Serial Bus (USB):hard drives, USB thumbdrives, CD-R burners, etc. FreeBSD provides support for thesedevices.</p><div class="SECT2"><h2 class="SECT2"><a id="AEN23815" name="AEN23815">16.5.1 Configuration</a></h2><p>The USB mass storage devices driver, <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=umass&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">umass</span>(4)</span></a>, provides thesupport for USB storage devices. If you use the <tt class="FILENAME">GENERIC</tt> kernel,you do not have to change anything in your configuration. If you use a custom kernel, besure that the following lines are present in your kernel configuration file:</p><pre class="PROGRAMLISTING">device scbusdevice dadevice passdevice uhcidevice ohcidevice usbdevice umass</pre><p>The <a href="http://www.FreeBSD.org/cgi/man.cgi?query=umass&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">umass</span>(4)</span></a> driver usesthe SCSI subsystem to access to the USB storage devices, your USB device will be seen asa SCSI device by the system. Depending on the USB chipset on your motherboard, you onlyneed either <var class="LITERAL">device uhci</var> or <var class="LITERAL">deviceohci</var>, however having both in the kernel configuration file is harmless. Do notforget to compile and install the new kernel if you added any lines.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> If your USB device is a CD-R or DVD burner, the SCSI CD-ROM driver, <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=cd&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">cd</span>(4)</span></a>, must be addedto the kernel via the line:</p><pre class="PROGRAMLISTING">device cd</pre><p>Since the burner is seen as a SCSI drive, the driver <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=atapicam&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">atapicam</span>(4)</span></a> should notbe used in the kernel configuration.</p></blockquote></div><p>Support for USB 2.0 controllers is provided on FreeBSD 5.X, and on the 4.X branchsince FreeBSD 4.10-RELEASE. You have to add:</p><pre class="PROGRAMLISTING">device ehci</pre><p>to your configuration file for USB 2.0 support. Note <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=uhci&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">uhci</span>(4)</span></a> and <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=ohci&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">ohci</span>(4)</span></a> drivers arestill needed if you want USB 1.X support.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> On FreeBSD 4.X, the USB daemon (<ahref="http://www.FreeBSD.org/cgi/man.cgi?query=usbd&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">usbd</span>(8)</span></a>) must berunning to be able to see some USB devices. To enable it, add <varclass="LITERAL">usbd_enable="YES"</var> to your <tt class="FILENAME">/etc/rc.conf</tt>file and reboot the machine.</p></blockquote></div></div><div class="SECT2"><h2 class="SECT2"><a id="AEN23855" name="AEN23855">16.5.2 Testing theConfiguration</a></h2><p>The configuration is ready to be tested: plug in your USB device, and in the systemmessage buffer (<a href="http://www.FreeBSD.org/cgi/man.cgi?query=dmesg&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">dmesg</span>(8)</span></a>), the driveshould appear as something like:</p><pre class="SCREEN">umass0: USB Solid state disk, rev 1.10/1.00, addr 2GEOM: create disk da0 dp=0xc2d74850da0 at umass-sim0 bus 0 target 0 lun 0da0: <Generic Traveling Disk 1.11> Removable Direct Access SCSI-2 device da0: 1.000MB/s transfersda0: 126MB (258048 512 byte sectors: 64H 32S/T 126C)</pre><p>Of course, the brand, the device node (<tt class="DEVICENAME">da0</tt>) and otherdetails can differ according to your configuration.</p><p>Since the USB device is seen as a SCSI one, the <tt class="COMMAND">camcontrol</tt>command can be used to list the USB storage devices attached to the system:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">camcontrol devlist</kbd><Generic Traveling Disk 1.11> at scbus0 target 0 lun 0 (da0,pass0)</pre><p>If the drive comes with a file system, you should be able to mount it. The <ahref="disks-adding.html">Section 16.3</a> will help you to format and create partitionson the USB drive if needed.</p><p>If you unplug the device (the disk must be unmounted before), you should see, in thesystem message buffer, something like the following:</p><pre class="SCREEN">umass0: at uhub0 port 1 (addr 2) disconnected(da0:umass-sim0:0:0:0): lost device(da0:umass-sim0:0:0:0): removing device entryGEOM: destroy disk da0 dp=0xc2d74850umass0: detached</pre></div><div class="SECT2"><h2 class="SECT2"><a id="AEN23873" name="AEN23873">16.5.3 Further Reading</a></h2><p>Beside the <a href="disks-adding.html">Adding Disks</a> and <ahref="mount-unmount.html">Mounting and Unmounting File Systems</a> sections, readingvarious manual pages may be also useful: <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=umass&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">umass</span>(4)</span></a>, <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=camcontrol&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">camcontrol</span>(8)</span></a>, and <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=usbdevs&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">usbdevs</span>(8)</span></a>.</p></div></div><div class="NAVFOOTER"><hr align="LEFT" width="100%" /><table summary="Footer navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="raid.html" accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html"accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="creating-cds.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">RAID</td><td width="34%" align="center" valign="top"><a href="disks.html"accesskey="U">Up</a></td><td width="33%" align="right" valign="top">Creating and Using Optical Media (CDs)</td></tr></table></div><p align="center"><small>This, and other documents, can be downloaded from <ahref="ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/">ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/</a>.</small></p><p align="center"><small>For questions about FreeBSD, read the <ahref="http://www.FreeBSD.org/docs.html">documentation</a> before contacting <<ahref="mailto:questions@FreeBSD.org">questions@FreeBSD.org</a>>.<br />For questions about this documentation, e-mail <<ahref="mailto:doc@FreeBSD.org">doc@FreeBSD.org</a>>.</small></p></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -