1 This article describes the way to build a kernel right after installation, before the very first reboot. This has been performed on the request of the project leader, Matthew Dillon.
\r
3 I used a dual PIII-450MHz machine, and I have built an SMP kernel with pf, vlan and ALTQ features compiled-in. I used the latest PREVIEW ISO to date (20061228). No additional tools are needed. I performed a fresh installation. Prerequisities: you have to know how to create a custom kernel config and build a kernel.
\r
5 ## Part 1: Mounting the necessary filesystems, copying kernel sources, chroot-ing.
\r
6 First, boot the machine with the CD and perform a regular installation, but after configuring the system, do not reboot, just leave the installer and log in as root. Then you should mount the root filesystem to the ***/mnt*** mount point:
\r
9 # mount /dev/ad0s1a /mnt
\r
10 In ***/mnt***, you will have the root of your HD installation mounted. If you have enough space, you can copy ***/usr/src-sys.tar.bz2*** to ***/mnt***, or you can mount additional 'partitions'. Try this:
\r
13 # cat /mnt/etc/fstab
\r
15 You'll get an output like this:
\r
18 # Device Mountpoint FStype Options Dump Pass#
\r
19 /dev/ad0s1a / ufs rw 1 1
\r
20 /dev/ad0s1b none swap sw 0 0
\r
21 /dev/ad0s1d /var ufs rw 2 2
\r
22 /dev/ad0s1e /tmp ufs rw 2 2
\r
23 /dev/ad0s1f /usr ufs rw 2 2
\r
24 /dev/ad0s1g /home ufs rw 2 2
\r
25 proc /proc procfs rw 0 0
\r
26 To mount the new home directory into ***/mnt/home***:
\r
29 # mount /dev/ad0s1g /mnt/home
\r
30 Then copy the kernel source tarball to the HDD:
\r
33 # cp /usr/src-sys.tar.bz2 /mnt/
\r
34 There we go. But now the root is the CD's top-level filesystem and it does confuse the kernel installation (FIXME). Luckily, we can tell the operating system to use another mountpoint (or even a folder) as root. We just tell the system to use /mnt as root.
\r
38 Now your ***/*** is the root of your new installation. Then mount all the remaining partitions:
\r
42 We are done with the first part. Let's just build the new kernel!
\r
44 ## Part 2: Unpacking the kernel source, building and installing the new kernel
\r
45 Go into ***/usr*** and unpack the kernel source tarball located in /:
\r
48 # cd /usr && tar xyfv /src-sys.tar.bz2
\r
49 Then your kernel sources will be in ***/usr/src***. Now create a custom kernel config, I named it SMP and placed it into ***/root'. After you are done with configuring, comes the trickier part. To make sure the kernel and userland are in sync from a developmental point of view, you usually have to ***make buildworld*** before trying to ***make buildkernel***, and the tools from the freshly built world (# userland) are used to build the new kernel. But now you don't have the necessary source files to do the buildworld and if you are on a slower connection, it can take ages to fetch, let alone the build time (takes 4x or 5x of the kernel build time). Luckily you can build a kernel with the toolchain of your current system - the kernel and userland from the CD are in sync, aren't they? :)
\r
52 # cd /usr/src && make nativekernel KERNCONFDIR#/root KERNCONFSMP
\r
53 <kernel build message flood>
\r
54 # make installkernel KERNCONFDIR#/root KERNCONFSMP
\r
55 Note: the ***nativekernel ***target can of course be used anytime, but the kernel and userland have to be in sync, otherwise if you make a kernel on top of an older userland, your system may become unusable.
\r
56 Done. Now get outta the chroot:
\r
60 and reboot. Make sure to remove the install CD.
\r
62 Hint: you can perform this on a faster machine and place the HDD into the original machine afterwards if you are in a hurry. Be aware of the fact that SMP kernels won't boot on UP machines, though.
\r