# Proper way to compile custom kernel



## Remington (Nov 6, 2012)

What is the best way to compile the customized kernel after doing freebsd-update?

My method is:

```
# freebsd-update fetch
# freebsd-update install
# reboot
# freebsd-update install
# /usr/sbin/config -g CUSTOM
# cd /usr/src
# make buildkernel KERNCONF=CUSTOM
# make installkernel KERNCONF=CUSTOM
# reboot
```


----------



## UNIXgod (Nov 6, 2012)

I've always used the method defined in the handbook:

kernel:
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-building.html

world:
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html

I noticed no mergemaster in your steps. You may run into some issues.


----------



## TheDreamer (Nov 30, 2012)

I thought *mergemaster* was only for remaking the world, and not needed when just making a custom kernel.


----------



## chatwizrd (Nov 30, 2012)

You should get used to using shutdown -r now instead of reboot its a lot safer. The mergemaster just looks for changes in your config files. It usually isn't needed unless jumping major versions. Your commands look right, yet I have never used the /usr/sbin/config command before, I will have to look into that one.


----------



## UNIXgod (Nov 30, 2012)

TheDreamer said:
			
		

> I thought *mergemaster* was only for remaking the world, and not needed when just making a custom kernel.



It's part of the post upgrade activities which the op was asking about. I highly doubt freebsd-update automates that nor would I expect it to do it well.


----------



## kpa (Dec 1, 2012)

chatwizrd said:
			
		

> You should get used to using shutdown -r now instead of reboot its a lot safer. The mergemaster just looks for changes in your config files. It usually isn't needed unless jumping major versions. Your commands look right, yet I have never used the /usr/sbin/config command before, I will have to look into that one.




mergemaster(8) is absolutely needed if you're following a -STABLE branch, don't skip it if you are following one.


----------



## gkontos (Dec 1, 2012)

@Remington,

You might want to have a look here for a custom kernel modification technique.

You should not run mergemaster() if you are using freebsd-update().

Like mentioned earlier, reboot() is not always the proper choice.


----------



## fmw (Dec 4, 2012)

gkontos said:
			
		

> @Remington,
> 
> Like mentioned earlier, reboot() is not always the proper choice.



What is the difference, aside from users being warned of the upcoming system halt/restart?


----------



## gkontos (Dec 4, 2012)

fmw said:
			
		

> What is the difference, aside from users being warned of the upcoming system halt/restart?



reboot(8)() will not call all shutdown command sequences while shutdown(8)() will. Therefore, it is better to use shutdown in multi user mode and reboot in single user mode.


----------



## bbzz (Dec 4, 2012)

Something like
`# make installkernel KERNCONF=CUSTOM KODIR=/boot/custom`
`# nextboot -k custom`

can be useful, just in case.


----------

