Back to Blog
How to Monitor Disk Usage in Linux (Step-by-Step Guide)

How to Monitor Disk Usage in Linux (Step-by-Step Guide)

   Mariusz Antonik    Server Health    3 min read    116 views

How to Monitor Disk Usage in Linux (Step-by-Step Guide)

Disk space issues are one of the most common causes of outages in Linux environments. The problem is not usually a sudden spike—it’s slow, unnoticed growth over time.

If you don’t actively monitor disk usage, logs, databases, and backups can quietly consume storage until systems reach critical levels. This guide shows you how to monitor disk usage in Linux using practical commands, simple scripts, and automation.

Why Monitoring Disk Usage Matters

Most teams rely on basic alerts when disks are almost full. But by that point, your options are limited and urgent.

Monitoring disk usage gives you:

  • Early visibility into storage growth
  • Time to plan capacity upgrades
  • Insight into abnormal usage patterns

This is especially important for small teams managing multiple servers without dedicated monitoring staff.

Step 1: Check Disk Usage with Built-in Commands

Linux provides simple commands to check disk usage instantly.

Use df for Filesystem Overview

df -h

This command shows disk usage across all mounted filesystems in a human-readable format.

Use du for Directory-Level Analysis

du -sh /var/log

This helps identify which directories are consuming the most space.

These commands are essential, but they only give you a snapshot—not a trend.

Step 2: Create a Simple Disk Monitoring Script

To track disk usage over time, you need to collect data regularly. A simple bash script can do this.

#!/bin/bash
DATE=$(date +"%Y-%m-%d %H:%M:%S")
df -h | grep '^/dev/' >> /var/log/disk-usage-history.log
echo "Checked at $DATE" >> /var/log/disk-usage-history.log

This creates a disk usage history in Linux that you can review later.

Step 3: Automate with Cron

Automation ensures consistent data collection.

Edit your crontab:

crontab -e

Add a job to run every hour:

0 * * * * /path/to/disk-monitor.sh

This approach enables continuous disk monitoring in Linux without manual effort.

Step 4: Analyze Disk Usage Over Time

Once you collect data, patterns begin to emerge.

Look for:

  • Steady growth trends
  • Sudden spikes after deployments
  • Unexpected increases in specific partitions

This is where tracking disk space usage over time on your server becomes valuable for decision-making.

Real-World Example

A Linux server running MySQL shows stable usage at 70%. No alerts are triggered.

However, after tracking disk usage history, the team notices a weekly increase of 3%. Investigation reveals slow-growing binary logs that were never cleaned up.

By identifying the issue early, they:

  • Implement proper log rotation
  • Prevent disk exhaustion
  • Avoid emergency downtime

Common Mistakes to Avoid

  • Only checking disk usage manually
  • Not storing historical data
  • Ignoring small but consistent growth
  • Relying solely on critical alerts

Effective monitoring is about consistency and visibility, not just tools.

Summary

Learning how to monitor disk usage in Linux is not just about running commands—it’s about building a system that tracks growth over time. With simple scripts and cron jobs, you can gain valuable insights into your infrastructure without adding complexity.

If you want to go beyond scripts and get clear weekly insights into disk growth, CPU usage, and database trends, explore Infrastructure Health Reporting. It provides practical visibility designed for small teams managing real-world systems.

About the Author
Mariusz Antonik

Oracle Cloud Infrastructure expert and consultant specializing in database management and automation.

All Tags
#Advanced #alerts #Bash #bash cpu monitoring script #bash monitoring #bash scripting #Beginner #Best Practices #block volume backup #Capacity Planning #cloud backup strategy #cpu bottleneck #CPU Monitoring #cpu monitoring linux #cpu monitoring script linux #cpu trends #cpu usage trends #cpu usage trends linux #create oracle db system in oci #cron cpu monitoring #cron cpu monitoring linux #cron jobs #database monitoring #database performance #detect slow queries mysql #devops #disk capacity planning server #disk forecasting linux #disk growth trend linux #Disk Monitoring #disk usage #disk usage script linux #disk usage trends #Early Detection #easy infrastructure monitoring #free-tier #Guide #health dashboards #Health Reporting #historical server monitoring #how to monitor cpu usage linux #infrastructure #infrastructure health #infrastructure health dashboard #infrastructure health reporting #infrastructure monitoring #infrastructure monitoring report #infrastructure trends #infrastructure trends monitoring #Infrastructure Visibility #lightweight linux monitoring #lightweight monitoring #linux #linux administration #linux cpu monitoring #linux cpu usage #linux disk capacity planning #linux disk usage #Linux monitoring #linux monitoring setup #linux monitoring tools #linux performance #linux performance monitoring #linux server #linux server monitoring #linux servers #linux storage #linux tools #low maintenance monitoring #monitor cpu usage over time linux #monitor linux server health #monitor server trends #monitor small production server #monitoring without complexity #MySQL #mysql health reporting #MySQL monitoring #mysql optimization #MySQL Performance #mysql performance degradation #mysql performance monitoring #mysql performance trends #mysql query performance issues #mysql server monitoring #mysql slow queries #mysql slow query analysis #mysql slow query monitoring #mysql trends #mysql-health #networking #nsg #OCI #oci backup #oci bastion tutorial #oci block volume #oci infrastructure as code #OCI monitoring #oci networking #oci oracle database private subnet setup #oci oracle database tutorial #oci security #oci setup guide #oci terraform tutorial #oci tutorial for beginners #oci vcn terraform #oci virtual machine db system guide #oracle base database service tutorial #oracle cloud bastion #oracle cloud free tier tutorial #oracle cloud infrastructure step by step #oracle cloud infrastructure tutorial #oracle cloud storage #oracle database on oci setup #oracle-cloud #Performance #Performance Degradation #performance monitoring #performance trend monitoring #performance trends #plan disk growth server #practical server monitoring #predict disk usage growth #private instance access #query optimization #Security #security lists #server health #server health reporting #server health weekly report #server monitoring #Server Performance #server trend analysis #server-trends #simple cpu monitoring linux #simple linux monitoring #simple monitoring small business #simple monitoring system #simple ops monitoring #slow queries #slow query reporting mysql #small business infrastructure #small business IT #small business servers #small infrastructure monitoring #small server monitoring #ssh bastion #storage capacity planning linux #storage monitoring #subnets #System Health #system health reporting #terraform oci compute #terraform oracle cloud infrastructure #Trend Monitoring #trend-analysis #trends #Tutorial #vcn