How to Free Up Space in Linux When Root (/) Partition Is Full

One of the most common problems Linux users face, especially on systems with limited disk space, is the root partition (/) getting completely full.

When this happens, you may encounter errors such as:

No space left on device

Don’t panic! It just means your root directory (the / partition) is full, which is a common issue, especially on systems with limited disk space or servers running 24/7.

When this happens, you may experience problems such as:

  • Inability to install or upgrade packages.
  • Failure to boot the system.
  • Services not starting.
  • Logs or temporary files not being written.

In this article, we’ll walk you through practical steps to identify the issue, safely clean up space, and prevent this from happening again. These instructions are suitable for both beginners and intermediate users.

Step 1: Check Disk Usage in Linux

The first step is to confirm the issue using the df command, which will displays the space used and available on the root partition. If the usage is 100%, it’s time to take action.

df -h /

Now let’s locate which folders are consuming the most space.

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

This will display the top-level directories under / sorted by size.

/var
/usr
/home
/tmp
/opt

Once you identify the largest directory, you can inspect it further, for example, if /var is large:

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

Step 2: Clean Package Cache in Linux

When you install or update software, Linux stores downloaded package files in a local cache. Over time, this cache can grow very large, especially if your system performs frequent updates or installations.

Cleaning this cache is a safe and effective way to free up space.

sudo apt clean         # For Debian/Ubuntu
sudo dnf clean all     # For RHEL-based

These commands remove all cached package files from /var/cache/apt/archives/ (for APT) and /var/cache/dnf/ (for DNF), which can accumulate over time and consume a significant amount of space.

Step 3: Remove Old Kernels in Linux

When your system installs kernel updates, it usually keeps the older versions to allow recovery in case the new one fails. Over time, this can consume a lot of space, especially in /boot, which has limited capacity.

To free up space on your Linux system, it’s a good idea to remove older, unused kernels. However, never remove the currently running kernel, as it is required for your system to boot and operate properly.

First, check the currently running kernel version.

uname -r

Then list all installed kernels:

dpkg --list | grep linux-image    # For Debian/Ubuntu
rpm -q kernel                     # For RHEL-based

Once you’ve identified which kernel versions are no longer needed, you can remove them. For example, to remove the version 5.15.0-88-generic on Ubuntu.

sudo apt remove --purge linux-image-5.15.0-88-generic

And on RHEL-based systems:

sudo dnf remove kernel-4.18.0-305.el8.x86_64

After removal, update the bootloader.

sudo update-grub

After removing old kernels, run this to clean up leftover packages and dependencies:

sudo apt autoremove      # For Debian/Ubuntu
sudo dnf autoremove      # For RHEL-based

Step 4: Clear Log Files in Linux

Linux keeps a record of system activity and events in log files in /var/log directory and these logs help system administrators troubleshoot problems, track user activity, and understand system performance.

But over time, they can grow very large, especially if:

  • A service is crashing repeatedly
  • The system is logging debug or error messages constantly
  • You’re running out of disk space and the logs just keep piling up

If your root partition / is full, there’s a good chance logs are taking up a lot of space. Cleaning or shrinking these log files can immediately free up some breathing room and get your system back to normal.

First, run the following command to see how much space each log file or folder is using:

sudo du -sh /var/log/*

Once you know which log files are the biggest culprits, you can truncate a log file, which means clearing its contents without deleting the actual file.

sudo truncate -s 0 /var/log/syslog
sudo truncate -s 0 /var/log/kern.log
sudo truncate -s 0 /var/log/auth.log

If your system uses journalctl (common in systemd systems), clean logs using:

sudo journalctl --vacuum-time=7d

This will keep only the last 7 days of logs.

Step 5: Clean Docker (if installed) in Linux

If you’re using Docker, it might be using a large amount of space due to images, containers, and volumes.

Check Docker space usage:

docker system df

To remove unused Docker data:

docker system prune -a

Be careful: this will delete all unused images, containers, and volumes.

Step 6: Live USB Rescue Method for Full Root Partition

If the system is completely full and unresponsive, you can use a Live USB to boot into a Live Linux environment and mount your root partition.

sudo fdisk -l
sudo mount /dev/sda1 /mnt  # Replace sda1 with your actual root partition

Browse the filesystem and delete large unwanted files.

cd /mnt
sudo du -sh var/*
sudo rm -rf var/log/*

Be cautious while removing files – avoid deleting critical system files.

Preventing This Issue in the Future

Here are some best practices to avoid filling up your root partition:

  • Use Separate Partitions – Create separate partitions for /var, /home, and /tmp during installation.
  • Monitor Disk Usage – Set up simple monitoring tools like monit, cron jobs, or email alerts to notify you when disk usage is high.
  • Schedule Regular Cleanup – Create cron jobs to clean logs and cache regularly.
  • Avoid Storing Large Files in / – Store backup files, downloads, and media on mounted external drives or a separate data partition.
Summary

When your root partition fills up, it can cause serious issues, from package installation failures and service crashes to logging errors and even system boot failures. Fortunately, with the right set of commands and some careful cleanup, you can recover space and bring your system back to normal without needing a reinstall.

Have you ever run into a full root (/) partition on your Linux system? What steps did you take to fix it? Share your experience in the comments below – your tips might help others in the community!

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

2 Comments

Leave a Reply
  1. In 20+ years of using Linux, I have never ran out of space on my root partition; never even have come close. However, once or twice I ran out space on my /boot/efi.

    This article is a must-read for lazy users who avoid routine clean-ups like the plague. Users who keep thousands of emails in their inbox.

    To prevent this issue in the future, BE AWARE WHAT IS HAPPENING ON YOUR SYSTEM AT ALL TIMES. Not just when alarm bells are ringing and red lights are flashing.

    “Use Separate Partitions”
    Separate partitions will not help if you do not allocate enough space to root partition, or do not do regular clean ups.

    “Monitor Disk Usage”
    Then, do something about it. Don’t wait until your partition(s) are 99% full.

    “Schedule Regular Cleanup”
    Make it a habit. Personally, I do not use Cron. There is too much chance of an error – wrong files get deleted or not deleted. I prefer to do clean ups manually to stay in control of my system.

    “Avoid Storing Large Files in / ”
    Who the heck stores large files, or ANY files for that matter, in root???!!! Windows refugees? First of all, it is a security breach waiting to happen. Secondly, it will exhaust ALL the space, no matter how large the root partition. “/” partition is for system related packages ONLY, or it should be!

    Reply
    • @Dragonmouth,

      Thanks for sharing your experience – 20+ years with Linux is impressive!

      You’re absolutely right: staying aware of what’s happening on your system and doing regular clean-ups makes a huge difference. This article is mainly for users who might overlook those things, especially beginners or folks new to Linux.

      Totally agree that separate partitions only help if they’re set up well, and that storing files in / is a bad idea – both for space and security.

      Appreciate your tips and perspective. It’s great to have experienced voices like yours in the community!

      Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.