February 17, 2012

Compiling a Free Bsd Kernel

Ever since my college days, I always loved to have my own
compiled
kernel. It gave me that extra feeling of "my motor is better
than
yours". I am sure each time my new kernel boots up the feeling I
have
is is the same as what Super Man has when he bashs up the bad
people.

A convention kernel boots up the system faster, it takes up lesser
memory space and one can setup drivers for hardware not
supported by a default kernel. Also these benefits, a convention
kernel
serves as an arresting conversation topic with geeks. Just ask
them
"What is your kernel size ?". This would keep the Geek busy for
sometime where he would elaborate all the great things he did to
the
kernel options to optimize his box.

If you happen to be a geek yourself, this is a great ask to
put send to those lowly Nubies. They'll never issue you
with stories of their nephew or kid sister after this :-D






Before we get down to compiling our own kernel, it is a
wonderful idea
to backup the gift kernel.

# cd /boot

# cp -pvr kernel kernel.orig

The former generic kernel is now stored as kernel.orig. In
case the
kernel does not boot (which has happened with me many times)
boot up
with the generic kernel and try again. Booting any other kernel
is
simple. At the boot time goto to the boot prompt and simple say
"boot
kernel.orig" and the default kernel would boot up.

The kernel sources are placed in the /usr/src/sys directory. If
not
installed, the kernel sources can be installed with the
following
commands. First insert the FreeBsd setup Cd in your Cd drive.

# mount /cdrom
# mkdir -p /usr/src/sys
# ln -s /usr/src/sys /sys
# cat /cdrom/src/ssys.[a-d]* | tar -xzvf
-


Then go to the director where the configuration files are
located.

#cd /sys/i386/conf

In this directory the Generic kernel configuration file is
located.
Copy this file and it as your convention name.

#cp -pvr Generic Babybsd

# vi Babybsd

First change the ident value from Generic to Babybsd (or
whatever name
you prefer). I have given my sample configuration file at the
end of
this article. The options are quite easy to understand and a
good
starting point would be the FreeBsd
Handbook
which has documented most of the kernel options.

You can also go to a shell and run the command #make Lint
in
this directory which would create a file called Lint which has
all the
options supported by the kernel listed.

After this stage just run the following commands

#/usr/sbin/config Babybsd

#cd ../compile/Babybsd

#make depend

#make

#make install

Please note that you must be root to run the make install.
Reboot and
the kernel should boot with your shining new kernel. :-)

# My Sample Kernel Configuration File for FreeBsd/i386

machine i386

cpu

I586_Cpu

cpu

I686_Cpu

ident

Babybsd

options Sched_4Bsd

# 4Bsd scheduler

options Inet

# InterNetworking

options Inet6

# Ipv6 communications protocols

options Ffs

# Berkeley Fast Filesystem

options Softupdates

# Enable Ffs soft updates support

options Ufs_Acl

# preserve for way control lists

options Ufs_Dirhash

# improve doing on big directories

options Md_Root

# Md is a inherent root device

options Nfsclient

# Network Filesystem Client

options Nfsserver

# Network Filesystem Server

options Nfs_Root

# Nfs usable as /, requires Nfsclient

options Msdosfs

# Msdos Filesystem

options Ntfs

options Cd9660

# Iso 9660 Filesystem

options Procfs

# Process filesystem (requires Pseudofs)

options Pseudofs

# Pseudo-filesystem framework

options Geom_Gpt

# Guid Partition Tables.

options Compat_43

# Compatible with Bsd 4.3 [Keep This!]

options Compat_Freebsd4

# Compatible with FreeBsd4

options Scsi_Delay=15000 #
Delay
(in ms) before probing Scsi

options Ktrace

# ktrace(1) support

options Sysvshm

# Sysv-style shared memory

options Sysvmsg

# Sysv-style message queues

options Sysvsem

# Sysv-style semaphores

options _Kposix_Priority_Scheduling # Posix
P1003_1B
real-time extensions

options Kbd_Install_Cdev #
install
a Cdev entry in /dev

options
Ahc_Reg_Pretty_Print #
Print register bitfields in debug

# output. Adds ~128k
to
driver.

options
Ahd_Reg_Pretty_Print #
Print register bitfields in debug

# output. Adds ~215k
to
driver.

options Adaptive_Giant

# Giant mutex is adaptive.

device
apic

# I/O Apic

# Bus support. Do not take off isa, even if you have no isa
slots

device isa

device eisa

device pci

# Floppy drives

device fdc

# Ata and Atapi devices

device ata

device
atadisk

# Ata disk drives

device
atapicd

# Atapi Cdrom drives

options Ata_Static_Id #
Static
device numbering

# Scsi peripherals

device
scbus

# Scsi bus (required for Scsi)

device ch

# Scsi media changers

device da

# Direct way (disks)

device cd

# Cd

device
pass

# Passthrough gismo (direct Scsi access)

device
ses

# Scsi Environmental Services (and
Saf-Te)

# atkbdc0 controls both the keyboard and the Ps/2 mouse

device
atkbdc

# At keyboard controller

device
atkbd

# At keyboard

device
psm

# Ps/2 mouse

device
vga

# Vga video card driver

device
splash

# Splash screen and screen saver support

# syscons is the default console driver, resembling an Sco
console

device sc

# Enable this for the pcvt (Vt220 compatible) console driver

#device vt

#options Xserver

# preserve for X server on a vt console

#options Fat_Cursor # start
with
block cursor

device
agp

# preserve any Agp chipsets

# Floating point preserve - do not disable.

device npx

# Power administration preserve (see Notes for more options)

#device apm

# Add suspend/resume preserve for the i8254.

device pmtimer

# Pci Ethernet Nics that use the coarse Mii bus controller
code.

# Note: Be sure to keep the 'device miibus' line in order to use
these
Nics!

device
miibus

# Mii bus support

device rl

# RealTek 8129/8139

# Wireless Nic cards

device
wlan

# 802.11 support

# Pseudo devices.

device
loop

# Network loopback

device
mem

# Memory and kernel memory devices

device io

# I/O device

device
random

# Entropy device

device
ether

# Ethernet support

device sl

# Kernel Slip

device
ppp

# Kernel Ppp

device
tun

# Packet tunnel.

device
pty

# Pseudo-ttys (telnet etc)

device md

# Memory "disks"

device
gif

# Ipv6 and Ipv4 tunneling

device
faith

# Ipv6-to-Ipv4 relaying (translation)

# The `bpf' gismo enables the Berkeley Packet Filter.

# Be aware of the menagerial consequences of enabling
this!

# Note that 'bpf' is required for Dhcp.

device
bpf

# Berkeley packet filter

# Usb support

device
uhci

# Uhci Pci->Usb interface

device
ohci

# Ohci Pci->Usb interface

device
ehci

# Ehci Pci->Usb interface (Usb 2.0)

device
usb

# Usb Bus (required)

#device
udbp

# Usb duplicate Bulk Pipe devices

device
ugen

# Generic

device
uhid

# "Human Interface Devices"

device
ukbd

# Keyboard

device
umass

# Disks/Mass storehouse - Requires scbus and
da

device
ums

# Mouse

# specific to my Machine

device
atapicam
# for Cd Writer to be detected by K3B and other Cd writing
software

device
sound

# To Enable Sound

device
"snd_ad1816"

device
"snd_als4000"

device
snd_cmi

device
"snd_cs4281"

device
snd_csa

device
"snd_ds1"

device
"snd_emu10k1"

device
"snd_es137x"

device
snd_ess

device
"snd_fm801"

device
snd_gusc

device
snd_ich

device
snd_maestro

device
"snd_maestro3"

device
snd_mss

device
snd_neomagic

device
"snd_sb16"

device
snd_sbc

device
snd_solo

device
"snd_t4dwave"

device
"snd_via8233"

device
"snd_via82c686"

device
snd_vibes

device
snd_uaudio

device pcii

device
acpi

device
acpi_asus

device
acpi_video

device
cbb
# cardbus (yenta) bridge

device
pccard #
Pc Card
(16-bit) bus

device
cardbus #
CardBus
(32-bit) bus

options Device_Polling

options Hz=1000

options Perfmon

device
apm_saver # Requires Apm

options
Auto_Eoi_1

options Auto_Eoi_2

options Vesa

Compiling a Free Bsd Kernel

ECO Friendly Toys