-- Leo's gemini proxy

-- Connecting to gemini.hitchhiker-linux.org:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini;lang=en-US

Freeing space in FreeBSD

2024-01-02

For a little while now I've been noticing the disk usage steadily creeping up on my FreeBSD root partition. I've got 100G set aside for FreeBSD and 100G set aside for Void Linux, with a big shared zfs pool that each OS can use for /home. Well, my FreeBSD partition managed to reach 74G used, and I figured it was time to clear out the cobwebs.


The first thing I looked at was orphaned packages. The `pkg` package manager is great in this regard, as you can remove orphans with the simple command `pkg --autoremove`. That command removed a total of 355 stale packages from my system. Now, a pretty large number of them were orphaned by things like the qt5-qt6 migration, or the same with python10-python12. But not-insignificant portion of those orphans are build dependencies due to the fact that I install and update my packages using the ports tree. Some of those will have to be rebuilt in order to update other packages, so not all of the reclaimed space is going to stay reclaimed. It's a start, though, and the reclaimed space was close to 5G.


There's still so much more to be done though.


The big culprit - stale distfiles and package archives

When you install a port on FreeBSD, you get not only the source files in the form of an archive that lives in /usr/ports/distfiles, but you also get a package archive that gets cached for you if you are using an upgrade tool like portmaster or portupgrade. Let's delete those.


Use portmaster, not portupgrade

First off some advice. I used the portupgrade suite of ports management tools for years, but I've since discovered that portmaster is just so much better that there is no reason to continue using portupgrade. The biggest reason I switched is that portupgrade is written in Ruby and pulls in about 10 gajillion dependent packages, all of which have to be updated rather often because it's Ruby and Rubyists are, you know, Agile guys. Portmaster, in contrast, is a shell script. I'm not always a fan of shell programming beyond some simple automations, but it has the huge advantage here of not pulling in any dependencies and being very stable, IE portmaster itself doesn't get updated anywhere near as often as portupgrade and it's googleplex of dependencies. It also does everything most people are ever going to need.


In this case, the commands were just the following:

# portmaster --clean-distfiles -y
# portmaster --clean-packages -y

The `-y` flag tells portmaster that you don't want to verify every action it's going to take. You will definitely not want to verify every action if you've let things go like I have, or you'll be hitting `y-Return` all day. So how much space did this create?

morgoth% df -h /
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/ada0p3     97G     37G     53G    41%    /

That's right, we've managed to go from 74G down to 37G with three commands. Guess it's time to start automating some of this for the future so that I don't ever get so cluttered again.


Tags for this page

FreeBSD

ports

software


Home

All posts


All content for this site is licensed as CC BY-SA.

© 2024 by JeanG3nie

Finger

Contact

-- Response ended

-- Page fetched on Mon May 20 11:40:22 2024