Cannot remove directory on btrfs

1

There is an object on btrfs file system called "????????? ??????" which probably some improperly deleted or copied temporary file or directory. And which can't be removed with common commands: rm, rm -d:

[root@localhost sessions]# rm -d \?\?\?\?\?\?\?\?\?\ \?\?\?\?\?\?/
rm: cannot remove ‘????????? ??????/’: Directory not empty
[root@localhost sessions]# rm -dr \?\?\?\?\?\?\?\?\?\ \?\?\?\?\?\?/
rm: descend into directory ‘????????? ??????/’? y
rm: remove directory ‘????????? ??????/’? y
rm: cannot remove ‘????????? ??????/’: No such file or directory
[root@localhost sessions]# rm \?\?\?\?\?\?\?\?\?\ \?\?\?\?\?\?/
rm: cannot remove ‘????????? ??????/’: Is a directory
[root@localhost sessions]# file \?\?\?\?\?\?\?\?\?\ \?\?\?\?\?\?/
????????? ??????/: directory

How such objects should be deleted?

UPDATE: OS and shell:

Linux 4.0.4-2-ARCH #1 SMP PREEMPT Fri May 22 03:19:32 UTC 2015 i686 GNU/Linux

GNU bash, version 4.3.39(1)-release (i686-pc-linux-gnu)

UPDATE2:

[root@localhost sessions]# rm -fr \?\?\?\?\?\?\?\?\?\ \?\?\?\?\?\?/
[root@localhost sessions]# ls
????????? ??????   backup-9.session
[root@localhost sessions]# lsattr \?\?\?\?\?\?\?\?\?\ \?\?\?\?\?\?/
[root@localhost sessions]# 

UPDATE3:

[root@localhost sessions]# echo $LANG
en_US.UTF-8
[root@localhost sessions]# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

UPDATE4:

[root@localhost sessions]# ls -la
ls: ????????? ??????: No such file or directory
total 23760
drwxr-xr-x 1 al users       0 Aug 13  2014 ????????? ??????
drwxr-xr-x 1 al users       0 Jun  7 05:53 .
drwx------ 1 al users       0 Jun  8 05:06 ..
-rw-r--r-- 1 al users  274557 May 24 18:58 backup-11.session

UPDATE5:

[root@localhost sessions]# find . -exec rm -fr {} \;
rm: refusing to remove ‘.’ or ‘..’ directory: skipping ‘.’
[root@localhost sessions]# ls -la
ls: ????????? ??????: No such file or directory
total 0
drwxr-xr-x 1 al users 0 Aug 13  2014 ????????? ??????
drwxr-xr-x 1 al users 0 Jun  8 17:03 .
drwx------ 1 al users 0 Jun  8 05:06 ..
[root@localhost sessions]# 

Al Berger

Posted 2015-06-08T13:05:43.103

Reputation: 481

The command I usually use is rm -rf. Are you sure that the directory name is correct (ls often shows ? for unprintable characters)? Try ls -b to verify. I often find a GUI file manager is a good way to remove awkward names. A little more about your Linux distribution and shell flavour would be helpful. – AFH – 2015-06-08T13:19:02.427

@AFH: the name was entered with autocompletion by pressing Tab. About OS and shell I updated the post. – Al Berger – 2015-06-08T13:26:04.740

1Looking at the comments against e_z's answer, I am inclined to suspect a file system corruption. If the problem is in the same partition as the root directory, you'll need to boot another system, such as a Live CD, and run fsck from there (or use recovery mode). You should also be able to delete from there, and a Live CD will give you a GUI file manager in case you've not configured one in your system. – AFH – 2015-06-08T14:41:58.993

AFH, I just started another 'btrfs check' and it shows 'checksum verify failed on...'. When it ends I'll run 'btrfs check --fix-crc' and see if the problem persists. – Al Berger – 2015-06-08T14:46:19.660

Answers

2

After rebuilding checksums for the whole partition, running scrub and --repair one more time - the garbage filesystem entries are at last gone.

Al Berger

Posted 2015-06-08T13:05:43.103

Reputation: 481

0

Please try to run as follows:

rm -fr <directory>

also check attributes using lsattr, if need be can use chattr to change attributes, see appropriate man pages.

e_z

Posted 2015-06-08T13:05:43.103

Reputation: 11

Seems that with that object neither rm -fr nor lsattr aren't working (the post is updated) – Al Berger – 2015-06-08T13:38:58.750

what is the value of LANG environment variable ? could you please run locale and post it. May be you have to set your language settings ? – e_z – 2015-06-08T13:42:24.360

Any output in /var/log/messages when trying to delete this folder ? – e_z – 2015-06-08T13:54:05.643

I would also try fsck on the filesystem at a convenient time. I you can move other files somewhere else temporarily, could do something like: cd <parent> ; mv <all needed files/folders elswhere>;find . -exec rm -fr {} \; ;mv <back your backed up files/folders> – e_z – 2015-06-08T13:56:26.000

On that machine systemd is used and /var/log/messages isn't present. 'journalctl -xn20' doesn't show any messages for that time. – Al Berger – 2015-06-08T13:58:01.973

'btrfs check' and 'scrub' and even 'btrfs check --repair' already were done, but that filesystem entry keeps remaining. – Al Berger – 2015-06-08T14:02:11.773

Try to run lsof +D <folder> to see which processes potentially have open files in it ? – e_z – 2015-06-08T14:03:32.087

e_z, lsof doesn't show other processes for that directory. Also for -exec rm please check the UPDATE5 in the post. – Al Berger – 2015-06-08T14:12:05.627

I'm lost, from brtfs FAQ I found same commands as you already mentioned: link .

– e_z – 2015-06-08T14:21:50.800

I was thinking yesterday a bit more and las thing I can suggest is trying to remove file using it's inode.

– e_z – 2015-06-09T08:49:51.867

e_z - thanks, very useful link, bookmarked it. – Al Berger – 2015-06-09T12:57:38.727