How to Dismount a Mounted File System
Novell Cool Solutions: Tip
By Curtis Parker
|
Digg This -
Slashdot This
Posted: 13 Dec 2004 |
Problem:
Unable to dismount a mounted file system while it is in use. Let's say you have mounted a network volume, cdrom, or a flash drive and now you want to dismount it but Linux won't allow it because the device is busy.
Solution:
-
First you will need to find out what process is using the mounted path. This can be done with the following command:
/usr/sbin/lsof +D /mnt/mounted_path
This command searches the mounted path for open files. If this is a mount for a large server volume, it will take some time to complete. It displays the command, PID, user, file name, etc for each open file.
Example:
-
You have mounted a usb flash drive at /mnt/usb using the command:
mount -t vfat /dev/sda1 /mnt/usb
-
You've done some work on the drive and then try to dismount the flash drive using the commmand:
umount /mnt/usb
-
It returns this output:
umount: /mnt/usb: device is busy umount: /mnt/usb: device is busy
-
You must have some process running somewhere that is using that device, run this command:
/usr/sbin/lsof +D /mnt/usb
-
The output might look like this:
COMMAND
PID
USER
FD
TYPE
DEVICE
SIZE
NODE
NAME
bash
5308
root
cwd
DIR
8,1
16384
1
/mnt/usb
vi
5555
root
cwd
DIR
8,1
16384
1
/mnt/usb
vi
5555
root
5u
REG
8,1
12288
26928
/mnt/usb/.testfile.txt.swp
- This shows that you have a terminal window running the bash shell that has changed its working directory to the usb flash drive and you have an instance of vi with testfile.txt open. Exit vi and "cd" out of the usb drive or close the terminal window. After doing so, when you re-run the lsof command, it shows no output. Re-run the umount command and it will return no errors.
Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

