CH-J Toolsserver management over SSH
Menu
All guides and articles →

The disk is full, but files do not take up space: how to find the cause

Explain the difference between df and du. Find deleted open files, exhausted inodes, hidden data, snapshots, and quotas without dangerous blind cleaning.

Df and du measure different things

The df command shows the accounting for a mounted file system, while du goes through the available file names and counts their usage. Therefore, their results may not be the same. A file system may hold space after a deleted but still open file; it may have metadata, reserves, or snapshots that a normal directory traversal does not explain.

Before you start deleting something, identify the specific failed operation and its target path. The message No space left on device may not mean exhausted data blocks at the root of /. It could be inodes, another mounted volume, temporary space, or an environment limit. Additionally, Disk quota exceeded indicates a different class of constraint than full disk.

The first phase of diagnostics should be read-only. Deleting the largest file found can remove the active database without freeing up space if a process is holding it open. First, determine the data owner, service binding, and available recovery. Also, if you are running low on space, consider that creating new archives on the same volume will make things worse.

Determine the correct volume, blocks, and inodes

Specify a path to the same filesystem where the write fails. If the target file has not yet been created, use an existing parent directory. Compare the output with the actual connection. Web data, database, and /tmp may be on different volumes and the difference cannot be explained by the machine-wide summary.

df -hT /var/www
df -i /var/www
findmnt -T /var/www
lsblk -f

Df -i shows inode availability where the filesystem makes sense. A large number of small files can exhaust this capacity, even if gigabytes remain free. Some filesystems handle metadata differently, so do not mechanically transfer the result between ext4, XFS, Btrfs, or network storage.

Findmnt will help uncover surprises: read-only mounts, overlays, tmpfs, or other underlying disks. Tmpfs draws memory capacity based on its limit, not the common free space of all disks. If an application is running in a container or other mount namespace, its view may differ from the admin shell on the host.

Compare the same range and take into account hidden names

Run du with the correct permissions and the same scope that you are comparing with df. If du cannot access the directory, it may report an error and not count the data. Therefore, do not throw away the error output. The -x switch will limit the run to a single file system and help avoid confusing mounted data volumes with the root itself.

# GNU du: nejprve omezená úroveň v podezřelé oblasti
sudo du -x -h --max-depth=1 /var
# Potom cíleně pokračujte do skutečně velkého podadresáře
sudo du -x -h --max-depth=1 /var/log

These commands can read many items even with a shallow depth of listing. On a very large production tree, choose a suitable time and narrower scope. Depth limits the display of totals, not necessarily all work below directories. Do not compare outputs based solely on visual ordering of human units; use comparable byte values for automatic comparisons.

The command du directory/* will pass files according to shell expansion and will normally omit names starting with a dot. Passing a directory itself will also include its hidden children. Hardlinks and sparse files also cause differences: the logical length of a file is not automatically the number of allocated blocks. A different result from du --apparent-size may therefore not indicate newly consumed space.

A deleted file may still be held by a running process

When deleting an open file name, the process can continue to use its contents via the existing descriptor. The space is only freed when the last matching reference is lost. A typical example is a log file deleted without the service switching to a new file. Df then sees the consumption, but regular du no longer has a name by which to find the contents.

# Pokud je lsof na systému dostupný:
sudo lsof +L1

Find the process, size, and label of the deleted file. Consider the actual type and file system; not every unreferenced entry is the cause of your specific problem. Compare the PID found to the service and the current state of the process. The PID can be reused after termination, and the old listing is not a permanent identity.

The fix depends on the application. For a log, a documented signal for reopening files or a controlled rotation may be correct. For another program, a scheduled restart may be needed. Do not blindly truncate a foreign /proc/PID/fd or terminate a database just because of a large value. Aborting a write or deleting a live data file can cause data loss.

Data hidden under mount, snapshots, and storage accounting

If you mount another filesystem to a non-empty directory, you won't see the original data under it from the regular path. But it still takes up space on the original volume. This scenario is common after a failed data disk mount: an application starts writing to the original directory, and a later mount hides its new files.

Verify suspicions with respect to active services. Do not dismount a production mount just for convenience. An administrator can use an isolated view of the underlying file system or a maintenance window, but they must understand the namespace and what each service uses. Identify and compare any hidden data found to the active copy first.

Snapshots can hold blocks even if you delete the original files. Additionally, there can be multiple capacity tiers for Btrfs, ZFS, thin volumes, and hypervisors. Free space inside the guest system is not identical to the host thin pool capacity. Use the storage-specific reading tools to check the retention and reason for snapshots before deleting them.

Containers, quotas, and reserved space

Container images, writable layers, and volumes may be billed differently. When using Docker, start with an overview of the Docker and then search for specific data. Do not manually delete files in the engine's internal storage. You could corrupt metadata or delete the application's data volume, even if you see cache in the name.

# Pokud skutečně používáte Docker:
docker system df -v
# Kvóty, pokud jsou na systému zavedené a nástroj dostupný:
quota -s

The docker system prune command is not the diagnostic equivalent of this overview. The deletion must respect the images, containers, volumes, and application workflows in use and recovery. For reserved blocks, such as ext4, adjusting the reserve is not considered an automatic fix. The reserve may have an operational purpose; consider the change based on the volume's role and the documentation for the specific system.

The quota limits the account or project even if the entire volume has space. Similarly, hosting or network storage may enforce its own limit. Therefore, if there is a difference between the administrative and application test, compare the actual UID, project, and namespace under which the application writes. Successful root write does not exclude the exhausted quota of the regular account.

Safe release of space only after confirmed cause

Once you know what's taking up space, choose a targeted remediation. Use proper rotation and retention for logs, application-driven caching for recoverable caches, and an approved retention policy for unneeded artifacts. For active data, storage expansion or application-driven migration may be the right answer. Accidentally deleting a large directory should not be a universal first step.

  • Confirm the specific file system and type of limit that has been exhausted.
  • Determine the data owner and whether the file is open or the blocks are held by a snapshot.
  • Prepare a recovery option for irreplaceable data.
  • Make the smallest appropriate change and measure the same range again.
  • Verify the actual originally failing write and the health of the service, not just the number in df.

In CH-J Tools, the disk overview can help identify the affected volume and the terminal can perform a targeted scan. However, it is not correct to claim that the same numerical value from one panel will explain every snapshot or container accounting. The result must correspond to the actual background and application path.

Write down an explanation of the difference and prevention of recurrence

After the repair, indicate whether it was an open deleted log, file count, quota, hidden data, or storage layer. Record the before and after state on the same drives and with the same path. A successful one-time recovery does not solve the cause if unlimited logs quickly re-create or mount stops working.

Monitor capacity, inodes, and relevant pool or quota by service role. For services that depend on a mounted volume, ensure that they do not accidentally write to the root disk when it is not present. Deduce retention and warning thresholds based on data growth and time to action. A universal percentage, regardless of size and growth rate, may not prevent another outage.

Frequently asked questions

Why didn't deleting a large log free up space?

A process may still be holding a deleted file open. Check lsof +L1 and use the service's documented procedure to reopen the log.

Can a disk be full even with free gigabytes?

Yes, for example, you may run out of inodes or account quota. Please verify the exact error and target file system.

Is the difference between df and du automatically an error?

No. The tools measure different views, and metadata, reserves, snapshots, or open deleted files can explain the difference.

Should I run docker system prune now?

No. First, determine the consumption and truly unnecessary objects. A general cleaning may remove something needed for operation or renovation.

Detailed documentation

GNU coreutils: df →

GNU coreutils: du →

lsof: open files and number of links →

Docker: storage usage overview →

Biometric unlock and security →

All tutorials by category →