Somehow a program created a file with a broken filename which cannot be deleted anymore. Any attempt to delete the file results in "No such file or directory" as if the file isn't there.
The problem seems to be a control character ASCII 2 in the filename.
$ ls
??[????ة?X
$ ls | xxd
00000000: 3f3f 5b3f 3f02 3f3f d8a9 3f58 0a ??[??.??..?X.
# Typing '?' and letting the bash complete the filename
$ rm \?\?\[\?\?^B\?\?ة\?X
rm: das Entfernen von '??[??'$'\002''??ة?X' ist nicht möglich: Datei oder Verzeichnis nicht gefunden
$ rm *
rm: das Entfernen von '??[??'$'\002''??ة?X' ist nicht möglich: Datei oder Verzeichnis nicht gefunden
$ ls -i
2532 ??[?????ة?X
$ find -inum 2532 -delete
find: ‘./??[??\002??ة?X’ kann nicht gelöscht werden.: Datei oder Verzeichnis nicht gefunden
I tried to run fsck
after reboot but the file is still there.
$ zcat /var/log/upstart/mountall.log.1.gz
...
fsck von util-linux 2.25.1
/dev/sdc3: sauber, 544937/6815744 Dateien, 21618552/27242752 Blöcke
...
No indication there was a problem. ("sauber" = clean)
I even tried to wrote my own deletion program which failed as well as the rm
command:
$ cat fix.c
#include <stdio.h>
#include <errno.h>
int main() {
char filename[20];
sprintf(filename, "%c%c%c%c%c%c%c%c%c%c%c%c", 0x3f,0x3f,0x5b,0x3f,0x3f,0x02,0x3f,0x3f,0xd8,0xa9,0x3f,0x58);
printf("filename = %s\n", filename);
int result = remove(filename);
printf("result = %d\n", result);
printf("errno = %d\n", errno);
perror("Error");
return 0;
}
$ gcc -o fix fix.c && ./fix
filename = ??[????ة?X
result = -1
errno = 2
Error: No such file or directory
I found similar questions the answers there don't work for me:
- https://serverfault.com/questions/565914/remove-corrupt-file-with-bad-file-name-linux
- How to delete this undeletable directory?
Other information:
$ mount | grep " / "
/dev/sdc3 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
$ uname -a
Linux hera 4.13.0-16-generic #19-Ubuntu SMP Wed Oct 11 18:35:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/issue
Ubuntu 17.10 \n \l
Is there a way to get rid of this file?
ls -b
to find out what it's really called.rm *
be a good idea? :pfsck.ext4 -f
, and if that does not help, try your luck withdebugfs
rm
to just delete everything. The folder was otherwise empty, because you can move other files out of there.