Windows – Long ‘pause’ after copying large files on windows 2008

copypauserobocopywindows

I have a mystery regarding pauses after file copies on windows server 2008 (and other releases)

When copying large files, like vhds, to locally attached USB disks I often see a long pause after the copy has completed 100%.

As an example: robocopying vhd files. The bytes read/written count matches the vhd file size and robocopy shows 100% but it pauses for several minutes. If I do nothing it will continue, but I will have to wait for quite some time – about the same amount of time as it took to get to 100%. The bytes read/bytes written counters for robocopy do not change.

My first thought was that the AV had to scan it, but I'm looking at a machine right now which doesn't have an AV installed and this is occurring, so impossible. No other processes are showing read/write byte counts as going up.

The behavior is the same if I use the copy command or xcopy.

I've seen this on other systems but have never worked out what the cause is.
Anyone got any suggestions as to what might be going on?

Best Answer

You are experiencing the process of emptying a local buffer to the actual drive. When you copy a file to slow media, your operating system can tell you the operation is done before it actually is finished for performance reasons. It actually keeps track of the operation by itself (in memory), unless the program you are using to track progress has some sort of "wait for the file to be actually written down" call at the end of the process. This is what is causing the wait.

For general Windows file copies, you can change this behaviour to trade off performance for safety by changing the USB drive's settings as described here: http://www.pcworld.com/article/254868/safely_remove_usb_drives_just_by_unplugging_them.html

If you do that, then "remove safely" will become absolutely necessary to avoid filesystem corruption on the external drive. This will shift the (unavoidable) wait to the moment you actually remove the drive, with the added benefit that if you later make further changes to the copied files before removing it, you will save a bunch of expensive I/O since the changes will be performed directly on the local buffer.