Analyzing disk issues is an important task for Linux admins. Disk I/O bottlenecks can bring down applications. In this tutorial, we will learn how to check disk space usage, disk load usage, disk iops, disk latency.
Hope this post can give you more ideas on how to troubleshoot disk problems.
Check Disk Space Usage with df
With df command in Linux, we can get the disk space usage. The commonly used option is -h. It displays disk usage in a more human-readable format.
The df command only targets a full filesystem. Even if you specify an individual directory, df will read the space of the whole disk.
The following options are commonly used.
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
-i, --inodes list inode information instead of block usage
-t, --type=TYPE limit listing to file systems of type TYPE
-T, --print-type print file system type
Check Disk Utilization In Linux with iostat
From iostat command, we can get the disk utilization. Disk utilization is the disk load usage. From this metric, we can see that the disk is busy or not. It is used to calculate the time percent that a disk was busy actively performing work during an interval. We can get more info about disk utilization from here.
A disk at 0% utilization is “idle,” and a disk at 100% utilization is continually busy performing I/O (and other disk commands). If they remain at 100% for some time, there should be a performance issue.
Note that disk utilization is an interval summary. Disk I/O can occur in bursts, especially due to write flushing, which can be disguised when summarizing over longer intervals.
Check Disk IOPS and Bandwidth In Linux
With the iostat command, we can get IOPS data and disk bandwidth data from r/s w/s rkB/s wkB/s columns. Troubleshoot high iowait issue on Linux
Workload spike could cause IO performance problems. The underlying disk can not support this workload during that time and it leads to a very high disk utilization issue.
Check IO usage by Process
The iotop command is top-like utility for looking at disk I/O. It provides an easy way to monitor Linux Disk I/O usage details and prints a table of existing I/O utilization by process or threads on the systems.
The following are some important iotop usage and keyboard shortcuts.
Move left or right arrow key to change the sorting.
Use –version option to see version number and exit.
Use -h option to see information of usage.
Use -r option to reverse the sorting order.
Use -o option to check processes or thread.
Use -b option to Turn On non-interactive mode to enable logging I/O usage.
Check Disk Latency On Storage Side
High storage latency is another important factor for disk performance issues. In this case, we need to check the LUN response time from the storage dashboard. High response time definitely impacts the disk utilization on the host side. Engaging your storage vendor in a timely manner is a good solution for this.