Disk Usage Monitoring
Introduction to Disk Usage Monitoring
Welcome to this lesson on Disk Usage Monitoring. Keeping track of disk usage is essential for maintaining system health and ensuring that there is adequate storage space for applications and data. Monitoring disk usage helps system administrators detect potential issues early, avoid system crashes, and maintain optimal system performance.
Let's dive in!
Disk Usage of Filesystems with df
Disk Usage of Files and Directories with du
The df command provides statistics about certain filesystems. If you want to estimate the disk usage of files and directories we can use the du command. The -h option is used to provide a human-readable report of the disk usage for all files and directories within the specified directory. It lists each item along with its size in human-readable format.
The -sh option provides a summary of the total disk usage for the specified directory in human-readable format. It does not list individual items. Instead, it gives you the total disk usage of the entire directory at the top level.
Let's take a look at the disk usage of our $FILESYSTEM directory.
The output is:
Let's look at the output of du -h $FILESYSTEM
12K /usercode/FILESYSTEM/.codesignal: This indicates that the.codesignaldirectory inside /usercode/FILESYSTEMis using 12 KB of disk space.20K /usercode/FILESYSTEM: This indicates that the total disk usage of the/usercode/FILESYSTEMdirectory is 20 KB, which includes the space used by its contents (like the.codesignaldirectory).
The output of the du -sh $FILESYSTEM command is: 20K /usercode/FILESYSTEM.
This is a summarized report indicating that the total disk usage of the entire /usercode/FILESYSTEM directory is 20 KB. It does not provide a breakdown of individual files or subdirectories.
