lsof equivalent in FreeBSD

When I want to umount a filesystem in Linux and the kernel says it can’t umount because the filesystem is busy I usually do something like

# lsof | grep [mount point]

To figure out what files are open in the mount point .

In FreeBSD you may install lsof or you could instead use the builtin fstat command that comes bundled with FreeBSD . For cases like the one mentioned above fstat with the -f switch is really handy:

# zfs destroy tank/data
cannot unmount '/tank/data': Device busy
#
# fstat -f /tank/data
USER     CMD          PID   FD MOUNT      INUM MODE         SZ|DV R/W
www      java        1674    4 -        20595308 -rw-r--r--  19269164  r
www      java        1674    5 -        20595308 -rw-r--r--  19269164  r
# 

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.