remove all installed packages

Garance A Drosehn drosih at rpi.edu
Wed Dec 9 04:12:54 UTC 2015


On 8 Dec 2015, at 15:03, Matthias Apitz wrote:

> Hello,
>
> Is it enough to remove all installed packages, just doing
>
> # rm -f /usr/local/*
> # rm -f /var/db/pkg/*
>
> Anything else?

I've done this from time-to-time to rebuild and modernize all of my
ports, and to also make sure that I have removed all old cruft.  The
process I do has more steps than what you are planning to do, but
that is basically what I do.

There are a few risks in doing it the way you have there.  You may end
up removing some binaries that you will wish you had if something does
go wrong.  At the very least, I recommend that you save a copy of
everything in /usr/local/etc in /usr/BAK-local/etc in case you'll need
some configuration file that you don't realize you will need.  And if
you have enough space, also save /usr/local/bin in /usr/BAK-local/bin.
After you have everything rebuilt then you won't care about the copies,
but they might come in very useful if something goes haywire.

I'd also suggest that you do the removing in one session, and then
start a brand new login session before you start to build (or otherwise
install) the first port that you want.  That way you'll know the new
session is not depending on anything which is in the older version
of /usr/local.

If you have a lot of available space which you could use to create
some new partitions, then I could tell you the longer process which
I go through.  I also get rid of everything at once (instead of
asking pkg to deinstall each package), but I do it in a way where
I don't have to commit to the newly rebuilt /usr/local until I'm
pretty sure that everything in it is working, and that I haven't
lost anything.

-- 
Garance Alistair Drosehn                =     drosih at rpi.edu
Senior Systems Programmer               or   gad at FreeBSD.org
Rensselaer Polytechnic Institute;             Troy, NY;  USA


More information about the freebsd-questions mailing list