Innovate | Connect | Transform
ContactService statusUSD $

GICT knowledge base

Troubleshooting Common Disk Space Issues in Ubuntu

Published

UbuntuLinux and Commands

Introduction

Ubuntu users often encounter various disk space problems that can cause system slowdowns, prevent updates, or stop applications from working properly. Understanding how to diagnose and fix these issues helps you maintain a healthy system and avoid data loss or system corruption.

This article covers the most common disk space problems Ubuntu users face and provides step-by-step solutions to resolve them. You will learn to identify different types of storage issues, understand their causes, and apply the right fixes to restore normal system operation.

Prerequisites

Before following this article, ensure you have:

  • An Ubuntu machine experiencing disk space issues
  • Administrative privileges (ability to use sudo)
  • Basic knowledge of using the terminal
  • Understanding that some troubleshooting may require system restarts

Common Disk Space Problems and Solutions

Ubuntu disk space issues typically fall into several categories, each requiring different troubleshooting approaches.

Problem 1: System Says “No Space Left” But Disk Shows Available Space

This confusing situation happens when you see available space in file managers, but get “no space left” errors when trying to save files or install software.

Causes

  • Inodes (file system entries) are exhausted even though disk space remains
  • Temporary files are filling up small partitions
  • Reserved space for system processes is being used

Solution Steps

Check inode usage:

df -i

Look for filesystems showing 100% or near 100% in the “IUse%” column.

If inodes are full, remove many small files:

sudo find /tmp -type f -delete
sudo find /var/tmp -type f -delete
rm -rf ~/.cache/*

Check for hidden large directories:

sudo du -sh /.[!.]* 2>/dev/null

Clear system temporary files:

sudo systemctl stop systemd-tmpfiles-clean.timer
sudo rm -rf /tmp/*
sudo rm -rf /var/tmp/*
sudo systemctl start systemd-tmpfiles-clean.timer

Problem 2: APT Package Manager Fails Due to Disk Space

Package installations or updates fail with disk space errors, even after running cleanup commands.

Causes

  • APT needs more space than is available for temporary operations
  • Package database corruption due to previous failed installations
  • /boot partition is full with old kernel images

Solution Steps

Check /boot partition specifically:

df -h /boot

If /boot is full, remove old kernel images:

dpkg -l | grep linux-image
sudo apt remove linux-image-VERSION-NUMBER-generic

Replace VERSION-NUMBER with older versions, keeping the current and one previous kernel.

Clean APT cache and fix broken packages:

sudo apt clean
sudo apt autoclean
sudo apt autoremove
sudo dpkg --configure -a

If APT database is corrupted, rebuild it:

sudo rm -rf /var/lib/apt/lists/*
sudo apt update

Problem 3: Hidden Files Taking Up Space

Large amounts of space are used but you can’t find where the files are located.

Causes

  • Hidden directories with dots (.) in front of their names
  • Files in system directories that regular users can’t see
  • Deleted files that are still held open by running processes

Solution Steps

Check for hidden files in your home directory:

du -sh ~/.[!.]* | sort -hr

Look for large hidden system directories:

sudo du -sh /var/.[!.]* /usr/.[!.]* 2>/dev/null

Find files that are deleted but still open (taking up space):

sudo lsof | grep deleted

Restart services holding deleted files:

sudo systemctl restart service-name

Or restart your computer to release all deleted files.

Problem 4: Log Files Growing Too Large

System log files consume excessive space and continue growing rapidly.

Causes

  • Log rotation not working properly
  • Applications creating excessive log entries
  • System errors causing repeated log messages

Solution Steps

Check which logs are largest:

sudo du -sh /var/log/* | sort -hr | head -10

Immediately truncate large log files (be careful):

sudo truncate -s 0 /var/log/large-logfile.log

Fix log rotation:

sudo logrotate -f /etc/logrotate.conf

Limit systemd journal size:

sudo journalctl --vacuum-size=100M
sudo nano /etc/systemd/journald.conf

Add these lines:

SystemMaxUse=200M
MaxRetentionSec=1month

Restart logging service:

sudo systemctl restart systemd-journald

Problem 5: Snap Packages Using Excessive Space

Snap packages consume more space than expected due to version retention.

Causes

  • Multiple versions of each snap package are kept automatically
  • Snap packages are larger than traditional packages
  • Disabled snap versions accumulate over time

Solution Steps

Check snap space usage:

sudo du -sh /var/lib/snapd/
snap list --all | grep disabled | wc -l

Remove specific old snap versions:

snap list --all | grep disabled
sudo snap remove snap-name --revision=revision-number

Set snap retention to minimum:

sudo snap set system refresh.retain=2

Remove all disabled snaps at once:

snap list --all | grep disabled | while read name version rev tracking publisher notes; do
sudo snap remove "$name" --revision="$rev"; done

Problem 6: Full Root Partition Prevents Login

System becomes unresponsive or prevents login due to completely full root partition.

Causes

  • Root partition (/) is 100% full
  • System cannot create temporary files needed for login
  • Desktop environment cannot start due to lack of space

Solution Steps

Boot from recovery mode or live USB if you cannot log in normally.

Emergency cleanup from recovery mode:

sudo mount -o remount,rw /
sudo rm -rf /tmp/*
sudo rm -rf /var/tmp/*
sudo apt clean
sudo find /var/log -name "*.log" -size +50M -delete

If you can access terminal (Ctrl+Alt+F1):

sudo service gdm stop
sudo rm -rf ~/.cache/*
sudo apt clean
sudo service gdm start

Create emergency space by removing largest files:

sudo find / -type f -size +100M -exec ls -lh {} \; 2>/dev/null | head -5
sudo rm /path/to/large/file

Diagnostic Commands for Troubleshooting

Use these commands to investigate disk space problems before applying solutions.

General Disk Analysis

Check overall disk usage:

df -h

Check inode usage:

df -i

Find directories using most space:

sudo du -h --max-depth=1 / | sort -hr | head -20

Specific Problem Investigation

Check for files deleted but still open:

sudo lsof +L1

Find recently modified large files:

sudo find / -type f -size +100M -mtime -1 2>/dev/null

Check mount points and filesystems:

findmnt
lsblk

Investigate specific directory growth:

watch "du -sh /var/log"

Press Ctrl+C to stop watching.

Prevention Strategies

Prevent common disk space problems with regular maintenance and monitoring.

Regular Maintenance Tasks

    • Weekly APT cleanup:
sudo apt clean && sudo apt autoremove
    • Monthly log rotation check:
sudo logrotate -f /etc/logrotate.conf
    • Monitor disk usage trends:
df -h / | tail -1 | awk '{print $5}'

If this shows over 75%, plan cleanup activities.

Early Warning Signs

Watch for these indicators of developing disk space problems:

  • System running slower than usual
  • Applications taking longer to start
  • “Low disk space” notifications from Ubuntu
  • Package updates failing with space errors
  • Temporary file creation errors

Configuration Improvements

Set automatic APT cleanup:

sudo nano /etc/apt/apt.conf.d/99auto-cleanup

Add:

APT::Periodic::AutocleanInterval "7";
APT::Periodic::MaxSize "500M";

Configure log size limits:

sudo nano /etc/systemd/journald.conf

Set:

SystemMaxUse=200M
MaxRetentionSec=1month

Recovery from Severe Issues

When disk space problems cause system instability or corruption.

File System Check

Check filesystem for errors (do this from live USB if system won’t boot):

sudo fsck -y /dev/sdaX

Replace X with your actual partition number.

System Recovery Steps

Boot from live USB if necessary.

Mount your system partition:

sudo mkdir /mnt/system
sudo mount /dev/sdaX /mnt/system

Emergency cleanup from live environment:

sudo rm -rf /mnt/system/tmp/*
sudo rm -rf /mnt/system/var/tmp/*
sudo find /mnt/system/var/log -name "*.log" -size +50M -delete

Check system integrity after recovery:

sudo chroot /mnt/system
apt update
dpkg --configure -a

When to Seek Additional Help

Some disk space problems require professional assistance or indicate hardware issues.

Signs of Hardware Problems

  • Disk space appearing and disappearing randomly
  • File system errors that return after repair
  • System becoming unresponsive during disk operations
  • Strange noises from hard drive

Advanced Issues Requiring Expert Help

  • Partition table corruption
  • File system damage beyond simple repair
  • RAID array problems
  • Complex server environment issues

Backup Considerations

Before attempting major fixes:

  • Back up important personal files to external storage
  • Document current system configuration
  • Consider creating a system backup if space permits

Conclusion

Troubleshooting disk space issues in Ubuntu requires systematic diagnosis to identify the root cause before applying solutions. You learned to handle common problems like inode exhaustion, APT failures, hidden files, log growth, snap storage, and system recovery situations.

The key to successful troubleshooting is understanding that different symptoms often have different underlying causes. Start with safe diagnostic commands, identify the specific problem type, then apply targeted solutions rather than generic cleanup procedures.

Regular monitoring and preventive maintenance help avoid many disk space problems before they become critical. Implement automatic cleanup and monitoring to maintain system health and catch issues early before they impact system functionality.

Related guides

Account services are unavailable until the production backend is configured.