Build Kernel Outside of /usr/src

Hi all,

I'm reading through a howto on getting an IPSEC VPN server running on FreeBSD. All looks straightforward, but I've got a question regarding compiling the kernel (required so that IPSEC can be added to it).

My FreeBSD root filesystem's running off a fast USB flash drive in my HP MicroServer. Now, there's unlikely to be enough room (or performance) for a kernel compile to be sensible from under /usr/src/.

I've got a ZFS pool with plenty of space mounted at /store/ .... could I copy /usr/src/ to /store/src and just build from there? Or will that blow up?

Could I do something cool with mount_null so that the actual source could be at /store/src with that directory mounted at /usr/src?

Reading through mount_null(8) it looks like this should be completely transparent to the build process.

Anyone given that a try?

Cheers,
Chris
 
If you have ZFS why not create a filesystem and simply zfs set mountpoint=/usr/src/ .....?
 
The kernel (and world, which is required to build the kernel) will be built using the value of MAKEOBJDIRPREFIX, which defaults to /usr/obj, for temporary file storage. To build 9.x for amd64 you need roughly 3GB of temporary space.

The straightforward approach therefore is to specify MAKEOBJDIRPREFIX, i.e. calling
# make MAKEOBJDIRPREFIX=/lots/of/space/here buildworld buildkernel
# make MAKEOBJDIRPREFIX=/lots/of/space/here installkernel
# mergemaster -p
...

However, since that requires you to specify that variable at any time you call make(1) for the system (make.conf won't work here), you can also mount your temporary space via nullfs to /usr/obj, or symlink /usr/obj to the temporary space instead.

The path to the sources (~850MB for 9.x, less if there is no subversion metadata) is irrelevant to the build process. While /usr/src is the default and exemplary used in the handbook, you can have them in your home directory if you want, and also use your user to build it (will need super user to install it later though, unless you overload DESTDIR to install it somewhere your user can write, e.g. a chroot environment)
 
Ah, superb. Thank you all for the help.

Despite having created a couple of ZFS datasets, I completely forgot that I could specify the mount-point!

So I'll do what @kpa/@SirDice suggested. And @xibo, thanks for the technical explanation.

Off to build me an ipsec-flavoured GENERIC :)

Cheers,
Chris
 
displaced said:
Off to build me an ipsec-flavoured GENERIC :)
Do not name a custom kernel GENERIC. It's going to cause a lot of confusion if you're asking for help because we all expect GENERIC to have a certain configuration.

Copy the GENERIC file and change the ident line.
 
Hi SirDice,

I was being a bit imprecise there - I built an ipsec-flavoured GENERIC called GENERIC_ipsec :)

Anyway, the compile went fine (and much quicker than I'd expected) -- the machine's now running great as a VPN server.

Thanks all,

Chris
 
Back
Top