Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Jul 2001 18:36:36 -0400
From:      "Sung N. Cho" <sucho2@vt.edu>
To:        freebsd-stable@FreeBSD.org
Subject:   To those who doesn't know how to compile kernel in FreeBSD!
Message-ID:  <01072118363600.38324@vt.edu>

next in thread | raw e-mail | index | archive | help
Step 1:  Make your config file

# ee /usr/src/sys/i386/conf/SNCHOKERNEL

Here's my config file:

--------------------------------------------
##############################################################################
# SNCHOKERNEL - Sung's custom kernel configuration file for FreeBSD 4.3/i386 #
##############################################################################

machine		i386			# Machine architecture
cpu		I686_CPU		# CPU class
ident		SNCHOKERNEL		# Kernel name
maxusers	16			# Max allowed simultaneous processes

makeoptions	CONF_CFLAGS=-fno-builtin	# Don't allow use of memcmp, etc.
makeoptions	CONF_COPTFLAGS="-O -pipe"	# Kernel optimizations

options 	INET			# InterNETworking
options 	INET6			# IPv6 communications protocols
options		IPSEC
options		IPSEC_ESP
options 	FFS			# Berkeley Fast Filesystem
options 	FFS_ROOT		# FFS usable as root device [keep this!]
options 	SOFTUPDATES		# Enable FFS soft updates support
options 	PROCFS			# Process filesystem
options 	COMPAT_43		# Compatible with BSD 4.3 [KEEP THIS!]
options		USER_LDT		# Allow user-level control of i386 ldt
options 	UCONSOLE		# Allow users to grab the console
options 	USERCONFIG		# boot -c editor
options 	VISUAL_USERCONFIG	# visual boot -c editor
options 	KTRACE			# ktrace(1) support
options 	SYSVSHM			# SYSV-style shared memory
options 	SYSVMSG			# SYSV-style message queues
options 	SYSVSEM			# SYSV-style semaphores
options 	P1003_1B		# Posix P1003_1B real-time extensions
options 	_KPOSIX_PRIORITY_SCHEDULING
options		ICMP_BANDLIM		# Rate limit bad replies
options		TCP_DROP_SYNFIN		# Drop TCP packets with SYN+FIN
options 	KBD_INSTALL_CDEV	# install a CDEV entry in /dev
options		NSWAPDEV=1		# Allow this many swap disks
options		QUOTA			# Enable quota

# System BUS support
device		isa
device		pci

# Floppy drives
device		fdc0	at isa? port IO_FD1 irq 6 drq 2
device		fd0	at fdc0 drive 0

# ATA and ATAPI devices
device		ata
device		atadisk			# ATA disk drives
device		atapicd			# ATAPI CDROM drives

# atkbdc0 controls both the keyboard and the PS/2 mouse
device		atkbdc0	at isa? port IO_KBD
device		atkbd0	at atkbdc? irq 1 flags 0x1
device		psm0	at atkbdc? irq 12
options		PSM_HOOKRESUME		# Hook the system resume event, useful
					# for some laptops
options		PSM_RESETAFTERSUSPEND	# Reset the device at the resume event

# Video card support
device		vga0	at isa?
options 	VGA_NO_FONT_LOADING	# Don't save/load font
options 	VGA_NO_MODE_CHANGE	# Don't change video modes

# splash screen/screen saver
pseudo-device	splash

# syscons is the default console driver, resembling an SCO console
device		sc0	at isa? flags 0x100
options 	SC_NO_CUTPASTE		# No cut/paste in syscons
options 	SC_NO_FONT_LOADING	# Don't load software fonts in syscons
options 	SC_NO_HISTORY		# Don't keep history
options 	SC_NO_SYSMOUSE		# Don't use mouse in syscons

# Floating point support - do not disable.
device		npx0	at nexus? port IO_NPX irq 13

# Power management support (see LINT for more options)
device		apm0			# Advanced Power Management

# PCCARD (PCMCIA) support
device		card
device		pcic0	at isa?
options		PCIC_RESUME_RESET

# Serial (COM) ports
device		sio0	at isa? port IO_COM1 flags 0x10 irq 4
device		sio1	at isa? port IO_COM2 irq 3
options		CONSPEED=115200

# Parallel port
device		ppc0	at isa? irq 7
device		ppbus			# Parallel port bus (required)
device		lpt			# Printer

# Ethernet NICs.
device		ed

# Pseudo devices - the number indicates how many units to allocate.
pseudo-device	loop			# Network loopback
pseudo-device	ether			# Ethernet support
pseudo-device	pty			# Pseudo-ttys (telnet etc)
pseudo-device	gif	4		# IPv6 and IPv4 tunneling
pseudo-device	faith	1		# IPv6-to-IPv4 relaying (translation)
pseudo-device	bpf			# Berkeley packet filter
------------------------------------------------------------------


Step 2:  Edit the /boot/loader.conf for loading other modules such as sound 
driver, USB drivers etc.  (If you do not wanna use modules, you can 
permanently compile the support in the kernel by adding sound, usb supports 
in config file)

ee /boot/loader.conf

Here's what my loader.conf looks like:

------------------------------------------------------------------
###################################################################
# Sung's override to the initial /boot/defaults/loader.conf file! #
# 								  #
# NOTE: Please include only changes to /boot/defaults/loader.conf #
#       to avoid any unnecessary routines!			  #
###################################################################

userconfig_script_load="YES"
autoboot_delay="5"		# Delay in seconds before autobooting
#machdep.pccard.pcic_irq="0"	# Assigns PCCARD controller IRQ (0=polled)
#linux_load="NO"			# Linux emulation
snd_maestro_load="YES"		# ess maestro-2 pci
usb_load="YES"			# USB subsystem
#ugen_load="NO"			# USB generic device, if all else fails ...
uhid_load="YES"			# Human Interface Devices
#ukbd_load="NO"			# Keyboard
#ulpt_load="NO"			# Printer
ums_load="YES"			# Mouse
#umass_load="NO"			# Mass Storage Devices
#umodem_load="NO"		# Modems
#uscanner_load="NO"		# Scanners
agp_load="YES"			# agp module
----------------------------------------------------------------------------------------

Advantage of using modules is that you keep the kernel small by excluding 
unused device support and you load the module as necessary.   For example, 
USB scanner, I don't use it all the time so I only load it by saying "YES" 
only when I'm using it!


Step 3:  Time to compile!

There are two ways of compiling kernel now:

1) If you have FreeBSD 4.3, do this:
#cd /usr/src
# make kernel KERNCONF=SNCHOKERNEL  <--- Whatever your config name is

You're done!

**** If you wanna recompile the kernel, do this:
#rm -rf /usr/obj/usr/src/sys/SNCHOKERNEL  <---- remove the old one

now repeat from above



2) If you don't have FreeBSD 4.3 or simply wanna do it the old way:
#cd /usr/src/sys/i386/conf
#/usr/sbin/config SNCHOKERNEL  <--- Whatever your kernel config file is
#cd /usr/src/sys/compile/SNCHOKERNEL
#make depend && make && make install

You're done!

***** If you wanna recompile the kernel, do this:

#rm -rf /usr/src/sys/compile/SNCHOKERNEL <---- remove the old one

now repeat the process above to recompile



CAN'T BOOT THE NEW KERNEL?  DO THIS:
1) Reboot the computer
2) When the BSD counts the time .... HIT any button other than RETURN
3) Doesn't know the commands?  Type ? and RETURN
3) unload kernel   <---- unload whatever the kernel was loaded
3) load kernel.GENERIC <--- load the default or any other kernel that worked
4) boot


Sung N. Cho


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?01072118363600.38324>