# Building a new kernel



## kwa71 (Jul 27, 2018)

Hello All,
I'm relatively new to FreeBSD but am a quick learner. I was wondering if I need to uninstall my drivers and KDE before hand as to not confuse things if I build a new kernel and update my ports tree. TIA --kwa71


----------



## Phishfry (Jul 27, 2018)

No need for that. Look here for the instructions. This starts you mid-chapter but contains the essentials.
https://www.freebsd.org/doc/handbook/kernelconfig-config.html

Same with the ports tree. There is a recommended file named UPDATING attached to each port which contains vital information.
There is even a web version:
http://updating.braincomb.com/


----------



## ShelLuser (Jul 27, 2018)

kwa71 said:


> I was wondering if I need to uninstall my drivers and KDE before hand as to not confuse things if I build a new kernel and update my ports tree.


Updating the ports tree is a very trivial task which doesn't affect anything other than the ports tree. It can become an issue if you're building some ports and then decide to update the tree at the same time, but otherwise you should be just fine.

Don't forget: installing a port is nothing else but building the software, packaging it and then installing that package.

Updating a kernel can be a little more tricky. In any case there's no need to uninstall drivers (I assume you installed those through the ports collection also?) but you may need to update them. And a good trick for that would be adding something like this to your /etc/make.conf:

```
PORTS_MODULES=x11/nvidia-driver
```
This tells the build process that as soon as you rebuild the kernel it needs to re-build and re-install x11/nvidia-driver as well, makes my life a lot easier because I don't have to bother with this manually anymore.

As always: with minor updates (11.1 to 11.2 for example) this wouldn't be too much of an issue, but with major upgrades (10.4 to 11.2 for example) it definitely can be.

Hope this can help!


----------



## rigoletto@ (Jul 27, 2018)

To make it clear Kernel/Base and Ports are two separated things ( except you cannot use ports without kernel/base ). Ports ( aka third party software ) should not touch/modify anything on kernel/base ( however very few exceptions do exist because they need to be installed on that way to work ), and that is why everything from ports are installed on /usr/local.

That said, you can ever reset your installation to pretty the same state of a fresh install using something like THIS, plus some mergemaster(8) to reset the configuration files you eventually modified on base.


----------



## Beastie (Jul 28, 2018)

lebarondemerde said:


> That said, you can ever reset your installation to pretty the same state of a fresh install using something like THIS


Is `pkg delete -af` not redundant?


----------



## ShelLuser (Jul 28, 2018)

Beastie said:


> Is `pkg delete -af` not redundant?


No, why would it be? Don't forget that many packages have scripts which can run during both installation and removal, depending on the circumstances it can be very useful to let those run.


----------



## rigoletto@ (Jul 28, 2018)

`pkg delete -af` will also remove pkg itself, what otherwise cannot be removed.


----------



## ralphbsz (Jul 28, 2018)

kwa71 said:


> ... if I build a new kernel ...


Are you sure you need to even build a new kernel?  These days, the stock kernels typically work well, and you might be able to save yourself a lot of work.


----------



## ksaltik (Aug 3, 2018)

ralphbsz said:


> Are you sure you need to even build a new kernel?  These days, the stock kernels typically work well, and you might be able to save yourself a lot of work.



I don't understand that kind of answers I want to build my own kernel. Trying things is good if someone try to learn something this is not answer why because I want it that way


----------

