6

I built a debootstrap chroot and bound /proc to it, i.e. sudo mount -o bind /proc <chroot>/proc

When I found I no longer needed it, I quite stupidly rm -r <chroot>'d it. Of course, rm refused to remove /proc.

Now umount says that /proc is in use and cannot be unmounted. How do I unmount it, now?

Thanks.

Brian
  • 303
  • 1
  • 4
  • 8

2 Answers2

4

Linux refuses to remove a directory that is a mount point, so <chroot>/proc should still exist. And Linux refuses to remove a directory that is not empty, so <chroot> should still exist.

Taking what you wrote at face value, you tried to unmount /proc, not <chroot>/proc. So the kernel tried to unmount the none filesystem mounted on /proc. You should unmount the none filesystem mounted at <chroot>/proc with umount <chroot>/proc then rmdir <chroot>/proc <chroot>.

Note that if you moved <chroot>, you must pass the new name to umount. You can check what the kernel thinks is mounted by looking in /proc/mounts.

In case umount complains because your /etc/mtab has somehow gone out of sync, use umount -n.

If even umount -n <chroot>/proc doesn't work, it's probably because some process is still running inside the chroot to access it. Use lsof to locate the process and kill it.

  • Thanks. Yes, `/proc` and, by extension, `` still exist. And actually, I did try to unmount `/proc`. For instance: `_@_:~$ sudo umount -n /proc/ [sudo] password for _: umount: /proc: device is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))` And then, the only process that `lsof` comes up with is `lsof` itself: `_@_:~$ lsof /proc/ COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME lsof 7046 _ 3r DIR 0,3 0 1 /proc/` Thanks again. – Brian Aug 24 '10 at 13:22
  • Sorry for the cruddy formatting; I'm new to markdown and have made too many edits to fix it. – Brian Aug 24 '10 at 13:28
  • @brian4work: `lsof /proc/` only shows processes that are using the `/proc` directory. `lsof +f -- /proc` shows all processes using the `proc` filesystem (i.e. it's equivalent to `lsof +f -- /proc`), whether through the chroot or outside (`mount --bind` is peculiar sometimes). At least `lsof +f -- /proc` would narrow the search. – Gilles 'SO- stop being evil' Aug 24 '10 at 17:52
  • Thanks so much; that did the trick. It turned out to be daemonized `dd` holding on to the chroot's kmsg file. – Brian Sep 01 '10 at 20:46
0

Try recreating the directory then umount it?

vmfarms
  • 3,117
  • 20
  • 17