Problem deleting files

Polytropon freebsd at
Sun Jul 1 20:31:54 UTC 2018

On Sun, 01 Jul 2018 14:13:30 -0500, Paul Schmehl wrote:
> I have a problem with a directory full of files that I can't seem to delete.
> [...]
> If I try to delete that specific filename, it seems to work. (Running rm 
> twice returns no such file the second time.) Yet the file count remains the 
> same.

Is this on UFS or ZFS?

If UFS, unmount the partition and perform a "fsck -f" for
that partition. In worst case, do it twice.

What you're observing looks a bit like filesystem inconsistency
problems. Putting the filesystem back into a consistent
state should solve the problem.

> Nothing I've tried to delete these files seems to work. What can I do to 
> get rid of these files?

There is a way to do it with "lower level tools", but I would
not suggest this for now. But let me mention it anyway:

You can unmount the partition, and then use "fsdb" to examine
the file system to check for the inodes that point to the files,
or the one pointing to the directory that contains the files.
Then remove them interactively from within the "fsdb" program,
or use "clri" to do it. Afterwards, run "fsck -f" at least
once (check for error messages!) to return the file system
into a consistent state - the formerly occupied space will
then be contributed to the free blocks list, and the space
is then available again.

See "man fsdb" and "man clri" for details.

And be very careful if you decide to do it this way.

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

More information about the freebsd-questions mailing list