VPS & Linux

Linux disk cleanup: free space without deleting the wrong data

Disk cleanup should begin with ownership and lifecycle, not a blind delete command. The safest space to reclaim is data you can name, reproduce, rotate, or expire without destroying the only copy of something important.

Identify the full filesystem and largest consumers

Confirm the mount with df, then use du or filesystem-specific tooling to find large directories. Account for deleted-but-open files, snapshots, container layers, package caches, logs, databases, uploads, and backup files stored on the same disk.

A large directory is not automatically safe to remove. Record what service owns it before changing anything.

Look for deleted files still held open

A rotated or manually deleted log can continue consuming blocks while a process keeps the old file descriptor open. lsof-style checks can reveal this mismatch between directory listings and filesystem usage.

Restart or reopen the specific service only after confirming the file can be released safely.

Clean by policy, not panic

Use logrotate, package-cache cleanup, temp-file policies, application retention, image pruning, or explicit artifact expiration as appropriate. Keep independent backups off the live filesystem. Do not accumulate “backup” archives beside production data.

Do not remove database, queue, mail, or application state because a directory name looks temporary.

Prevent the next full disk

Set alerts before the filesystem reaches emergency levels, track growth rate, reserve operational headroom, and document which directories are expected to grow. Resize storage when retained production data legitimately outgrows the plan.

  • Confirm the exact mount.
  • Check deleted-open files.
  • Apply service-specific retention.
  • Alert before emergency capacity.
Related DotMoose serviceExplore DotMoose VPS hosting

Keep reading

Related guides.

More vps & linux →