Colin Robinson

How to free up space in rootfs on Arch Linux

Is your rootfs partition at 100% and causing you problems?

I’ve been hovering around 95%-100% for a few weeks now. Being at 95% is fine, but 100% can cause all kinds of problems. I was testing a form on my local web server and couldn’t do file uploads because “the disk was full.” I was writing code and my editor couldn’t save the file because “the disk was full.” Its frustrating because you have hundreds of free gigs where you’re saving the file, but because rootfs is full, you can’t!

I’ll start by showing you the output of df

$ df
Filesystem     1K-blocks     Used Available Use% Mounted on
rootfs          10209220  9625988     71164 100% /
/dev             4055116        0   4055116   0% /dev
run              4058036      252   4057784   1% /run
/dev/sda3       10209220  9625988     71164 100% /
shm              4058036      796   4057240   1% /dev/shm
tmpfs            4058036     3160   4054876   1% /tmp
/dev/sda1          99590    34166     60205  37% /boot
/dev/sda4      449789792 23726068 403549860   6% /home

Not good, but its my own fault. I only allocated about 10g to /dev/sda3 when I setup the OS. I should I have predicted that I would need more.

The real solutions is to boot to a livecd and resize /dev/sda3. This can take a long time, break your grub install, and cause other headache inducing effects.

Here are some tricks I’ve picked up to get your rootfs down from the dreaded 100% to something you can actually work with.

Clear your pacman cache

When pacman downloads a package for you, it keeps a version in its cache (usually /var/cache/pacman/pkg). This is great if you ever want to downgrade a package, but its not necessary and it takes up space.

Clearing your cache is as easy as:

$ pacman -Sc

There are more complicated scripts on the net which do things like manage how mange revisions back to save packages for, but this is fine for now. Lets take a look at the difference that made

$ sudo df
Filesystem     1K-blocks     Used Available Use% Mounted on
rootfs          10209220  9303916    393236  96% /

Down to 96% already! This is all the difference in the world, now I can actually save this document I’m writing. Lets see how much further we can get this down.

Remove software you don’t use

Now might be a good time to remove unused software. I normally run a pretty tight system anyways, but I still found room to improve.

For example, I use Xfce as my Desktop Environment but I use Compiz as my Window Manager rather than xfwm4. This let me remove xfwm4 and xfwm4-themes and shed a few MBs. I originally installed both VirtualBox and VMware but I only use the latter. See you later Vbox!

Kill the orphans!

Or rather… remove orphaned packages. First do a pacman query -Q for all dependencies -d that are unrequired -t.

$ pacman -Qdt

If you have unrequired dependencies, why not remove them. This simple command with recursively remove all unrequired dependencies.

pacman -Rs $(pacman -Qtdq)

Where are we at?

$ df
Filesystem     1K-blocks     Used Available Use% Mounted on
rootfs          10209220  9090832    606320  94% /


Similar to CCleaner on Windows, BleachBit clears out temp files, system caches, and other junk. You can find it here in the AUR (There is also a CLI version).

Figure out what’s taking up space

Still not satisfied with the size of rootfs? Get down into the file structure and find out what’s taking up space. The arch wiki has a list of disk usage display programs. I’m personally a fan of ncdu (home page) (package details).

Have a suggestion of your own? Still having problems with your file system? Make a comment!

4 Responses to “How to free up space in rootfs on Arch Linux”

  • Jacques says:

    You could also move everything from /var to /home and symlink back to /var.

  • Ravi says:

    Good article! Gives an hint how we can free up file system space on *nix systems.

  • Daryl Haataja says:

    Late reply, I keep my pacman/pkg cache on a separate partition linked via:
    $ ln -s /path-to-other-partition/pacman/pkg/ /var/cache/pacman/pkg
    In my case /path-to-other-partition is mounted on boot in my user-home partition, i.e.
    $ ln -s ../../../home/username/mounted-other-partition/pac[…] /usr/cache/pacman/pkg
    This makes the symlink invalid if manipulated from a different linux. Else I might
    accidentally move, remove or change it from there. If that makes any sense.

  • Patrick says:

    Even later reply here. What about replacing systemd with busybox, xorg with fbdev or kdrive, remove build-essential if you don’t compile anything from the AUR and compress /var and /usr with squashfs and aufs or unionfs or just use a compressed filesystem such as btrfs? Arch’s base install sure has become pretty huge these days.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.