Skip to content

Instantly share code, notes, and snippets.

@prograhammer
Created May 14, 2015 15:34
Show Gist options
  • Save prograhammer/1a5a17120cbd7e94993b to your computer and use it in GitHub Desktop.
Save prograhammer/1a5a17120cbd7e94993b to your computer and use it in GitHub Desktop.
umount: device is busy. Why?
There are several reasons why a file system cannot be unmounted. Here are a few of the reasons.
Working directory or file open of a running process
# umount /mnt/test
umount: /mnt/test: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
# lsof /mnt/test/
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
bash 15819 tange cwd DIR 8,81 16384 6931 /mnt/test/testdir
cat 24932 root 1w REG 8,81 0 6944 /mnt/test/testdir/a
# kill -9 15819 24932
# lsof /mnt/test/
# umount /mnt/test
nfs-kernel-server is exporting the directory (and the directory is mounted by a client)
# umount /mnt/test
umount: /mnt/test: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
# showmount -e
Export list for alpha:
/mnt/test 192.168.1.203
# /etc/init.d/nfs-kernel-server stop
# umount /mnt/test
A loopback device backing file exists in the dir
# umount /mnt/test
umount: /mnt/test: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
# losetup -a
/dev/loop0: [0851]:6983 (/mnt/test/testdir/disk.img)
/dev/loop1: [0851]:6986 (/mnt/test/testdir/disk2.img)
# umount /mnt/test/testdir/disk.img
# umount /mnt/test/testdir/disk2.img
umount: /mnt/test/testdir/disk2.img: not mounted
# losetup -d /dev/loop1
# umount /mnt/test
A swapfile exists in the dir
# umount /mnt/test
umount: /mnt/test: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
# cat /proc/swaps
Filename Type Size Used Priority
/mnt/test/testdir/swapfile file 95480 0 -2
# swapoff /mnt/test/testdir/swapfile
# umount /mnt/test
The device failed
# umount /mnt/test
umount: /mnt/test: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
# dmesg
:
[75620.618404] lost page write due to I/O error on md0
[75620.618408] Buffer I/O error on device md0, logical block 16804
:
[75890.015507] INFO: task cp:27736 blocked for more than 120 seconds.
[75890.015513] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[75890.015516] cp D ffff88053fdd39c0 0 27736 27734 0x00000004
## Here I have not found a solution, so:
# umount -l /mnt/test
The dir contains an umounted encfs
normaluser$ encfs /mnt/test/dir.enc /mnt/test/dir
EncFS Password:
# umount /mnt/test/dir
# umount /mnt/test
umount: /mnt/test: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
## Here I have not found a solution, so:
# umount -l /mnt/test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment