Compiling Freebsd Kernel

Freebsd kernel compile

………………………..

compile kernel
1
編譯前檢查

檢查是否有完整的 FreeBSD source tree
2
產生並編輯新的kernel設定檔

#cd /usr/src/sys/amd64/conf
#cp GENERIC kernel2
#vi kernel2
編輯內容視需求修改
3
重建kernel後重開機

#cd /usr/src
#make buildkernel KERNCONF=kernel2
建立完後會出現完成訊息
————————————————————–
>>> Kernel build for kernel2 completed on Fri Nov 23 17:08:10 CST 2012
————————————————————–
#make installkernel KERNCONF=kernel2
#reboot
4
檢查是否編輯完成

#uname -a
FreeBSD systw 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Fri Nov 23 16:58:02 CST 2012 root@systw:/usr/obj/usr/src/sys/kernel2 amd64
訊息出現kernel2,表示是使用新改的kernel開機
ps:
新的kernel會複製到 /boot/kernel/kernel
舊的kernel則移至 /boot/kernel.old/kernel

ps:
amd64是系統架構
其他架構還有
alpha
i386
pc98
sparc64

ps:
The kernel does not boot解決方案
1 在開機選擇中,選擇 Escape to a loader prompt
2 在prompt mode下輸入
unload kernel
boot /boot/kernel.old/kernel

ps:
列出各設備詳細資訊
pciconf -lv

ps:
pciconf — diagnostic utility for the PCI bus
SYNOPSIS
pciconf -l [-bcv]
pciconf -a selector
pciconf -r [-b | -h] selector addr[:addr2]
pciconf -w [-b | -h] selector addr value


……………………………………………………………………………………………………………………..

kernel設定檔
以HP G5 DL380為例,kernel目前最少需保留如下

cpu HAMMER
ident GENERIC

options SCHED_ULE # ULE scheduler
options PREEMPTION # Enable kernel thread preemption
options INET # InterNETworking
options SCTP # Stream Control Transmission Protocol
options FFS # Berkeley Fast Filesystem
options SOFTUPDATES # Enable FFS soft updates support
options UFS_ACL # Support for access control lists
options UFS_DIRHASH # Improve performance on big directories
options UFS_GJOURNAL # Enable gjournal-based UFS journaling
options CD9660 # ISO 9660 Filesystem
options PROCFS # Process filesystem (requires PSEUDOFS)
options PSEUDOFS # Pseudo-filesystem framework
options GEOM_PART_GPT # GUID Partition Tables.
options GEOM_LABEL # Provides labelization
options COMPAT_FREEBSD32 # Compatible with i386 binaries
options COMPAT_FREEBSD4 # Compatible with FreeBSD4
options COMPAT_FREEBSD5 # Compatible with FreeBSD5
options COMPAT_FREEBSD6 # Compatible with FreeBSD6
options COMPAT_FREEBSD7 # Compatible with FreeBSD7
options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
options STACK # stack(9) 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 PRINTF_BUFR_SIZE=128 # Prevent printf output being interspersed.
options KBD_INSTALL_CDEV # install a CDEV entry in /dev
options HWPMC_HOOKS # Necessary kernel hooks for hwpmc(4)
options AUDIT # Security event auditing
options MAC # TrustedBSD MAC Framework
options INCLUDE_CONFIG_FILE # Include this file in kernel

# Make an SMP-capable kernel by default
options SMP # Symmetric MultiProcessor Kernel

# CPU frequency control
device cpufreq

# Bus support.
device acpi
device pci

# Floppy drives

# ATA controllers

# SCSI Controllers
device mpt # LSI-Logic MPT-Fusion

# ATA/SCSI peripherals
device scbus # SCSI bus (required for ATA/SCSI)
device ch # SCSI media changers
device da # Direct Access (disks)
device cd # CD
device pass # Passthrough device (direct ATA/SCSI access)
device ses # SCSI Environmental Services (and SAF-TE)

# RAID controllers interfaced to the SCSI subsystem
device ciss # Compaq Smart RAID 5*

# RAID controllers
device mfi # LSI MegaRAID SAS
device tws # LSI 3ware 9750 SATA+SAS 6Gb/s RAID controller

# atkbdc0 controls both the keyboard and the PS/2 mouse
device psm # PS/2 mouse
device kbdmux # keyboard multiplexer
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
options SC_PIXEL_MODE # add support for the raster text mode
device agp # support several AGP chipsets

# PCCARD (PCMCIA) support
# PCMCIA and cardbus bridge support
device cbb # cardbus (yenta) bridge
device pccard # PC Card (16-bit) bus
device cardbus # CardBus (32-bit) bus

# Serial (COM) ports
device uart # Generic UART driver

# Parallel port

# PCI Ethernet NICs.

# PCI Ethernet NICs that use the common 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 bce # Broadcom BCM5706/BCM5708 Gigabit Ethernet

# ISA Ethernet NICs. pccard NICs included.

# Wireless NIC cards

# Pseudo devices.
device loop # Network loopback
device random # Entropy device
device ether # Ethernet support
device pty # BSD-style compatibility pseudo ttys
device firmware # firmware assist module

# The `bpf’ device enables the Berkeley Packet Filter.
# Be aware of the administrative 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 xhci # XHCI PCI->USB interface (USB 3.0)
device usb # USB Bus (required)
device uhid # “Human Interface Devices”
device ukbd # Keyboard
device umass # Disks/Mass storage – Requires scbus and da
device ums # Mouse
# USB Serial devices
# USB Ethernet, requires miibus
# USB Wireless

# FireWire support

# Sound support