Gentoo Wiki


This article is part of the Tips & Tricks series.
Terminals / Shells Network X Window System Portage System Filesystems Kernel Other

Please improve it in any way that you see fit, and remove this notice {{Cleanup}} from the article. For tips on cleaning and formatting see Cleanup process



In Linux and Gentoo both there are ways to reduce disk space that doesn't break the system and can help low end or full systems get some needed space - things like:

There are also some additional tips in other places on this wiki on how to do such things. As you come across them, please copy the snippets over here! :-D


As always, if one is unsure of what they are doing, then cry about it later - doesn't work. I mean, it's just a computer, not the end of the world if you have to recompile a few things, right?

I'd suggest reading through this guide once, digesting the information, then head over to the system, guide in hand (or on screen), and get the work done. Blindly removing packages from the system could have a disastrous effect on your computer's health.


Ensure you have gentoolkit installed: emerge -av gentoolkit This includes two useful programs - euse and equery - which have excellent documentation in their man pages: man euse

TIP: Optionally emerge -av eix It builds an index so that searches through portage are considerably quicker.

You should ensure your system is synced and up to date before doing any maintenance:

emerge --sync or eix-sync if you use eix.

Do any outstanding builds:

emerge -aNDu world

Fix any binaries that may be pointing to shared libraries that don't exist anymore:

revdep-rebuild -av

Compile options in /etc/make.conf


A note on CFLAGS:

For the average desktop user it really makes no sense to CFLAGS="-O9 -march=8088 --fomg-optimize" your system. In fact, may make it slower. Using CFLAGS="-Os" or CFLAGS="-O2" is much more effective on a desktop system and can shave off more than 30% of the size. This is because larger binaries (like the HUGE ones produced by -O3) take longer to load, and occupy more RAM.

To harness this newfound speed and size reduction you'd need to emerge --emptytree --newuse world --pretend --verbose. Note that --empty-tree causes portage to have temporary memory loss - remembering all of the packages you want installed, but not rememebering that any of them are installed. Also note that it could literally take 2 or 3 days and make your system quite a bit bigger before it makes it smaller.

USE flags

Just as good - and perhaps better - than the tip above is customizing your USE flags. Take time to look through your USE flags and see if there's stuff that you realize that you don't really need. /etc/make.conf shows what you have explicitly configured.

Use the euse command to find more information. Run euse -i which will list every known flag along with its description. Look for the first character inside the square brackets. If you have a + (plus) then it is on and if you have a - (minus) then it is off.

You can also lookup individual flags. For example, if you have arts enabled and you don't know what it is

 $  euse -i arts 
 [-    ] arts - Adds support for aRts: the KDE sound daemon

If you're using GNOME exclusively, then you don't need things like arts kde qt, so remove them from your USE flags or add them preceded by a minus signs -arts. This will remove extra bulk from applications that have support for both KDE and GNOME so that only the one is supported.

You can change the useflags the hard way by editting /etc/make.conf or the easy way by using euse. For example to disable arts kde qt run euse -D arts kde qt. To enable mp3 run euse -E mp3.

Once you've done that and you are fairly confident about your settings, procede to recompile.

To take advantage of your new USE flags you'd need to emerge --newuse world --pretend --verbose. Note that --newuse causes portage re-emerge any package that were previously compiled with a different set of USE flags than your current ones. Also note that it could take several hours and download several new packages.

TIP: The program ufed is also favoured by some for editing use flags. However it is far more particular about the formatting of /etc/make.conf.

Don't Compile

Compiling generates a lot of garbage in a lot of places. If you're using Gentoo because of portage but would rather not compile, don't feel ashamed, use PORTAGE_BINHOST. Check out the TIP Using PORTAGE BINHOST.

Removing Temporary Files

Empty the following directories:

/tmp: Some running programs may get confused if you do this, for example the X window system.

/var/tmp: Especially /var/tmp/portage/*, the temporary directories in which packages are compiled from source during an emerge. Whenever an emerge fails or is interrupted, it often leaves huge directories here.

~/.Trash or ~/.local/share/Trash/files/: If you use Xfce or any other compliant program, trashed files go to the latter instead of the former.

/usr/portage/distfiles/*: The cache of source code tarballs that have been downloaded over the Internet.

Removing ancient distfiles and binaries

After using Gentoo for a long time, you accumulate a lot of obsolete binaries and/or distfiles. Some of these are obvious candidates for removal (Xorg, OpenOffice) simply because they are large. But many may not be. Gentoolkit has a recent tool, eclean, that can remove all of these for you. Simply run eclean-dist or eclean-pkg. Note that eclean-dist has a "destructive" option, which clears out all unused distfiles. This can save far more space, but is slightly more dangerous in that you might have to download files again if there is a downgrade of a package (either by your choice or by developers).

Removing packages

This is the simplest way to remove things from your system and slim down your install. Here, you just remove packages that you don't use anymore. This frees up space, and in the case of libraries, reduces future bloat by making sure nothing links against them.

One way to obtain a list of everything installed is to look at the output of "emerge -ep", which can be very unorganized and massive and may not work anymore. So we're not going to do that. Instead, we're going to browse through portage's list of installed packages in order to maintain our sanity. Navigate to the directory /var/db/pkg. This directory contains an organized list of everything installed in the [package category]/[package-name]-[package-version] format.

Simply look through the package category names and see if there is a program you use or not. The more you know about your system, the easier this is, because you know what you need, and what you don't. Make sure that you know what you are removing. Be careful when removing libraries, as you can damage your system in doing so (libraries typically have "lib" in the package name or package category).

TIP: You can use the q command to find out more about packages. For example you can find out which packages own a file or directory using qfile file_or_directory. Use emerge -pv portage-utils for these utilities.

 $  qfile /usr/share/devhelp
 dev-cpp/gtkmm (/usr/share/devhelp)
 dev-cpp/libglademm (/usr/share/devhelp)

You can also easily find out how big installed packages are using qsize package_name:

 $  qsize gtkmm
 dev-cpp/gtkmm-2.12.0: 486 files, 29 non-files, 6912.227 KB

You can then find out which packages depend on this one using equery depends package_name

 $  equery depends gtkmm
 [ Searching for packages depending on gtkmm... ]
 media-gfx/inkscape-0.45.1 (>=dev-cpp/gtkmm-2.4)

You can find out about the package slowly using emerge --search package or quickly using eix package

 $  eix gtkmm
 * dev-cpp/gtkmm
    Available versions:  ..............
    Installed:           2.8.3
    Description:         C++ interface for GTK+2

TIP: If you wish to see the list of installed packages sorted in ascending order by the amount of space they take:

 $  qsize -a -k | sort -n -k 6


I look at my x11-wm folder, and I see that I've managed to install metacity, fvwm, blackbox, openbox, and ratpoison (I like to try stuff out). I know metacity is part of gnome, which I use, and I like fvwm, which I also use, but I decide the others can go. So as root, I simply emerge -C x11-wm/blackbox x11-wm/openbox x11-wm/ratpoison

Removing old versions of software

Carefully examine the output of emerge --prune --pretend and then selectively remove packages.

Removing dependencies of software no longer installed

It is important to note that I cannot advise doing this on a critical production machine. If you've read the whole article, or done it before, you'll know why. The first step is to emerge --depclean -p. This will create a list of programs that are possibly no longer needed.

Now the tricky part is this: sometimes packages wont be kind enough to ask us if we want features, and will auto-detect them at compile time. So even if we've said we don't want something...say oss... to be enabled, some programs (like wine) will decide to build support for it anyway when you merge them if you just happen to have the oss libraries installed. This creates problems because there is no way that portage can know about this.

Non Critical Packages

Removing "cruft"

Read more about removing cruft here.

Fixing what you just broke

Run revdep-rebuild --pretend to list any packages which need re-emerging. You'll need to emerge --ask gentoolkit if you haven't already. If revdep-rebuild insists on continually re-emerging any binary packes you have installed, try $EDITOR `which revdep-rebuild`, and remove all the "/opt"s from the SEARCH_DIRS line.

For good measure, run emerge --update --deep --newuse world --pretend to give you a list of any software that was removed that you still need.


Purging unused locales

Another way to reduce disk space usage is to remove unused locales. See the Official localization guide section on "Generating locales".

Remove foreign language man pages

With appropriate privileges, it is possible to remove the foreign man pages as follows:

rm -rf /usr/share/man/??
rm -rf /usr/share/man/??_*

Removing unused documentation files

Another good thing is to remove unwanted documentation (AUTHORS.txt, CHANGELOG.txt) which is located in /usr/share/doc as it takes up a fairly huge amount of disk space.

rm -rf /usr/share/doc

If you only want to remove certain files that are probably not needed by you like the changelogs or author files:

find /usr/share/doc \( -iname "authors*" -or -iname "changelog*" \) -delete

And for the future: If you are sure you won't need doc anymore (e.g. because you have this great gentoo-wiki ;D ) you can add "nodoc" option to FEATURES in make.conf. This will prevent installing any doc in your system.

Removing foreign language scrollkeeper files

With appropriate privileges, it is possible to remove the foreign language scrollkeeper files as follows:

rm -rf /var/lib/scrollkeeper/[a-b]?
rm -rf /var/lib/scrollkeeper/ca
rm -rf /var/lib/scrollkeeper/cs
rm -rf /var/lib/scrollkeeper/cy
rm -rf /var/lib/scrollkeeper/[d-t]?
rm -rf /var/lib/scrollkeeper/[v-z]*
rm -rf /var/lib/scrollkeeper/pt_*
rm -rf /var/lib/scrollkeeper/sr*

Remove unneeded Kernel sources

Take a look at /usr/src, there are hundreds of MBs taken up by each unneeded Kernel source tree:

 du -sh /usr/src/*

You only need to keep a source tree around if you think you might need to recompile it. For an old reliable kernel that you've used for months and years and are keeping around as a fallback, you don't need the sources, and if by some chance you do need to recompile it, you can re-emerge them.

Note: A few number of programs use the kernel source to help with emerges (e.g. hal, iptables)

Additional note: If you decide to delete /usr/src, you should save /usr/src/linux/.config somewhere because if you ever do re-emerge the kernel sources, you can run 'make oldconfig' to bring the kernel configuration back too.

If you delete the unneeded directories first, the unmerge process goes much faster:

 rm -r /usr/src/2.6.x-gentoo-ry

But you should delete the directories anyway, also after unmerging the Kernel sources, because there are still compiled and other modified files not covered by Portage.

Then if it's a really old kernel delete its files in /boot and in /lib/modules, and don't forget to remove its entries from your bootloader's config file.

Resources not yet absorbed

how to control portage space usage

See also

External links

Retrieved from ""

Last modified: Mon, 01 Sep 2008 04:56:00 +0000 Hits: 49,153