Yep - in general, you should start by identifying the process holding the volume open rather than immediately forcing a dismount with /x. This can be caused by Antivirus/EDR software, Windows Search indexing, backup agents, VSS-related components, and applications with open file handles.
You can use both Handle.exe or Process Explorer. Run Handle from an elevated command prompt and inspect references to the affected volume:
handle.exe -a D:
You can also search for the volume's device path if searching by drive letter does not identify the relevant handles:
handle.exe -a | findstr /i "D:"
Keep in mind that some processes reference volumes through device paths rather than drive letters, so a drive-letter search is not always conclusive. Process Explorer's Find Handle or DLL function can also help identify processes holding files open on the affected volume.
Once you identify the process, determine whether it is safe to stop or temporarily disable the associated service. For example, you might investigate the Windows Search service (WSearch), an endpoint protection agent, or a backup application. Avoid terminating security or backup processes without understanding the implications.
Regarding the switches, /f requests filesystem repairs and requires exclusive access to the volume. /x forces the volume to dismount first, invalidating open handles and interrupting access to the volume. It also implies /f. Consequently, /x is not simply another way to acquire a lock. It can disrupt applications, services, and backup operations that depend on the volume.
For machines where this happens repeatedly, I would also check whether the secondary volume is being accessed by scheduled backup jobs, monitoring agents, indexing services, or other background processes. If the volume is used by applications or services that cannot safely be stopped, schedule the repair during a maintenance window.
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin