Podręcznik FreeBSD
Poprzedni | Rozdział 17. Storage | Następny

# 17.5. USB Storage Devices

Contributed by Marc Fonvieille.

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 these devices.

## 17.5.1. Configuration

The USB mass storage devices driver, umass(4), provides the support for USB storage devices. If you use the `GENERIC` kernel, you do not have to change anything in your configuration. If you use a custom kernel, be sure that the following lines are present in your kernel configuration file:

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

The umass(4) driver uses the SCSI subsystem to access to the USB storage devices, your USB device will be seen as a SCSI device by the system. Depending on the USB chipset on your motherboard, you only need either `device uhci` or `device ohci`, however having both in the kernel configuration file is harmless. Do not forget to compile and install the new kernel if you added any lines.

> Notatka: If your USB device is a CD-R or DVD burner, the SCSI CD-ROM driver, cd(4), must be added to the kernel via the line:

>     device cd

> Since the burner is seen as a SCSI drive, the driver atapicam(4) should not be used in the kernel configuration.

Support for USB 2.0 controllers is provided on FreeBSD; however, you must add:

    device ehci

to your configuration file for USB 2.0 support. Note uhci(4) and ohci(4) drivers are still needed if you want USB 1.X support.

## 17.5.2. Testing the Configuration

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 Sekcja 17.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

## 17.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).

Poprzedni | Spis treści | Następny
RAID | Początek rozdziału | Creating and Using Optical Media (CDs)

Ten i inne dokumenty można pobrać z ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/.

W przypadku pytań o FreeBSD prosimy przeczytać dostępną dokumentację przed kontaktem z <questions@FreeBSD.org>.
W sprawie zapytań o tę dokumentację prosimy o kontakt z <doc@FreeBSD.org>.