Unable To Lock Device. Make Sure You Do Not Have Open Files On This Device And Try Again Guide
lsof /dev/sdb reveals a stale NFS lock or a process like gvfsd-trash holding the device.
lsblk | grep sdX mount | grep sdX lsof | grep '/dev/sdX' fuser -v /dev/sdX For a specific partition: lsof /dev/sdb reveals a stale NFS lock or
1. Overview | Attribute | Details | |-----------|---------| | Error Message | Unable to lock device. Make sure you do not have open files on this device and try again. | | Commonly Occurs In | Disk utilities (e.g., fdisk , parted ), filesystem operations (e.g., mkfs , mount ), partition managers (GParted, Disk Utility), and virtualization tools (when accessing raw disks). | | Type | Resource busy / locking failure | | Typical OS | Linux, macOS, BSD, some Unix-like environments | 2. Root Cause The error indicates that the operating system’s device lock mechanism is active. A process or kernel subsystem has an open handle to the device (or a partition on it), preventing exclusive access. Make sure you do not have open files