I've got some samba drives that are being accessed by multiple users daily. I already have code to recognize shared drives (from a SQL table) and mount them in a special directory where all users can access them.
I want to know, if I remove a drive from my SQL table (effectively taking it offline) how, or even is, there a way to unmount a busy device? So far I've found that any form of umount
does not work.
Ignoring the possibility of destroying data - is it possible to unmount a device that is currently being read?
Press the Windows / Super key and search for “disk.” Select the Disks utility. 3. Selecting the USB Flash drive correctly. Click the square stop button icon to unmount the disk.
Answer. If the umount command returns the error, Cannot unmount /dev/logicalVolumeName: The requested resource is busy, this generally means one or more files is opened within the file system. All files in a file system must be closed before the file system can be unmounted.
YES!! There is a way to detach a busy device immediately - even if it is busy and cannot be unmounted forcefully. You may cleanup all later:
umount -l /PATH/OF/BUSY-DEVICE umount -f /PATH/OF/BUSY-NFS (NETWORK-FILE-SYSTEM)
NOTE/CAUTION
umount
commands when inside mounted path (Folder/Drive/Device) itself. First, you may use pwd
command to validate your current directory path (which should not be the mounted path), then use cd
command to get out of the mounted path - to unmount it later using above commands.If possible, let us locate/identify the busy process, kill that process and then unmount
the samba share/ drive to minimize damage:
lsof | grep '<mountpoint of /dev/sda1>'
(or whatever the mounted device is)
pkill target_process
(kills busy proc. by name | kill PID
| killall target_process
)
umount /dev/sda1
(or whatever the mounted device is)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With