Back to Blog
Track Disk Usage Over Time on Linux Before Capacity Becomes an Incident

Track Disk Usage Over Time on Linux Before Capacity Becomes an Incident

   Mariusz Antonik    Automation    7 min read    30 views

A Linux server can look healthy today and still be heading toward a storage incident. A single df result tells you how much space is free now, but it does not show whether a filesystem is growing by 200 MB a week or 20 GB a day. Tracking disk usage over time on Linux turns that snapshot into a capacity forecast.

You do not need a large monitoring platform to get useful trend data. A scheduled command, a small history file, and a weekly review can reveal steady growth, sudden jumps, and shrinking safety margins. The key is to collect consistent measurements and connect them to the workloads that create the data.

Why a disk usage snapshot is not enough

Percentage-used thresholds are useful, but they describe only the current state. Two filesystems at 70 percent can carry very different risks. One may have remained stable for a year; the other may have gained ten percentage points since Monday and be on course to fill before the weekend.

Trend data answers the operational questions that a snapshot cannot:

  • How quickly is each filesystem growing?
  • Is growth steady, seasonal, or sudden?
  • How many days of usable capacity remain at the recent rate?
  • Which application, database, log, backup, or user directory is responsible?
  • Did cleanup or retention changes have the expected effect?

Start with consistent filesystem measurements

Collect the same fields at the same time each day. For local filesystems, df provides total, used, available, and percentage-used values. POSIX output keeps each filesystem on one line, while byte units make calculations consistent:

date -u +%Y-%m-%dT%H:%M:%SZ
df -P -B1 -x tmpfs -x devtmpfs

Exclude temporary pseudo-filesystems that do not represent persistent capacity. Be deliberate about network mounts: include them when your service depends on their available space, but label them separately because remote availability and reporting behavior may differ.

Record the filesystem device and mount point, not just a display name. Mount points can move, devices can be replaced, and containers can show filesystems differently from the host. Stable identifiers help prevent an apparent trend from being caused by a configuration change.

Save a lightweight daily history

A CSV file is enough for a small server. The following Bash example appends one row per persistent filesystem with a UTC timestamp:

#!/usr/bin/env bash
set -euo pipefail
out=/var/log/disk-usage-history.csv

if [[ ! -f "$out" ]]; then
  echo 'timestamp,filesystem,bytes_total,bytes_used,bytes_available,percent_used,mountpoint' > "$out"
fi

ts=$(date -u +%Y-%m-%dT%H:%M:%SZ)
df -P -B1 -x tmpfs -x devtmpfs | awk -v ts="$ts" 'NR > 1 {
  gsub(/%/, "", $5)
  print ts "," $1 "," $2 "," $3 "," $4 "," $5 "," $6
}' >> "$out"

Run the collector from a systemd timer or cron at a quiet, consistent time. Protect the output file from untrusted writes, monitor the collector itself, and apply rotation or retention so the measurement history does not become another source of uncontrolled growth.

Calculate growth rate instead of watching percentages alone

Compare used bytes between two observations and divide by elapsed time. If a filesystem gained 35 GB over seven days, its average growth was 5 GB per day. Available space divided by that growth rate gives a rough time-to-capacity estimate.

daily_growth = (used_now - used_previous) / elapsed_days
days_remaining = available_now / daily_growth

Treat the result as a forecast, not a promise. Growth may accelerate during imports, backups, sales periods, or product launches. Filesystem overhead and reserved blocks also mean that “100 percent” is not a safe operating target. Forecast against a practical action threshold such as 80 or 85 percent, with a suitable buffer for your workload.

Use multiple windows to avoid misleading forecasts

A one-day difference can be dominated by log rotation, a temporary export, or a backup cycle. Calculate short and medium windows—for example, seven-day and thirty-day growth. A fast seven-day rate with a modest thirty-day rate highlights a recent change; similar rates suggest sustained growth.

For cyclical workloads, compare equivalent points in the cycle. Measure Monday after the weekend backup against the previous Monday, not against Sunday before the backup. Median daily growth is often more robust than a simple average when occasional cleanup jobs create large downward steps.

Find what is consuming the space

A trend warning should lead to a focused investigation. Start at the affected mount point and summarize its largest top-level directories without crossing into other filesystems:

sudo du -x -h --max-depth=1 /var | sort -h
sudo du -x -h --max-depth=1 /srv | sort -h

Use du carefully on busy or very large trees because a full walk can create I/O load. Run it during an appropriate window, narrow the path, or use filesystem-specific tools and application metrics when available.

Common sources of unexplained growth include application logs without effective rotation, MySQL binary logs, database tables, container layers, package caches, abandoned uploads, local backup copies, and deleted files that remain open by a process. If df reports more usage than du can account for, check open deleted files with lsof +L1.

Monitor inode usage as well as bytes

A filesystem can fail to create files while plenty of byte capacity remains if it runs out of inodes. This is common when an application creates millions of small cache, session, queue, or temporary files. Add df -Pi to the collection and trend inode utilization for filesystems where file counts can grow rapidly.

Report byte capacity and inode capacity separately. A server at 45 percent bytes but 92 percent inodes needs action even though a conventional space alert may remain quiet.

Account for databases, containers, snapshots, and backups

Host filesystem growth is only the outer layer. For MySQL, correlate disk growth with database and table size, binary-log retention, temporary files, and backup output. A database directory growing steadily may be expected; a binary-log directory growing after a failed purge is a different issue with a different fix.

Container hosts need visibility into images, writable layers, volumes, and logs. Deleting a container does not always remove its volumes, and unbounded JSON logs can consume host capacity quickly. Avoid automated deletion until ownership and recovery requirements are clear.

Snapshots and backups can hide capacity use outside the normal directory view or on separate storage. Include their retention, repository growth, and restore requirements in the same weekly capacity conversation.

Choose warnings based on time to action

Static percentage thresholds remain useful as a final safety net, but trend warnings should consider how long your team needs to respond. A small server gaining 2 GB per day with 20 GB free has about ten days of raw capacity. If procurement, migration, or maintenance approval takes a week, that is already an action item.

  • Stable: utilization and growth remain within the expected range, with a comfortable capacity horizon.
  • Watch: growth has accelerated, the safety margin is narrowing, or an expected cleanup did not occur.
  • Action needed: projected capacity is inside the response window, inode use is critical, or a sudden jump threatens service continuity.

Require both evidence and context in the warning. “Disk is 76 percent full” is less useful than “/var gained 48 GB in seven days, mainly under MySQL binary logs; at the current rate it will cross the 85 percent action threshold in nine days.”

Build a concise weekly disk growth report

A practical report does not need every daily measurement. For each important filesystem, include current utilization, change over the reporting period, seven- and thirty-day growth rates, forecast to the action threshold, inode status, likely growth source, and one recommended next step.

  • Current state: used and available capacity, percentage used, and inode utilization.
  • Trend: change since last week and whether growth is accelerating.
  • Forecast: estimated time to the operational threshold, with assumptions stated.
  • Cause: the directory, service, database, backup, or retention behavior driving growth.
  • Action: clean up safely, correct retention, expand storage, archive data, or investigate the workload.

Keep raw measurements for audit and deeper analysis, but lead with the conclusion. Developers and business owners should be able to see which storage risk matters, why it changed, and who needs to act.

Track disk growth without another noisy dashboard

Reliable capacity planning starts with small, repeatable measurements. Daily collection and a weekly trend review expose slow growth that point-in-time alerts miss while keeping immediate notifications for genuinely urgent conditions.

DMCloud Architect turns Linux, MySQL, backup, and infrastructure signals into a clear weekly view with risks and next actions. To monitor disk growth and other operational trends without spending every day in dashboards, explore Infrastructure Health Reporting.

About the Author
Mariusz Antonik

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

All Tags
#active-directory #adcli #Advanced #agent-visibility #agentless-monitoring #alerts #amazon-linux-2023 #argo-cd #asset-inventory #atop #auditd #automation #backend-infrastructure #backup-monitoring #backup-setup #backup-verification #backups #bandwidth-monitoring #bare-metal-server #baseline-delta-monitoring #Bash #bash cpu monitoring script #bash monitoring #bash scripting #bash-automation #bash-script #bash-scripts #Beginner #Best Practices #bind-dns #block volume backup #brute-force-protection #Capacity Planning #career-development #centos-7 #centos-ftp-migration #centralized-logging #chromebook-linux #ci-cd #cifs-mounts #clonezilla #cloud backup strategy #cloud-administration #cloud-costs #cloud-database-setup #cloud-networking #cloudflare-workers #cluster-administration #compute #container-monitoring #control-panel-security #cpu bottleneck #CPU Monitoring #cpu monitoring linux #cpu monitoring script linux #cpu trends #cpu usage trends #cpu usage trends linux #cpu-monitoring-script #cpu-monitoring-without-tools #cpu-performance-decline-server #cpu-performance-degradation-linux #cpu-performance-trends-linux #cpu-pressure-linux #cpu-reporting-linux-server #cpu-saturation #cpu-usage-history-linux #create oracle db system in oci #cron #cron cpu monitoring #cron cpu monitoring linux #cron jobs #cron-monitoring #custom-linux-distribution #cve-2026-98432 #cve-advisory #data-sanitization #database #database monitoring #database performance #database-health #database-migration #database-setup #debian #deployment-checklist #detect slow queries mysql #devops #devops-career #devops-checklist #devops-help #devops-interview #devops-learning #disk capacity planning server #disk forecasting linux #disk growth trend linux #Disk Monitoring #disk usage #disk usage script linux #disk usage trends #disk-capacity #disk-growth #disk-saturation-detection-linux #disk-scaling-planning-linux #disk-space-monitoring #disk-usage-history-linux #dns-migration #dnssec #Early Detection #easy infrastructure monitoring #ebpf #egress-monitoring #elasticsearch #exposed-port-monitoring #fail2ban #field-server-checklist #firewall-rules #fleet-ops #free-tier #freelance-sysadmin #gitlab-ci #gitops-security #growth-trends #Guide #health dashboards #Health Reporting #historical server monitoring #historical-monitoring #home-lab #how to monitor cpu usage linux #hpc #http-boot #https-certificates #incident-response #infiniband #infrastructure #infrastructure health #infrastructure health dashboard #infrastructure health reporting #infrastructure monitoring #infrastructure monitoring report #infrastructure trends #infrastructure trends monitoring #Infrastructure Visibility #infrastructure-as-code #infrastructure-automation #infrastructure-checklist #infrastructure-reporting #inode-monitoring #interview-prep #ip-allowlist #iproute2 #it-asset-disposal #journald #kernel-patching #kubernetes-security #latency-checks #lightweight linux monitoring #lightweight monitoring #lightweight-monitoring-solution #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 #linux-admin #linux-commands #linux-disk-monitoring #linux-file-sharing #linux-hardening #linux-health #linux-home-lab #linux-hotspot #linux-maintenance #linux-migration #linux-monitoring-for-small-business #linux-monitoring-script #linux-monitoring-small-business #linux-networking #linux-patch-management #linux-performance-tuning #linux-plus #linux-remote-desktop #linux-security #linux-server-health #linux-server-health-checks #linux-troubleshooting #lmod #local-dns #local-network #log-management #log-retention #logrotate #loki #low maintenance monitoring #lpic-1 #luks2 #machine-password-rotation #mkcert #monitor cpu usage over time linux #monitor linux server health #monitor server trends #monitor small production server #monitor-server-trends-over-time #monitoring #monitoring without complexity #monitoring-agent #monitoring-for-lean-teams #monitoring-without-devops-team #mptcp #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 #mysql-health-check #mysql-heatwave #mysql-indexing #mysql-monitoring-lightweight #mysql-monitoring-production #mysql-performance-visibility #mysql-query-degradation #mysql-query-latency #mysql-slow-query #mysql-workload-trends #network-automation #network-exposure #network-monitoring #network-traffic #networking #networkpolicy #nftables #node-express #nsg #observability #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 #oci-database #oci-mysql-heatwave #oci-mysql-heatwave-tutorial #oci-subnets #offline-pwa #open-port-monitoring #openhpc #operations-checklist #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 #oracle-cloud-mysql-database-service #oracle-cloud-mysql-setup #oracle-cloud-vcn-setup #oracle-linux #oracle-linux-9 #outbound-connections #patch-compliance #patch-management #path-mtu-discovery #Performance #Performance Degradation #performance monitoring #performance trend monitoring #performance trends #ping-monitoring #plan disk growth server #plesk #practical server monitoring #practical-linux-monitoring #predict disk usage growth #private instance access #process-monitoring #production-database #production-troubleshooting #prometheus #proxmox #Python #query optimization #query-trends #remote-workstation-security #rhel-tuned #rollback #route-tables #rsyslog #rtnetlink #samba-server #Security #security lists #security-audit #security-compliance #security-hardening #security-monitoring #selinux #server #server health #server health reporting #server health weekly report #server monitoring #Server Performance #server trend analysis #server-administration #server-audit #server-checklist #server-decommissioning #server-diagnostics #server-hardening #server-health-check #server-health-checklist #server-health-insights #server-health-summary #server-management #server-operations #server-security #server-security-audit #server-security-checklist #server-throughput #server-trends #server-troubleshooting #servers #service-worker #siem #simple cpu monitoring linux #simple linux monitoring #simple monitoring small business #simple monitoring system #simple ops monitoring #slow queries #slow query reporting mysql #slow-query-log #slurm #small business infrastructure #small business IT #small business servers #small infrastructure monitoring #small server monitoring #small-business-monitoring #small-business-security #small-business-server-monitoring #small-business-tech #software-support-engineer #sosreport #source-built-linux #ssh #ssh bastion #ssh-security #sssd #storage capacity planning linux #storage monitoring #subnets #support-engineer-interview #sysadmin-checklist #sysadmin-lab #syscall-monitoring #sysstat #System Health #system health reporting #system-administration #system-monitoring #systemd #tcp-mtu-probing #tcp-tuning #technical-support #terraform oci compute #terraform oracle cloud infrastructure #track-disk-growth-linux #Trend Monitoring #trend-analysis #trends #Troubleshooting #tuned-adm #Tutorial #ubuntu #ufw #uptime-checks #uptime-monitoring #vcn #vcn-design #vector #vps-management #vps-setup #vsftpd #vulnerability-management #vulnerability-response #wazuh #weekly-checklist #weekly-health-report #weekly-health-reporting #weekly-health-reports #weekly-reports #weekly-server-report #windows-admin #windows-agent #windows-linux #xrdp