How to Monitor Disk Space Usage on Linux Server - Complete Guide

Are you running out of disk space and wondering how to monitor disk usage on your Linux server? Need to track disk space utilization and receive alerts before disks fill up? This comprehensive guide shows you multiple methods to check di...

Last updated: 2025-11-17

How to Monitor Disk Space Usage on Linux Server - Complete Guide

Are you running out of disk space and wondering how to monitor disk usage on your Linux server? Need to track disk space utilization and receive alerts before disks fill up? This comprehensive guide shows you multiple methods to check disk space, monitor disk usage over time, detect rapid disk space growth, and prevent disk space exhaustion that can cause server failures.

Why Monitoring Disk Space Matters

Disk space exhaustion can cause "No space left on device" errors that crash applications, prevent system operations, and cause data loss. Log files, database files, temporary files, and application data can consume disk space rapidly. Regular monitoring of disk space helps you detect space-consuming files early, plan capacity upgrades, optimize disk usage, and prevent disk space exhaustion that can cause critical system failures.

Method 1: Check Disk Space with df Command

The df command is the standard way to check disk space usage on Linux.

Basic Disk Space Check

To see disk space for all filesystems:

# Human-readable disk space
df -h

This shows:

  • Filesystem name
  • Total size
  • Used space
  • Available space
  • Usage percentage
  • Mount point

Check Specific Partition

To check disk space for a specific partition:

# Check root partition
df -h /

# Check /var partition
df -h /var

# Check /home partition
df -h /home

This helps identify which partitions are approaching capacity limits.

Disk Space in Megabytes

For precise values in megabytes:

# Disk space in MB
df -m

This shows disk space in megabytes, useful for scripts and calculations.

Method 2: Check Disk Space with du Command

The du command shows disk usage for directories.

Directory Disk Usage

To see disk usage for a directory:

# Human-readable directory usage
du -h /var/log

# Summary of directory usage
du -sh /var/log

# Top 10 largest directories
du -h / | sort -rh | head -n 10

This helps identify which directories consume the most disk space.

Total Disk Usage

To see total disk usage:

# Total disk usage
du -sh /

This provides total disk usage for the root filesystem.

Method 3: Check Disk Space with lsblk Command

The lsblk command shows block devices and their mount points.

List Block Devices

# List block devices
lsblk

# With filesystem information
lsblk -f

This shows block devices, sizes, and mount points.

Method 4: Automated Disk Space Monitoring with Zuzia.app

Manually checking disk space works for occasional verification, but for production servers, you need automated monitoring that alerts you when disk usage exceeds thresholds. Zuzia.app provides comprehensive disk space monitoring through scheduled command execution.

Setting Up Automated Disk Space Monitoring

  1. Add Scheduled Task in Zuzia.app Dashboard

    • Navigate to your Linux server in Zuzia.app
    • Click "Add Scheduled Task"
    • Choose "Command Execution" as the task type
  2. Configure Disk Space Check Command

    • Enter command: df -h
    • Set execution frequency: Every hour (recommended)
    • Configure alert conditions: Alert when disk usage exceeds thresholds (e.g., > 80%)
    • Set up different thresholds for different partitions
  3. Set Up Notifications

    • Choose notification channels (email, webhook, Slack, etc.)
    • Configure alert thresholds (e.g., alert if disk usage > 80%)
    • Set up different thresholds for warning vs. critical
    • Configure escalation rules for critical disk space issues

Track disk space usage over time:

# Disk space with timestamp
echo "$(date): $(df -h / | awk 'NR==2 {print $5}')"

Zuzia.app stores all command outputs in its database, allowing you to track disk space trends and identify patterns over time.

Method 5: Advanced Disk Space Monitoring Techniques

Calculate Disk Usage Percentage

Calculate disk usage percentage for specific partitions:

# Get disk usage percentage for root
df -h / | awk 'NR==2 {print $5}'

# Extract percentage number
USAGE=$(df -h / | awk 'NR==2 {print $5}' | sed 's/%//')
echo "Disk usage: ${USAGE}%"

This helps create alert conditions based on usage percentage.

Compare Disk Space Over Time

By storing disk space data in Zuzia.app, you can compare current disk usage with previous measurements to detect rapid growth.

Monitor Multiple Partitions

Monitor multiple partitions simultaneously:

# Check multiple partitions
for partition in / /var /home; do
  echo "=== $partition ==="
  df -h $partition
done

This helps track disk usage across all critical partitions.

Real-World Use Cases for Disk Space Monitoring

Prevent Disk Space Exhaustion

Monitor disk space to prevent exhaustion:

# Check disk usage
df -h

# Alert if usage > 80%
USAGE=$(df -h / | awk 'NR==2 {print $5}' | sed 's/%//')
if [ "$USAGE" -gt 80 ]; then
  echo "ALERT: Disk usage exceeded 80%"
fi

Set up Zuzia.app to check disk space hourly and alert when thresholds are exceeded.

Rapid Growth Detection

Detect rapid disk space growth:

# Track disk usage over time
df -h / | awk 'NR==2 {print $5}' > /tmp/disk-usage-$(date +%Y%m%d-%H%M).txt

Use Zuzia.app's historical data to identify rapid growth patterns and plan capacity upgrades.

Capacity Planning

Use historical disk space data to plan capacity:

# Track disk usage trends
df -h / | awk 'NR==2 {print $2, $3, $4, $5}'

Zuzia.app's historical data helps you understand disk space growth trends and plan capacity upgrades accordingly.

Best Practices for Disk Space Monitoring

1. Monitor Regularly

Check disk space at least every hour for active monitoring. Less critical systems can be checked every 6-12 hours. Use Zuzia.app automated monitoring to ensure regular checks.

2. Set Appropriate Thresholds

Set different alert thresholds:

  • Warning: Disk usage > 70%
  • Critical: Disk usage > 80%
  • Emergency: Disk usage > 90%

3. Monitor Critical Partitions Separately

Monitor critical partitions like /, /var, /home, and /tmp separately, as they often have different usage patterns and growth rates.

Use Zuzia.app's historical data to track disk space trends over time. Understanding how disk space grows helps plan capacity upgrades and optimize usage.

5. Plan Cleanup and Archiving

When disk usage approaches thresholds:

  1. Identify large files for cleanup
  2. Archive old data instead of deleting
  3. Implement log rotation
  4. Optimize database files if possible

Troubleshooting Common Disk Space Issues

Disk Space Full

If disk space is full:

  1. Check disk usage: df -h
  2. Find large files: find / -type f -exec du -h {} + 2>/dev/null | sort -rh | head -n 10
  3. Identify files for cleanup
  4. Archive or delete unnecessary files
  5. Implement log rotation

Rapid Disk Space Growth

If disk space grows rapidly:

  1. Monitor disk usage frequently: df -h
  2. Track growth using Zuzia.app historical data
  3. Identify source of growth: Check logs, databases, temporary files
  4. Implement cleanup scripts
  5. Plan capacity upgrade if needed

Cannot Write to Disk

If you cannot write to disk:

  1. Check disk space: df -h
  2. Check inode usage: df -i
  3. Verify permissions: ls -la /path
  4. Check filesystem errors: fsck -n /dev/sda1
  5. Free up space if needed

FAQ: Common Questions About Monitoring Disk Space

How often should I check disk space on Linux?

We recommend checking disk space every hour for active monitoring. Use Zuzia.app automated monitoring to check continuously without manual intervention. Less critical systems can be checked every 6-12 hours.

What should I do when disk usage exceeds thresholds?

When disk usage exceeds thresholds, immediately investigate: identify large files using find and du commands, clean up unnecessary files, archive old data, implement log rotation, and plan capacity upgrades if growth continues. Use Zuzia.app to track disk usage and receive alerts when thresholds are exceeded.

Can I monitor multiple partitions separately?

Yes, you can monitor multiple partitions separately: df -h / /var /home for specific partitions, or set up separate monitoring tasks for each critical partition with different thresholds. This helps focus monitoring on partitions that matter most.

Zuzia.app stores all disk space data historically in its database, allowing you to view disk space growth trends over time. You can see historical data showing disk usage on different dates, identify when disk space grew rapidly, and track growth patterns to plan capacity upgrades.

What's the difference between df and du for checking disk space?

df shows filesystem-level disk space (total, used, available for mounted filesystems), while du shows directory-level disk usage (how much space directories and files consume). Use df to check overall disk space, and du to identify which directories consume the most space.

Can I monitor disk space across multiple Linux servers?

Yes, Zuzia.app allows you to add multiple servers and monitor disk space across all of them simultaneously. Each server executes disk space check commands independently, and all results are stored in Zuzia.app's database for centralized monitoring and comparison.

Does Zuzia.app use AI to analyze disk space patterns?

Yes, if you have Zuzia.app's full package, AI analysis is enabled. The AI can detect patterns in disk space growth, identify rapid growth trends, predict when disk space will be exhausted based on historical data, and suggest cleanup or capacity upgrade strategies based on machine learning algorithms.

We use cookies to ensure the proper functioning of our website.