InterspaceKnowledgebaseTech ArticlesTutorialsHow to Analyze Disk Storage in Linux
TUTORIALS
14-Nov-2024
How to Analyze Disk Storage in Linux

1.Essential Linux Storage Commands

The df and du commands form the core of Linux storage analysis. These tools help track disk usage and identify potential space issues.
df -h displays mounted filesystem information in human-readable format:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 20G 14G 4.6G 75% /
/dev/sdb1 100G 50G 45G 53% /data
tmpfs 4G 0 4G 0% /run

Key df options:

  • -i
    Shows inode usage instead of block usage
  • -T
    Displays filesystem types
  • --exclude-type=tmpfs
    Filters out specific filesystem types

The du command analyzes directory space usage:
du -sh /path/to/directory

Common du combinations:

  • du -sh *
    Shows total size of each item in current directory
  • du -h --max-depth=1
    Displays directory sizes one level deep
  • du --threshold=1G
    Lists only items larger than 1GB

2.Advanced Storage Analysis Tools

Install required tools:
# Ubuntu/Debian
sudo apt install ncdu prometheus-node-exporter sysstat iotop

# RHEL/CentOS/Fedora
sudo dnf install ncdu prometheus-node-exporter sysstat iotop

ncdu provides an interactive interface for storage analysis:
ncdu /

Navigation keys:

  • Arrow keys
    Move through directories
  • Enter
    Enter selected directory
  • d
    Delete selected item (use with caution)

Finding large files with advanced commands:
# Files larger than 1GB, modified in last 30 days
find / -type f -size +1G -mtime -30

# Top 10 largest files in system
find / -type f -exec du -Sh {} + | sort -rh | head -n 10

# Files growing rapidly
find / -type f -size +100M -mtime -1

3.Storage Performance Analysis

Monitor I/O statistics with iostat:
iostat -xz 1

Check disk read/write performance:
dd if=/dev/zero of=test bs=1G count=1 oflag=direct

Monitor file system operations:
sudo iotop -o

4.Clear common space hogs

Package Cache:
sudo apt clean or sudo dnf clean all

Journal Logs:
sudo journalctl --vacuum-time=7d

Docker:
docker system prune -a

Check for deleted but open files:
sudo lsof | grep deleted

Analyze disk fragmentation:
sudo e4defrag -c /

Related content
Documentation
Cloud
Communications
Hosting
My Interspace
Tech Articles
Tutorials
Learn
News
Latest news
Latest events
Related products
Premium Internet Access
Highest-grade Internet access for professional needs. Superior point-to-point fiber-optic link, symmetrical down/up speed, unlimited traffic, SLA 99.9% and static IP. Direct connections to the top tier 1 global providers. Our network architecture is passionately designed to ensure the highest quality connections to any destination worldwide, boasting unmatched transfer speeds and multi-tier redundancy.
Dedicated Servers
Dedicated servers on high-grade hardware from well-known sever vendors. They are hosted in our own data centers, enabling us full control in safe-guarding the uptime 24/7. Selection of primary data centers and a disaster recovery one located at a safe distance. Power control options (reset, power off/on) and free of charge KVM-over-IP available 24/7 on a single click, including support to remotely boot/install your own ISO images.
Elastic Cloud VPS
Elastic Cloud VPS is a virtual machine powered by advanced cloud and networking technologies, offering significant advantages over traditional VPS hosting at an unbeatable price to performance ratio. Deploy OS and apps in just 1 min. Dynamically add or remove features. One click automatic backups, snapshots and disaster recovery replica, stored in a remote data center at a safe distance. New gen of AMD EPYC CPUs, ultra fast NVMe disks, dedicated connections and free private net.


Our website uses cookies. By continuing to use our website, you consent to the use of cookies and you agree with our Terms and conditions.    I understand