Bienvenido! - Willkommen! - Welcome!

Bitácora Técnica de Tux&Cía., Santa Cruz de la Sierra, BO
Bitácora Central: Tux&Cía.
Bitácora de Información Avanzada: Tux&Cía.-Información
May the source be with you!

Thursday, August 26, 2010

Safe removal

Source
An USB drive should never be removed without logging it off, especially when the drive has a write cache. The official way is thru a symbol in the systray and some mouse clicks.
For 'removable' drives as internal card readers the media should be 'ejected': Right click the drive in the Windows Explorer, select 'Eject' here. Under XP this is not allowed for restricted users but this can be enabled by a policy. There are some useful commandline tools for this purpose but they all have some disadvantages. So I wrote my own:
Reactivate a USB drive
When a drive has been prepared for safe removal then it can be reactivated only by replugging it.
Meanwhile I have learned that this is true only for devices which have the problem code 47 after the safe removal. Devices which have "Code 21" can be reactivated, I have made a tool for this: RestartSrDev. This works when RemoveDrive was started with admin previleges.
Other solution: Put a USB hub before the device in question. If the hub is deactivated and reactivated by means of DEVCON then all there attached devices wakes up even if they had been prepared for safe removal. The hub's device ID is shown too by my ListUsbDrives when stared with -A (as all info), it's the 'Ctrl2 DevID'.
Sample:
devcon disable USB\VID_067B*PID_2517*
devcon enable USB\VID_067B*PID_2517*
The & (Ampersand character) has a special meaning on the Windows command line, so replacing it by * (placeholder for any characters) is an easy way to prevent problems.
My Tools for USB drives
Developing USBDLM I've made some other tools. They got their own page:
Drive Tools for Windows
Automatic actions on plug in and out
My USB drive letter manager can execute AutoRun events on arrival of a drive, on removal request and after removal.
Automatic actions on arrival of a USB drive can be easily abused to copy interesting data from it in the background. So, never, never attach a USB drive with sensible data to a foreign computer even if you stand beside all the time! It's very easy to copy all DOC, XLS and PDF files in the background!

No comments: