It's not a secret anymore!*
The moose likes I/O and Streams and the fly likes Mounting and Dismounting (USB Drive) Volumes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Mounting and Dismounting (USB Drive) Volumes" Watch "Mounting and Dismounting (USB Drive) Volumes" New topic

Mounting and Dismounting (USB Drive) Volumes

Bill Denniston

Joined: Aug 26, 2008
Posts: 6
I am writing a Java application to perform mass copying of files to many USB drive devices connected to a Windows PC via daisy chained USB hubs. The copy operation will be performed on as many USB drive devices as I can get to work simultaneously. (It looks like 127 ports per root on the PC, so at least this many simultaneous copy operations, performed repetitively over hundreds to thousands of USB drive devices in total.) While testing with a simple thumb drive on a Windows XP PC, inserting and removing the drive does not seem to require a formal "mount" and "dismount" action. However, Windows has a "Safely Remove Hardware" wizard, I presume for a reason (maybe not...) and I suspect performing this operation many times in a session as envisioned will cause problems with the OS. Can anyone comment on the need to formally mount or dismount large numbers of USB drive devices in a scenario like this? If mounting and dismounting is required, can you also please comment on the methods to use in Java, comparing alternatives if any. Many thanks for the help.
Rob Spoor

Joined: Oct 27, 2005
Posts: 19649

Bill Denniston wrote:However, Windows has a "Safely Remove Hardware" wizard, I presume for a reason (maybe not...)

Windows has two speed settings for external drives: optimized for performance and optimized for safe removal.

The latter is default for (most) new devices. It means that data that is written to the device directly. Removing the device without unmounting will cause no problems, but speed is limited. I've never got much more than about 5MB/s.

The former usually needs to be set manually through device manager. Data is written to a buffer inside Windows first; Windows will then gradually flush this buffer to the device. While the performance gain is significant (I got up to 25-30MB/s, a gain of over 400%) it does come at a cost. Removing the device without unmounting will cause any unflushed buffer contents to be discarded. It may even mess up the device's entire file system. Definitely not recommended.

How To Ask Questions How To Answer Questions
jQuery in Action, 2nd edition
subject: Mounting and Dismounting (USB Drive) Volumes
Similar Threads
Eclipse projects on removable media
WinXP On Linux
mount point
Accessing USB devices
How do I read my usb flash drive content