9

I've mounted a block device (internal hard disk) to say ~/HD, and I'm trying,

~# umount ~/HD

It answers,

umount: device is busy.

Now I kill all processes manually by examining

~# fuser -m ~/HD

I also make sure that really no process is accessing the ~/HD path

~# lsof | grep HD

Still umount ~/HD says device is busy even with -f option.

PS: I don't want to use the -l option of umount, since the mounted device is actually an encrypted mapper device, which in turn won't get unmounted unless mapper device is clearly unmounted.

So basically my question is how to really force umount to unmount a device OR How can a device still be marked as busy while no processes are accessing it (or at least fuser and lsof don't report it) and what can I do about it?

I'm on Ubuntu 9.10 x64.

studiohack
  • 13,468
  • 19
  • 88
  • 118
Vikrant Chaudhary
  • 369
  • 2
  • 5
  • 13

9 Answers9

6

Make sure your current working directory (run 'pwd') is not a under ~/hd. If you are currently in that directory, umount will refuse to unmount.

IvanGoneKrazy
  • 261
  • 1
  • 3
3

Command lsof will tell you what process(es) hold a file open.

kmarsh
  • 4,940
  • 1
  • 23
  • 32
3

You will see this behavior if you have mounted something else on a subdirectory of ~/hd. In this case, neither fuser nor lsof will show anything. If you haven't mounted anything under ~/hd ('mount' will answer this question), then I'm not sure what to check.

larsks
  • 4,053
  • 28
  • 36
2

to locate active processes/users execute:

fuser -u /path/to/mount

then execute the following to remove them:

fuser -k /path/to/mount

finally umount the offending device.

Lars Tackmann
  • 245
  • 1
  • 2
  • 8
1

Larsks wrote: "You will see this behavior if you have mounted something else on a subdirectory of ~/hd. In this case, neither fuser nor lsof will show anything."

Using lsof with grep will show subdirectory use - eg "lsof |grep HD".

I had the same problem as the original poster and found the cause using the command above.

Pete
  • 11
  • 1
0

I couldn't unmount because a user had an open SMB session. Worth checking.

FreeSoftwareServers
  • 1,317
  • 5
  • 23
  • 46
  • 1
    This seems more like a comment then an answer to a 5 year old question. – Ramhound Jan 07 '16 at 02:06
  • i didnt have the rep, nor will i with downvotes, but does age matter when a post has ~21k views? This is where google lead me today and lsof | grep /mnt/disk solved my issue – FreeSoftwareServers Jan 07 '16 at 02:28
  • 1
    Yes; it matters because comments are not answers. You could easily edit your answer and make it an answer but currently how it is written seems more like a comment. An answer describes a solution in detail and specifically answers the question that was asked. You not having the reputation to post a comment as an answer isn't how you post a comment. – Ramhound Jan 07 '16 at 02:54
  • Sure I wanted to make it a comment but couldn't but you reference the fact it's 5 years old like it's important. I will update it then... and add the ls grep part – FreeSoftwareServers Jan 07 '16 at 02:57
  • 1
    All content is important. Your answer brought this question to the 1st page. If you want to comment post helpful detailed content to questions you know the answer to or ask detailed specific questions – Ramhound Jan 07 '16 at 03:11
  • Especially the age of a post right? – FreeSoftwareServers Jan 07 '16 at 03:12
0

If all else fails do a

# umount -lf /unmountable_location

l for lazy, f for force

Mureinik
  • 3,974
  • 11
  • 28
  • 32
0

If you really want to just unmount it, you can use umount -f

from man umount :

-f     Force unmount (in case of an unreachable NFS system).  (Requires kernel 2.1.116 or later.)
rags
  • 323
  • 3
  • 6
0

Have you tried to use sync?

The sync command flush the filesystem caches by force the changed blocks to be writed on the disk.

Jr. Hames
  • 54
  • 3