Cleanly removing /usr/src

For some reason that I can't remember, I have /usr/src fully populated on my FreeBSD 11.3 machine at home. Never noticed it, until I ran the upgrade from 11.2 to 11.3 a few days ago. That's 140,000 files that I don't need, and which clog backup and waste time during upgrades. What's the clean way to remove them? Can I just do "rm -Rf /usr/src/* /usr/obj/*"? Without causing problems for future upgrades?
 
Yes!

In addition, in /etc/freebsd-update.conf you might want to remove src from the components of the base system which should be kept updated. (± line 15).
 
I don't know if this is still the case, but in the past the nvidia driver needed /usr/src to build. This is of course only applicable if you ever build it from the port.
 
Thank you, done. Worked well. The upgrade on the 2nd machine ran 3x faster, when it didn't have to upgrade the source.

And no need to worry about the Nvidia driver; I only do servers (no graphics), and I hardly ever build anything from ports.
 
I don't know if this is still the case, but in the past the nvidia driver needed /usr/src to build. This is of course only applicable if you ever build it from the port.

Not only that one, there is a couple of them. Working with /usr/ports needs /usr/src as a prereq. But nobody (afaik) needs /usr/obj; that one can be dropped immediately after OS-build&installation.
 
Ports that require access to kernel structures typically need access to the source tree. This includes for example various kernel modules and tools like the aforementioned sysutils/lsof.
 
But nobody (afaik) needs /usr/obj; that one can be dropped immediately after OS-build&installation.
Now this directory should be 'make clean' from the building directory (usually /usr/src) before deleted.

I have been down that rabbit hole before by deleting without cleaning first. You need to undo some flags.
This is usually the result of a broken build that bombs out and leaves some build files in a state of flux. make clean fixes that.
chflags -R noschg *
 
Back
Top