EXT4 is usually pretty good at keeping files fragmentation at minimum, but, sometimes, especially if dealing with really huge files, some fragmentation may actually occur.
Luckily EXT4 supports online defragmentation, command fsck displays, among other things, fragmentation percentage:
[root@fedora ~]$ fsck.ext4 -fvn /dev/sda1 e2fsck 1.42.12 (29-Aug-2014) Warning! /dev/sda1 is mounted. Warning: skipping journal recovery because doing a read-only filesystem check. Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information 429 inodes used (1.31%, out of 32768) 5 non-contiguous files (1.2%) 1 non-contiguous directory (0.2%) # of inodes with ind/dind/tind blocks: 0/0/0 Extent depth histogram: 420 45161 blocks used (34.46%, out of 131072) 0 bad blocks 1 large file 402 regular files 17 directories 0 character device files 0 block device files 0 fifos 0 links 1 symbolic link (1 fast symbolic link) 0 sockets ------------ 420 files
The command e4defrag, which is contained in e2fsprogs, can be used to perform online defragmentation of EXT4 volumes.
[root@fedora ~]$ yum install e2fsprogs
Then sit tight, prepare to wait some time and run what follows to defrag the volume:
[root@fedora ~]$ e4defrag -c /dev/sda1