When you dynamically remove a device, the RCM daemon runs the following:
The script's register command to gather the list of resources (device names) that are identified in the script.
The script's queryremove and preremove commands prior to removing the resource if the script's registered resources are affected by the dynamic remove operation.
The script's postremove command if the remove operation succeeds. However, if the remove operation fails, the RCM daemon runs the script's undoremove command.