Definition I found with Google:
Internal Fragmentation is the term used to describe disk space which is allocated to a file but unused because the file is smaller than the allocated space.
As you again omit to mention what Operating System and version you have, and what Filesystem Type you have (e.g. UFS, VxFS , whatever) all answers can only be general.
Comparing the output from "du -s" with the total of the sizes of the files as reported by "ls -la" demonstrates the discrepancy.
Proprietary software may well provide better tools. Depends what you have.
It's a real problem on Windows systems with large discs and large numbers of small files. A disc upgrade can actually reduce the amount of free space!
#!/bin/bash
DIR=/home/username
# du outputs "blocks folder" so we read both and just ignore the folder.
read USED_K FOLDER <<<$(du -s -B 1024 "$DIR" 2> /dev/null)
# du outputs a header line, then "filesystem blocks used available ..."
# so we ignore the header line with 'tail', then read the first three.
read FILESYSTEM TOTAL_K G <<<$(df -B 1024 "$DIR" | tail -n 1)
echo "$DIR uses $(( (USED_K*100) / TOTAL_K ))% of $FILESYSTEM"
Running this gets me
/home/username uses 51% of /dev/sdc5
---------- Post updated at 01:31 PM ---------- Previous update was at 01:27 PM ----------
Which do you want? The space used, or something nebulous about fragmentation?