Linux Optimize Directories ( File Access Time ) in ext3 Filesystem

September 8, 2019

Q. I’m using CentOS Linux 5 server with ext3 on /disk2 (/dev/sdb1). How do I improve my file server performance. I’ve many large files in directories and how do I speed up access time?

A. Use e2fsck command. The -D option causes e2fsck to try to optimize all directories, either by reindexing them if the filesystem supports directory indexing, or by sorting and compressing directories for smaller directories, or for filesystems using traditional linear directories. It improves performance by using hashed binary trees.

ext3 File Tuning / Directory Optimization

Login as the root user

Take down system to single user mode and unmount file system:
# umount /dev/sdb1

Type the following command:

WARNING! Running e2fsck on a mounted filesystem may cause SEVERE filesystem damage. Always unmount file system.

Now run e2fsck on unmounted file system:
# e2fsck -D -f /dev/sdb1

e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 3A: Optimizing directories
Pass 4: Checking reference counts
Pass 5: Checking group summary information

/disk2: ***** FILE SYSTEM WAS MODIFIED *****
/disk2: 39/26104 files (17.9% non-contiguous), 20045/104388 blocks

Mount file system:
# mount /dev/sdb1

Now your should see improvements while accessing files. For more information please read e2fsck man page:
man e2fsck

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Article Tags:
Article Categories:
How To

Comments are closed.