In this blog post, we will discuss three different ways to check disk performance in Linux. This is an important task for any system administrator or developer who is responsible for maintaining a Linux server.
By understanding how to check disk performance, you can ensure that your systems are running smoothly and efficiently!
3 Linux Commands to check disk performance
The following Linux commands can be used to check disk performance:
- iostat – This command provides information about CPU and I/O statistics for devices and partitions.
- df – This command displays information about the amount of free space on each disk and partition.
- sar – This command provides system activity information in a historical way, including disk activity.
check disk performance with iostat command in Linux
The most common way to check disk performance in Linux is using the “iostat” command. This command will show you information about the input/output activity of your hard drive. This information can be useful in understanding how your system is using its resources.
The iostat command can generate the following types of reports:
- cpu utilization report
- device utilization report
- disk utilization report
- system load average report
If you see that the “iostat” command is showing a high rate of activity, it is an indication that your system is under a heavy load.
The “iostat” command can be used to get more information about disk performance. To use this command, you can run the following command: iostat -xk 1 3
For example, if you run the following command: iostat -xk 1 3. You will see output that looks like this:
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util
The “r/s” and “w/s” columns show the number of reads and writes that are being processed per second. This is the disk iops in Linux.
The “rkB/s” and “wkB/s” columns show the number of kilobytes that are being read and written per second.
The “avgrq-sz” column shows the average size of the requests that are being processed.
The “avgqu-sz” column shows the average number of requests that are waiting to be processed.
The “await” column shows the average time that a request spends waiting to be processed. The “svctm” column shows the average time that a request spends being processed.
The “%util” column shows the percentage of time that the disk is being used. This column shows the percentage of time that the disk is being used.
You cannot determine how much I/O load is present from %util. It only represents the percentage of sample time during which at least one io was outstanding within the scheduler/driver/storage.
So with iostat 1 (sample rate of 1 second), a %util of 75% means there was at least 1 io outstanding to storage 750 milliseconds of the total 1 second sample time.
It does not represent anything useful in terms of actual load except in the case where you are dealing with a single physical disk.
In the case of a single physical disk (such as a direct attached SATA disk), %util represents roughly what percentage of the time the disk was working on an io.
With a single physical disk and its single physical disk head, once iostat reaches 100% then no additional io work can be done AT THAT LOAD POINT.
Where the load point is comprised of the size of the io, the ratio of reads versus writes, how random or sequential that load is.
Determining a load alarm limit is highly dependent upon both the storage technology being used AND the application.
Ultimately the application has more control over the load point/mixture — the disk can only process the io, big or small; random or sequential; read or write, as presented
by the application.
For more information, you can read the iostat man page by running the following command:man iostat.
check disk performance with sar command in Linux
Sar command is a useful tool to check disk performance in Linux. we can use this tool to collect, report system activity. This information can be used to help diagnose system problems and improve system performance.
Collect disk performance statistics using the sar command:
sar -dp <interval> <count>
- -d option is used to monitor disk I/O activity.
- -p option is used to Pretty-print device names.
- <interval> is the time interval in seconds between each report.
- <count> is the number of reports to be generated.
For example, to monitor disk performance every 2 seconds for 5 times, use the following command:
sar -dp 2 5
This will generate output that includes statistics such as the number of read and write operations per second, the amount of data read and written per second, the average number of milliseconds spent per read or write operation, etc.
check disk performance with df command in Linux
We can check disk space in Linux by using the df command. This command will show you the amount of free space on your hard drive. It is important to keep an eye on this number, as it can indicate whether or not your system is running out of space.
If the “df” command shows that your system is running low on space, it may be time to consider adding more storage to your system or removing some files.
There are a few different ways that you can use the “df” command. One way is to use the “df -h” flag, which will show you the amount of space in human-readable format. This can be helpful if you want to see how much space is being used on your system.
Another way to use the “df” command is to use the “df -i” flag, which will show you the number of free inodes on your system. Inodes are used to track files on a Linux system. If you are running low on inodes, it may be time to delete some files or add more storage to your system.
how to fix disk performance issues in Linux
If you are seeing poor disk performance on your Linux system, there are a few things that you can do to try to improve it.
- One thing that you can try is to add more memory to your system. If your system is running out of memory, it may start using the disk for storage, which will affect the performance of the system.
- Another thing that you can do is to defragment your hard drive. This will help to improve the performance of your system by making it easier for the system to access the files on the disk.
- You can also try to optimize your file system. This will help to improve the performance of your system by reducing the amount of time that the system has to spend searching for files.