This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP 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
Author

Mounting and Dismounting (USB Drive) Volumes

Bill Denniston
Greenhorn

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
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mounting and Dismounting (USB Drive) Volumes