buildworld and next kernel compilation

Michael Powell nightrecon at hotmail.com
Sat Aug 16 07:49:14 UTC 2014


Mohsen Pahlevanzadeh wrote:

> Dear BSD man,
> 
> Suppose i compile my kernel via:
> 
> ///////////////////////////////////////////////////////
> svn co svn://svn.freebsd.org/base/stable/10 /usr/src
> svn up /usr/src
> cd /usr/src
> make buildworld
> ### edit my MYKERNELCONF
> make kernel KERNELCONF=MYKERNELCONF
> shutdown -r now
> ### boot via single user and use the following commands:
> mount -u /
> mount -a -t ufs #my fs is ufs
> swapon -a
> adjkerntz -i
> mergemaster -p
> cd /usr/src
> make installworld
> mergemaster -iF
> make delete-old
> reboot
> make delete-old-libs
> ///////////////////////////////////
> 
> My question: suppose i need to again compile my kernel and add fooobar,
> What do you suggesst procedure for compilation according to i compile
> once?
> 
> 
First, I cd to /usr/obj and rm -rf usr and rm -rf lib32 so there is no cruft 
left over from any previous build.  In other words, blow away everything 
under /usr/obj. I believe there is a target for doing this but haven't tried 
that approach in a very long time. I think it's something like doing a make 
clean in /usr/src which accomplishes the same thing. IIRC doing make kernel 
combines both make buildkernel and make installkernel  into one operation; I 
just prefer to do one at a time as a purely personal quirk. 

The choice depends on whether any source code has changed, e.g. if you have 
done another svn up /usr/src then you will want to do the whole make 
buildworld/installword thing again or your kernel and userland will become 
out of sync with each other. If there has been no update, the source tree is 
the same as before with no change (other than an edit to a kernelconf file) 
then you can simply just do a make buildkernel, make installkernel, and 
reboot (or combine with make kernel). What you don't want to have happen is 
a kernel that has been built from sources that differ from what world was 
built from. As long as the source is the same you can just build new 
kernel(s) and install without having to do anything else.

Couple of hints here too: each time you build a new kernel the current 
running kernel will be moved to kernel.old. This allows for to boot to 
kernel.old should you somehow install a defective kernel. Note that if you 
were to somehow get into the situation where you somehow built two kernels 
in a row that were bad you will have lost the first kernel.old that was a 
working kernel. It's kind of an odd situation to get into and isn't really 
very likely, but the possibility is there.

The make delete-old-libs (last line above) is something you need to be 
careful with. It isn't really needed in a minor revision update such as 
upgrading from 9.2 to 9.3 because the ABI has not changed and all your 
installed ports are still linked against the same library versions. However, 
this situation is different when a major update takes place, e.g. an upgrade 
from 9.x to 10.x will require you to rebuild all the ports so they link 
against the new library version bumps. Do NOT run the make delete-old-libs 
until AFTER successfully rebuilding all installed applications.

-Mike





More information about the freebsd-questions mailing list