On Mon, Jun 02, 2014 at 02:22:15PM +0300, Martin Papik wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
>
>
> >> How can I detect this situation? I mean I didn't see anything in
> >> /proc/mounts or references to the mount point from /proc/<pid>/*,
> >> so I only managed to correct it (chdir elsewhere) by chance on a
> >> hunch. Would it not be desirable to know that there's a phantom
> >> FS referenced by a number of processes?
> >
> > lsof.
>
> No good.
lsof reports such things as belonging to / because it can't find the
correct path for them. Indeed, you can't find them by filtering on
mount point, file or anything else. But they are there.
e.g:
$ sudo mount /dev/vdc /mnt/scratch
$ cd /mnt/scratch
$ sudo umount -l /mnt/scratch
$ sleep 300
$ cd ~
$ ps -ef |grep [s]leep
dave 16341 7432 0 09:27 pts/1 00:00:00 sleep 300
$ sudo lsof |grep sleep
sleep 16341 dave cwd DIR 253,32 6
96 /
sleep 16341 dave rtd DIR 8,1 4096
2 /
sleep 16341 dave txt REG 8,1 31208
32607 /bin/sleep
sleep 16341 dave mem REG 8,1 1742520
245384 /lib/x86_64-linux-gnu/libc-2.17.so
sleep 16341 dave mem REG 8,1 145160
245381 /lib/x86_64-linux-gnu/ld-2.17.so
sleep 16341 dave mem REG 8,1 1607584
98063 /usr/lib/locale/locale-archive
sleep 16341 dave 0u CHR 136,1 0t0
4 /dev/pts/1
sleep 16341 dave 1u CHR 136,1 0t0
4 /dev/pts/1
sleep 16341 dave 2u CHR 136,1 0t0
4 /dev/pts/1
See the first two DIR lines? They have different devices but the
same path (/). That's what you need to look for - the non-root device
with a root path - in this case 253,32:
$ ls -l /dev/vdc
brw-rw---- 1 root disk 253, 32 Jun 3 09:01 /dev/vdc
$
With this knowledge, the simple way:
$ sudo lsof |grep "253,32"
bash 7432 dave cwd DIR 253,32 6
96 /
sleep 16341 dave cwd DIR 253,32 6
96 /
There's the two processes holding references to the unmounted
filesystem.
Cheers,
Dave.
--
Dave Chinner
david@xxxxxxxxxxxxx
|