How to clean up the Fedora root folder
fetched at December 10, 2020

When upgrading a package or the Fedora release version, I sometimes hit the error:

Disk Requirements: At least XXX more space needed on the / filesystem.

This message tells me that the disk space is inadequate. I need to clean the Fedora root folder space before performing the upgrade.

When browsing to learn more about this issue, I can easily find many people who have the same problem, as well as many different cases where it occurs. In addition, the possible ways to fix this issue are typically spread over various forums, making it complicated to choose the right path.

In this article, I grouped together several interesting sources that describe different ways to address this issue, even when my case wasn’t the root cause. I hope my experience and understanding of this issue helps save you time in resolving it.

Search the largest folders

To start, I perform a local search to help guide my next actions. One search shows the 30 larger folders outside of "/home". It is important to exclude /home as it is usually a partition of data mounted outside of the root partition, as shown in the following command. In case there are also several data partitions that I need to exclude:

sudo du --exclude="/home" -x -h -a / | sort -r -h | head -30

(Kudos to CabSud for proposing the command in this thread.)

After that, I check the largest folders to determine their size and use. Then I can safely remove these folders or use the safe command if available. Check through the list of common stuff that requires a large space and the command used to clean them safely.

Common cleanable folders

During these searches, I found several recommended ways to resolve the inadequate disk space warning. Each is described as follows.


Docker stocks all images and containers in the root partition. For a heavy user, there is a good chance a lot of the stored images are no longer used. When I ran this command it cleaned 27GB:

docker system prune -a

The Docker command demonstrates the most efficient results.

Kernel previous version

By default, three kernel versions are kept. You can remove one to free up space and keep only two using this command:

dnf remove $(dnf repoquery --installonly --latest-limit=-2 -q)

Don’t expect the dnf command to provide too much size cleaning. It won’t free up several gigabytes, but it remains an option for cleaning out some space. For more details, take a look at this article.

Fedora version cache

When upgrading to a new version of Fedora, a cache is created. In theory, the cache is cleaned after the upgrade. If not, cleaning can be forced using the following command:

dnf system-upgrade clean

Journal log

The journal log can take up a fair amount of space. In my case, running this command cleared 1.5GB:

sudo journalctl --vacuum-size=100M

However, I noticed some people mentioning that it saved them as much as 5GB. More options are explained in this blog post.

Dnf package cache

I mention this last option because it was often the first recommendation shown in the forums I reviewed, and therefore worthy of note. In my case, this command didn’t clean anything:

dnf clean packages

Learn about more options in the command documentation.

Increase the root partition size

If you still don’t have space, you can increase the root partition size. Several people say this tutorial worked for them. I didn’t use it myself because it requires you to unmount the home folder. As a newbie in Fedora usage, I preferred to investigate again to reduce the size before attempting this manipulation, and I finally found success.

Hopefully, sharing my experience helps you find the right solution to your root partition space problems.


The post How to clean up the Fedora root folder appeared first on Red Hat Developer.

Visit Link

Follow our Twitter bot for more updates.