Gaming industry under DDoS attack. Get DDoS protection now. Start onboarding
  1. Home
  2. Developers
  3. How to Monitor Disk Activity in Linux Using the iotop Command

How to Monitor Disk Activity in Linux Using the iotop Command

  • By Gcore
  • October 30, 2023
  • 3 min read
How to Monitor Disk Activity in Linux Using the iotop Command

In the vast realm of Linux system administration, monitoring disk activity is crucial to diagnose performance bottlenecks, manage resources, and ensure optimal system operations. The iotop command emerges as a powerful tool in this endeavor, offering real-time insights into I/O utilization by processes. This guide will help you learn how to effectively harness the capabilities of iotop, and keep a vigilant eye on your Linux system’s disk activity.

Importance of Monitoring Disk Activity in Linux

Observing disk activity in Linux is crucial for a variety of reasons:

  1. Performance Optimization. By observing disk activity, administrators can identify and rectify performance bottlenecks. For instance, spotting processes or applications that are making excessive I/O operations can help in making necessary adjustments or optimizations.
  2. Resource Management. Efficient disk usage ensures that resources are not wasted. By monitoring, one can ensure that disk space is allocated effectively, and unnecessary files or logs aren’t consuming precious space.
  3. Predictive Analysis. Regular monitoring can help in predicting and preventing potential disk failures or performance issues. Patterns in disk activity, such as consistent high I/O operations, can be a precursor to larger issues, allowing for proactive measures.
  4. Security and Compliance. Unusual disk activity can sometimes be a sign of security breaches, like data exfiltration attempts or malware operations. Regularly monitoring can help in detecting such anomalies early, ensuring data protection and meeting compliance requirements.

By maintaining regular oversight of disk activity, Linux administrators can guarantee stable, safe, and optimized operations, enhancing the system’s lifespan. In the following section, we’ll explore how to track disk activity with the iotop command.

Process to Monitor Disk Activity Using iotop Command

Here’s a guide on how to monitor disk activity in Linux using the iotop command, complete with descriptions and potential outputs:

1. Installation. Before you can use iotop, it needs to be installed on your system.

sudo apt install iotop    # For Debian/Ubuntu systemssudo yum install iotop    # For RedHat/CentOS systems

Sample Output:

2. Basic Monitoring. To get a basic overview of disk I/O usage by each running process.

sudo iotop

Output will be a real-time interface will show a list of processes, their respective I/O usage, and other related statistics. This list updates every few seconds.

3. Monitor Only Processes Doing I/O. If you’re only interested in processes that are currently doing I/O operations, you can use the -o flag.

sudo iotop -o

The interface will now filter and display only those processes which are actively performing I/O operations.

4. Display I/O Data in Batch Mode. If you’d like to get I/O stats without the real-time UI, useful for scripts or logging, you can use the -b flag.

sudo iotop -b

A one-shot list of processes and their I/O stats will be displayed, suitable for piping to other commands or redirecting to a file.

5. Monitoring Specific Processes. To monitor specific processes, use the -p flag followed by the process ID (PID).

sudo iotop -p [PID]

The interface will focus on the I/O stats of the specified process.

Tips

  • iotop requires root privileges for most of its functionalities. Hence, the use of sudo is often necessary.
  • Regularly monitoring disk activity can provide insights into system performance and potential bottlenecks.
  • The iotop command comes with other flags and functionalities; refer to its man page (man iotop) for more details.

Congratulations, now you’re able to monitor disk activity using the iotop command. By mastering and effectively utilizing iotop, you can obtain an in-depth perspective of disk activities, which aids in optimizing and safeguarding your Linux system.

Conclusion

Looking to deploy Linux in the cloud? With Gcore Cloud, you can choose from Basic VM, Virtual Instances, or VPS/VDS suitable for Linux:

Choose an instance

Related articles

What's the difference between multi-cloud and hybrid cloud?

Multi-cloud and hybrid cloud represent two distinct approaches to distributed computing architecture that build upon the foundation of cloud computing to help organizations improve their IT infrastructure.Multi-cloud environments involve us

What is multi-cloud? Strategy, benefits, and best practices

Multi-cloud is a cloud usage model where an organization utilizes public cloud services from two or more cloud service providers, often combining public, private, and hybrid clouds, as well as different service models, such as Infrastructur

What is cloud migration? Benefits, strategy, and best practices

Cloud migration is the process of transferring digital assets, such as data, applications, and IT resources, from on-premises data centers to cloud platforms, including public, private, hybrid, or multi-cloud environments. Organizations can

What is a private cloud? Benefits, use cases, and implementation

A private cloud is a cloud computing environment dedicated exclusively to a single organization, providing a single-tenant infrastructure that improves security, control, and customization compared to public clouds.Private cloud environment

What is a cloud GPU? Definition, types, and benefits

A cloud GPU is a remotely rented graphics processing unit hosted in a cloud provider's data center, accessible over the internet via APIs or virtual machines. These virtualized resources allow users to access powerful computing capabilities

What is cloud networking: benefits, components, and implementation strategies

Cloud networking is the use and management of network resources, including hardware and software, hosted on public or private cloud infrastructures rather than on-premises equipment. Over 90% of enterprises are expected to adopt cloud netwo

Subscribe to our newsletter

Get the latest industry trends, exclusive insights, and Gcore updates delivered straight to your inbox.