Tuesday, May 14, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 2119  / 1 Year ago, wed, april 26, 2023, 2:26:11

I have a dir under /home/myuser dir which an application stores and deletes millions of temporary files. When I do ls on this dir (now it only has a hundred files only) it is too slow (actually I do not get any output for many minutes). After some google search and doing:



ls -dl ~/mydir/


I get this



drwxrwxrwx 2 myuser myuser 160108544 Oct 12 11:31 /home/myuser/mydir/


which basically means I have to re-index directory entries for this directory (if I understood correctly). How do I do force such a re-indexing on this dir?


More From » filesystem

 Answers
7

It depends of the underlaying file system type you use, most of the file system do not compact directories after a deletion.


Unmount the filesystem and use e2fsck -D to optimize the directories.


If that problem occurs many time you should consider to use a dedicated file system for that directory. You should use a different file system type, I don't know which one will dynamically compact the directory entries, Btrfs by design is advertised to not suffer of that problem.


Edit:

e2fsck -D can take a very long time, psusi answer is a good alternative to avoid reindexing the whole filesystem.


[#28145] Friday, April 28, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ditery

Total Points: 9
Total Questions: 116
Total Answers: 119

Location: Grenada
Member since Sun, Dec 20, 2020
3 Years ago
;