0

Hi trying to delete a directory and no mater what I try I get: rm: cannot remove 'wont_delete/delete': Directory not empty

I'm running sudo rm -vr wont_delete/

The directory is on gluster fs.

Edit: Also tried sudo rm -vrf wont_delete/

user432024
  • 273
  • 3
  • 14

1 Answers1

0

Try with this rm with the options r and f

rm -rf wont_delete/

-r, -R, --recursive remove directories and their contents recursively

-f, --force ignore nonexistent files, never prompt

UPDATE

Reference: Unable to remove directory from GlusterFS volume mount point , Why ?, this solution is verified by Red Hat

Issue

  • Unable to remove directory from GlusterFS volume mount point

  • Why some files and directories are missing from GlusterFS volume mountpoint but they are available in bricks?

  • Unable to delete folders in gluster

  • Cannot remove directory (rm -rf)


rmdir: failed to remove `testdir`': Directory not empty"

Logs


W [client-rpc-fops.c:695:client3_3_rmdir_cbk] 0-volname-client-0: remote operation failed: Directory not empty

W [client-rpc-fops.c:695:client3_3_rmdir_cbk] 0-volname-client-1: remote operation failed: Directory not empty

Resolution

Upgrade the cluster to Red Hat Gluster storage 3.2

Root Cause

This can happen due to multiple issues. But the main reason is due to a stale directory or stale link_to_file exists in any of the brick of the volume.

Diagnostic Steps

rmdir: failed to remove `testdir`': Directory not empty"
  • Check all the bricks for this directory , here for example testdir and see if this directory is empty or not in all the bricks.

  • Most probably this directory will be having some files and directories in some of the bricks.

  • Remove gfidlink to this Directory or file from .glusterfs directory.

  • Important Note Perform delete only when data inside this directory is not important .

There is another reference How to remove a directory from a gluster volume when rmdir unexpectedly fails with "directory not empty", verified by Red Hat

Arden Smith
  • 432
  • 2
  • 8