disappearing files

Robert Bonomi bonomi at mail.r-bonomi.com
Thu Jul 28 16:39:07 UTC 2011


> Date: Thu, 28 Jul 2011 12:30:36 +0200
> From: admin at prnet.org
> Subject: Re: disappearing files
>
> Hi,
>
> Dmesg returns no error. Also smartctl returns no errors. I will wait for
> other suggestion before unmounting the volume in this machine for the case
> someone else has another suggestion what to check for, because it might be
> that by umounting and remounting, it will take again a few month for the
> problem to reappear.
>
> On the other machine that was having the problem, dmesg and smartctl also
> returned no errors. I rebooted the machine and started fsck which also
> returned no error. On remounting, everything was working again.


When the problem shows up again, run the following script, as superuser,
from inside the jail environment. It requires one argument -- the fully
qualified path name of the 'disappeared' file.

    #!/bin/sh 

    if [ $# -lt 1 ] ; then
      echo  "Usage: $0  pathname"
      echo  "   'pathname' MUST be spcified"
      echo
      exit 1
    fi
    if [ $# -gt 1 ] ; then
      echo  "Usage: $0  pathname"
      echo  "   only one 'pathname' allowed (\"$*\" is invalid)"
      echo
      exit 1
    fi

    dir_name=`dirname $1`                             export dir_name
    file_name=`basename $1 | sed -e 's/[.]/\\//'`     export file_name
    file_name=`dirname $file_name`
    fs_name=`echo f* | tr ' ' '\n' | head -1`
    fs_name='df ${fs_name} | tail -1 | cut -d ' ' -f 1'

    sync; sync                       # this just  minimizes fsck 'chatter'
    echo
    echo 'fsck output:'
    yes |fsck -n  ${fs_name}         # don't fix anything, continue if asked
    echo
    echo 'ls output:'
    ls -l ${dir_name}/${file_name}*
    echo
    echo 'stat output:'
    stat  ${dir_name}/${file_name}*
    echo
    echo 'stat -L output:'
    stat  -L ${dir_name}/${file_name}*
    echo
    echo 'lsof output:'
    lsof | grep  ${file_name}

This will show _all_ the relevant info for the file(s) and filesystem.  Run
it when things misbehave, _and_ when things are working properly.  Differences
should prove very informative.

Do -not- be suprised if 'fsck' reports inconsistencies -- such are to be
expected on an 'active' filesystem.  However, the list of "inconsistencies"
_can_ be useful if 'something unexpected' shows up there.



More information about the freebsd-questions mailing list