umount: /tmp/disk: device is busy
This is a common problem when trying to unmount a filesystem that is currently in use, especially when you have no idea what is using it!
Here’s a test..
ns3:~# cd /tmp/disk
Now we’ll create a test.sh script that will simply loop indefinitely, pausing every second as it goes.
ns3:/tmp/disk# cat test.sh
#!/bin/bash
while(true); do
sleep 1;
done
ns3:/tmp/disk# chmod +x test.sh
ns3:/tmp/disk# ./test.sh &
[1] 31460
Now test.sh is running, I’ll return to my home directory
ns3:/tmp/disk# cd ~/
Attempting to unmount /tmp/disk returns:
ns3:~# umount /tmp/disk
umount: /tmp/disk: device is busy
umount: /tmp/disk: device is busy
Assuming I don’t know that test.sh is currently running:
ns3:~# lsof +D /tmp/disk
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
test.sh 31460 root cwd DIR 7,0 1024 2 /tmp/disk
test.sh 31460 root 255r REG 7,0 44 12 /tmp/disk/test.sh
sleep 31666 root cwd DIR 7,0 1024 2 /tmp/disk
Now I know that test.sh is running, I can issue:
ns3:~# killall test.sh
[1]+ Terminated ./test.sh (wd: /tmp/disk)
(wd now: ~)
Followed by:
ns3:~# umount /tmp/disk
Tags: cd, chmod, device is busy, filesystem, killall, lsof, umount, unmount
You must be logged in to post a comment.