USB mass storage device class
The USB mass storage device class, otherwise known as USB MSC or UMS, is a protocol that allows a Universal Serial Bus (USB) device to become accessible to a host computing device, enabling file transfers between the host device and the USB device. To the host device, the USB device appears similar to an external hard drive, enabling drag-and-drop file transfers.
The USB mass storage device class comprises a set of computing communications protocols defined by the USB Implementers Forum that run on the Universal Serial Bus. The standard provides an interface to a variety of storage devices.
Some of the devices that are connected to computers via this standard include:
- external magnetic hard drives
- external optical drives, including CD and DVD reader and writer drives
- portable flash memory devices
- solid-state drives
- adapters bridging between standard flash memory cards and USB connections
- digital cameras
- digital audio players and portable media players
- card readers
- mobile phones
Devices which support this standard are referred to as MSC (Mass Storage Class) devices. While MSC is the official abbreviation, UMS (Universal Mass Storage) has become common in online jargon.
Operating system support
Most current mainstream operating systems include support for USB mass storage devices, although support on older systems is usually available through patches.
Microsoft Windows natively supports MSC since Windows 2000 (Windows NT5).
There is no native support for USB supplied by Microsoft in Windows versions prior to Microsoft Windows 95 and Windows NT 4.0. Windows 95 OSR2.1, an update to the operating system, featured very limited support for USB. During that time, no generic USB mass storage driver was produced by Microsoft, even for Windows 98. This meant that a device-specific driver was needed for each type of USB storage device. Today, third-party generic drivers are available as freeware for Windows 98 and Windows 98SE. Third party generic drivers are also available for Windows NT 4.0.
Windows Mobile supports accessing most USB mass storage devices formatted with FAT on devices with USB Host. However, portable devices typically cannot provide enough power for disk enclosures containing hard drives (a 2.5" hard drive typically requires the maximum 2.5 W provided by the USB specification) without a self-powered USB hub. On the other way around, Windows Mobile devices cannot show their file systems as a mass storage device unless the device implementer explicitly decides to add such functionality. However, third party applications exist to add MSC emulation to most WM devices (commercial "Softick CardExport" and free "WM5torage"). Generally only memory cards can be exported, and not internal storage memory, due to the complications with filesystems outlined in the Device access section.
In the past Windows's AutoRun feature worked indiscriminately on any removable media, allowing USB storage devices to become the infection entryway for computer viruses. As the FAT file system, often used on USB storage for its simplicity and wide compatibility, has few access control features, a user has no convenient way to protect USB drives from infection after inserting into an untrusted computer, unless the device has a hardware read-only switch. To address this issue, Microsoft announced it would be limiting the AutoRun functionality to CD/DVD drives only starting in Windows 7 and future updates to previous versions of Windows.
Neither MS-DOS nor most compatible operating systems included support for USB. Third-party generic drivers are available which support USB mass storage devices, such as Duse, USBASPI and DOSUSB. FreeDOS supports USB mass storage as ASPI devices.
The Linux kernel has supported USB mass storage devices since kernel version 2.4 (year 2001), and a backport to kernel 2.2.18 has also been made. In Linux beyond generic driver for all devices conforming to USB mass storage device class, there are quirks, bug-fixes and additional functionalities for various devices, controllers and vendors to enable more functions (like ATA command pass-through for ATA-USB bridges, useful for S.M.A.R.T. or temperature monitoring, controlling spin-up and spin-down of disks in such hard drives and other options). This also includes most Android-based devices, as Android uses a Linux kernel.
Solaris also supports devices since the 2.8 release and up (year 1998), NetBSD since the 1.5 release and up (year 2000), FreeBSD since the 4.0 release and up (year 2000), and OpenBSD since the 2.7 release and up (year 2000). Digital UNIX (later known as Tru64 UNIX), supports USB and USB mass storage devices since version 4.0E (year 1998). AIX supports USB mass storage devices since the 5.3 T9 and 6.1 T3 releases, but it is not well supported and lacks some features (like partitioning and using it as general block device in system).
Game consoles and embedded devices
The Xbox 360 and PlayStation 3 support most mass storage devices for data transfer of media such as pictures and music. The Xbox 360 (as of April 2010) also allows using a mass storage device for saved games, and the PS3 allows transferring saves between devices on a mass storage device.
Independent developers have released drivers for the TI-84 Plus and TI-84 Plus Silver Edition in order to access USB mass storage devices. In these calculators, the usb8x driver supports the msd8x user interface application.
The USB mass storage specification provides an interface to a number of industry standard command sets. The specification allows a device to declare this via its subclass. In practice however, there is little support for specifying the command set directly via its subclass, as most drivers only support the "SCSI transparent command set" and designate their subset of the SCSI command set via their SCSI Peripheral Device Type (PDT). Subclass codes can specify the following command sets:
- Reduced Block Commands (RBC)
- SFF-8020i, MMC-2 (used by ATAPI-style CD and DVD drives)
- QIC-157 (tapes drives)
- Uniform Floppy Interface (UFI)
- SFF-8070i (used by ARMD-style devices)
- SCSI transparent command set (use INQUIRY to get PDT)
The specification does not require any particular file system to be used on conforming devices. Based on the specified command set and any subset of that, it provides a means to read and write sectors of data—much like the low-level interface used to access any hard drive. Operating systems may treat a USB mass storage device like a hard drive, and users may partition it in any format (MBR, GPT, etc.) and format it with any file system.
Because of its ubiquity and relative simplicity, the most common file system on embedded devices such as USB flash drives, cameras, or digital audio players is Microsoft's FAT or FAT32 file system with (optional) support for long filenames. Large USB-based hard disks may come formatted with NTFS, which is much less supported outside Microsoft Windows. However, a keydrive or any other device may be formatted using another filesystem (for example HFS Plus on an Apple Macintosh, or Ext2 under Linux, or Unix File System under Solaris or BSD). This choice may prevent or limit access to the contents of the device by equipment running a different operating system. Other storage options such as LVM, partition tables and software encryption are also possible, depending on operating system.
In cameras, MP3 players, and similar gadgets which must access the file system independently from an external host, the FAT32 filesystem is typically preferred by device manufacturers. All such devices stop using the file system (dismount) before making it available to host operating system, to prevent file system corruption or other damage (it is possible to use it by both device and host, by using read-only mode or by using a cluster-aware file system, however this is not done in existing commodity devices, and has limited usage even in theory, especially on embedded devices). Some devices have a switch or option which allows them to be used in read-only mode (write protection), often used to make files available for shared use without risk of virus infection.
Several partitioning schemes are used by pre-formatted devices. There are two main schemes used by vendors. First puts file system (most commonly FAT32) directly on the device without any partitions, effectively making it start from sector 0, without any additional boot sectors, headers or partitions. Second one, uses DOS partition table (and MBR code), with single (first) partition spanning entire device. This partition is often aligned to some high power of 2 of sectors (like 1 or 2 MB), which is also common and important in solid state drives for best performance and durability. Some devices with embedded storage, acting like USB mass storage device (like MP3 players with USB port), will report that file system is damaged or missing, if formatted using different file system than FAT32 (or any other originally used there). However most devices which uses partition by default can be repartitioned (by shrinking size of first partition and file system) to have more partitions. Such devices will use first partition for its own operations, however after plugging into host system all partitions will be available.
There are also devices which are connected using single USB port, but act as multiple USB devices, one of which is a USB mass storage device. This is often used to simplify distribution and access to drivers and documentation, mostly for Microsoft Windows and Mac OS X operating system. Such drivers are necessary to make full use of the device (usually because the device does not fit any of the standard USB classes, or has additional functionality). An embedded USB mass storage device makes it possible to install additional drivers without the need for any CD-ROM disks, floppies or Internet access to vendor web site. This becomes more important as many modern systems are supplied without any optical or floppy drives. Often Internet access is not available, for example, because the device is used to provide network access - such as Wireless, GSM or Ethernet cards. The embedded USB mass storage is commonly made permanently read-only by the vendor, preventing accidental corruption and the use of it for other purposes (it can be sometimes updated using proprietary protocols when doing device's firmware upgrade). There are multiple other advantages of this way of distribution: decreased costs, simplified installation and fact that user cannot forget the drivers (a problem when using the device or selling the device).
Some advanced disk drive commands, such as Native Command Queuing, which may increase performance, Secure Erase, which allows all the data on the drive to be securely erased, and S.M.A.R.T., which allows a computer to measure various indicators of drive reliability, exist as extensions to the basic low-level command sets used by hard drives, such as SCSI, SATA, or PATA. These features may not work when hard drives are encapsulated in some disk enclosure supporting the USB mass storage interface. Some USB mass storage interfaces provides a generic interface which only provides basic read/write commands, as outlined above. This works perfectly well for basic data transfer using hard drive-based devices; however, it means that there is no simple way to send advanced, device-specific commands to USB mass storage devices (although devices may create their own communication protocols over the USB-standard "control interface").
The newer USB Attached SCSI (UAS) protocol (introduced in USB 3.0) fixes several of these issues, including command queuing, special command pipes for hardware that needs them, and power management.
Specific USB 2.0 chipsets had their own proprietary methods of achieving SCSI pass-through, which could be used for example to read S.M.A.R.T. data from drives using tools like smartctl (using the -d option followed by chipset). More recent USB storage chipsets support the SCSI / ATA Translation (SAT) as generic protocol for interacting with ATA (and SATA) devices. Using more esoteric ATA or SCSI pass-through commands (such as secure erase or setting a security password) when a drive is connected via a USB bridge may result in bricked drives, especially when done with the hdparm utility.
- MSRCTeam (2009-04-28). "Changes in Windows to Meet Changes in Threat Landscape". TechNet Blogs. Retrieved 2012-11-07.
- "Driver for USB Mass Storage compliant devices".
- "eserver: HOWTO: JFS2 on USB device on AIX 188.8.131.52". Eserver.livejournal.com. 2010-01-21. Retrieved 2012-11-07.
- "Xbox Live's Major Nelson » USB Memory Support for the Xbox 360 coming April 6th :". Majornelson.com. 2010-03-26. Retrieved 2012-11-07.
- "83Plus:Software:usb8x/Asm Interface/MSD". WikiTI. 2009-02-18. Retrieved 2012-11-07.
- "#25 (SCSI pass through for SMART via USB on MacOSX smartmontools? 3rd party code available!) – smartmontools". Sourceforge.net. Retrieved 2014-01-21.
- "USB smartmontools". Sourceforge.net. Retrieved 2014-01-21.
- "ATA Secure Erase - ata Wiki". Ata.wiki.kernel.org. 2013-07-22. Retrieved 2014-01-21.
- Mass Storage device class specification — on the site of the USB Implementers Forum.
- Bootability specification Mass Storage bootability specification — describes how bootable USB Mass Storage devices should work.
- "USB Mass Storage Bulk-Only Transfer" is a link that often rots, lately found buried at "USB" -> Developers -> Documents -> Class Specs -> Approved -> Mass Storage -> "Mass Storage Bulk Only 1.0".
- USB Mass Storage Device source code in FreeBSD
- USB Mass Storage source code in Linux