On some dialects, when lsof has to break a block because it can't
get information about a mounted file system via the lstat(2) and
stat(2) kernel functions, or because you specified the -b
option,
lsof can obtain some of the information it needs - the device
number and possibly the file system type - from the system mount
table. When that is possible, lsof will report the device number
it obtained. (You can suppress the report by specifying the -w
option.)
You can assist this process if your mount table is supported with
an /etc/mtab or /etc/mnttab file that contains an options field
by adding a ``dev=xxxx'' field for mount points that do not have
one in their options strings. Note: you must be able to edit the
file - i.e., some mount tables like recent Solaris /etc/mnttab or
Linux /proc/mounts are read-only and can't be modified.
You may also be able to supply device numbers using the +m
and +m
m options, provided they are supported by your dialect. Check
the output of lsof's -h
or -?
options to see if the +m
and +m
m
options are available.
The ``xxxx'' portion of the field is the hexadecimal value of the
file system's device number. (Consult the st_dev field of the
output of the lstat(2) and stat(2) functions for the appropriate
values for your file systems.) Here's an example from a Sun
Solaris 2.6 /etc/mnttab for a file system remotely mounted via
NFS:
nfs ignore,noquota,dev=2a40001
There's an advantage to having ``dev=xxxx'' entries in your mount
table file, especially for file systems that are mounted from
remote NFS servers. When a remote server crashes and you want to
identify its users by running lsof on one of its clients, lsof
probably won't be able to get output from the lstat(2) and
stat(2) functions for the file system. If it can obtain the file
system's device number from the mount table, it will be able to
display the files open on the crashed NFS server.
Some dialects that do not use an ASCII /etc/mtab or /etc/mnttab
file for the mount table may still provide an alternative device
number in their internal mount tables. This includes AIX, Apple
Darwin, FreeBSD, NetBSD, OpenBSD, and Tru64 UNIX. Lsof knows how
to obtain the alternative device number for these dialects and
uses it when its attempt to lstat(2) or stat(2) the file system
is blocked.
If you're not sure your dialect supplies alternate device numbers
for file systems from its mount table, use this lsof incantation
to see if it reports any alternate device numbers:
lsof -b
Look for standard error file warning messages that begin
``assuming "dev=xxxx" from ...''.