FreeBSD compiled kernel detailed explanation

xiaoxiao2021-03-06  76

FreeBSD compiled kernel detailed explanation

Author: heiyelurenQQ groups: 5415735 (Linux / FreeBSD installation and maintenance group) Date: 2004/9 / 2-- special thanks QQ group Friends Anan, the paper was produced under the guidance of his patience -

I used to hear the compilation kernel. I feel special, huh, especially the operating system like FreeBSD, it is very good, can customize the kernel, how to get it, huh, huh, can improve the speed, and can guarantee Safe stability, so I will try to customize the kernel. (I am also a newbie, if the article has an error, please correct!)

The freebsd I used is a version 5.2.1. Now it is a new one, I look at my kernel file size:

# ls -l / boot / kernel / kernel-r-xr-xr-x 1 root wheel 5940286 Feb 24 2004 /Boot/kernel.bak/kernel

It seems that it is not small, more than 5m, huh, huh, I have to put it into 3M, huh, begin ...

First, install the kernel source code to compile the kernel, first must ensure the source code of the kernel, let's see if our system is installed:

# ls / usr / src / sysls: / usr / src / sys: no sudh file or directory

Prove that we have not installed the kernel source code, well, we installed it. The kernel source code is installed in the / usr / src / sys directory. If there is no such directory, then you have not

There is installation source code. Let's put our FreeBSD installation CD in the CD-ROM drive, then execute the ROOT / SysInstall under FreeBSD, select Configure, then

Distributions, down SRC, last sys, can start installing after entering bus, generally install it in a few minutes, install you, you can view this folder:

# Ls / usr / src / sysMakefile ddb libkern netkey pcialpha dev modules netnatm posix4amd64 fs net netncp powerpcarm geom net80211 netsmb rpcboot gnu netatalk nfs securitycam i386 netatm nfs4client sparc64coda i4b netgraph nfsclient syscompat ia64 netinet nfsserver toolsconf isa netinet6 opencrypto ufscontrib isofs netipsec pc98 vmcrypto kern netipx PCCard

After the source code is installed, we can start our configuration kernel only.

Second, configuring the kernel file actually our compilation kernel is to configure kernel files, the directory of the kernel profile is under / usr / src / sys / i386 / confed, we enter the referential: # CD / usr / src / sys / i386 / conf # lsgeneric generic.hints Notes Paemakefile Oldcard getHints.awk

The kernel profile is generic, what we want to configure is it, the configuration includes opening those hardware support, IPv6 support, network card, etc. In order to prevent the configuration of our configuration file, there is a problem.

Let's put it back up:

# cp generic generic.bak

Then we use any editor to open the file, you can use VI, or EE to open, I use EE to open for convenience:

# ee generic

There is similar after opening:

# Generic - generic kernel configuration file for freebsd / i386 ## for more information on this file, please read the handbook section on # kernel configuration files:

The content, the front there is "#" represents the content or option is a comment, so if we want to get any options, you can add "#" in front, and of course you don't need any options you can delete, but

I recommend unwanted options in front add "#".

About Profile Detailed Modify Recommendation Reference FreeBSD Chinese Manual About Kernel Configuration Options: http://www.freebsd.org.cn/snap/doc/en_cn.gb2312/books/Handbook/kernelconfig-config.html

My profile is so modified. I don't explain in detail. Please check the above configuration file reference should be suitable for most of the machines such as ISA, SCSI, RAID.

Generic kernel configuration file configuration:

######################################################################################################################################################################################################################################################################################################## ################################## generic - generic kernel configuration file for freebsd / i386 ## for more information on this file, please read the handbook section # kernel configuration Files: ## http://www.freebsd.org/doc/en_us.iso8859-1/books/handbook/kernelconfig-config. html ## The handbook is also available locally in / usr / share / doc / handbook # if you've installed the doc distribution, otherwise always see the # FreeBSD World Wide Web (http://www.FreeBSD.org/) server For the # late information. ## an exhaustive list of the # device lines is also present in the ../../conf/notes and notes files. # if you are in doubt as to the purpose Or Necessity of A Line, Check First # in Notes ## $ freebsd: src / sys / i386 / conf / generic, v 1.394.2.3 2004/01/26 19:42:11 NECTAR EXP $ MACHINE I386 # CPU i486_cpu # CPU I586_CPUCPU I686_CPUIDENT Generic

#TO staticly compile in device.hints# Hints "generic.hint" #default placers to look for devices.

#makeoptions debug = -g #build kernel with gdb (1) Debug symbols

options SCHED_4BSD # 4BSD scheduleroptions INET # InterNETworking # options INET6 # IPv6 communications protocolsoptions FFS #Berkeley Fast Filesystemoptions SOFTUPDATES #Enable FFS soft updates supportoptions UFS_ACL #Support for access control listsoptions UFS_DIRHASH #Improve performance on big directoriesoptions MD_ROOT #MD is a potential root device # options NFSCLIENT #Network filesystem Client # options nFSSERVER #Network filesystem Server # options NFS_ROOT #NFS usable as /, requires NFSCLIENT # options MSDOSFS #MSDOS Filesystemoptions CD9660 #ISO 9660 Filesystemoptions PROCFS #Process filesystem (requires PSEUDOFS) options PSEUDOFS # Pseudo-filesystem frameworkoptions COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!] options COMPAT_FREEBSD4 #Compatible with freeBSD4 # options SCSI_DELAY = 15000 #Delay (in ms) before probing SCSIoptions kTRACE #ktrace (1) support # options SYSVSHM # SYSV-style shared memoryoptions SYSVMSG #SYSV -Style Message QueueSopt ions SYSVSEM # SYSV-style semaphoresoptions _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensionsoptions KBD_INSTALL_CDEV # install a CDEV entry in / devoptions 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 Pfil_hooks # Pfil (9) Framework

# Debugging for use in -current # options DDB #Enable the kernel debugger # options INVARIANTS #Enable calls of extra sanity checking # options INVARIANT_SUPPORT #Extra sanity checks of internal structures, required by INVARIANTS # options WITNESS #Enable checks to detect deadlocks and cycles #oPtions witness_skipspin # don't run witness on spinlocks for speed # To make an small need

Device Isadevice Eisadevice PCI

# Floppy DrivesDevice FDC

# ATA and ATAPI devicesdevice atadevice atadisk # ATA disk drives # device ataraid # ATA RAID drivesdevice atapicd # ATAPI CDROM drivesdevice atapifd # ATAPI floppy drives # device atapist # ATAPI tape drivesoptions ATA_STATIC_ID #Static device numbering

# SCSI Controllers # device ahb # EISA AHA1742 family # device ahc # AHA2940 and onboard AIC7xxx devices # device ahd # AHA39320 / 29320 and onboard AIC79xx devices # device amd # AMD 53C974 (Tekram DC-390 (T)) # device isp # Qlogic Family # Device Mpt # lsi-logic mpt-fusion # device ncr # ncr / symbios logic # device Sym # ncr / symbios logic (NEWER Chipsets those of `ncr ') # Device TRM # tekram DC395U / UW / F DC315U Adapters

#device adv # Advansys SCSI adapters # device adw # Advansys wide SCSI adapters # device aha # Adaptec 154x SCSI adapters # device aic # Adaptec 15 [012] x SCSI adapters, AIC-6 [23] 60. # device bt # Buslogic / Mylex MultiMaster SCSI Adapters

#Device ncv # ncr 53c500 # device nsp # Workbit ninja scsi-3 # device STG #TMC 18C30 / 18C50

# SCSI peripheralsdevice scbus # SCSI bus (required for SCSI) #device ch # SCSI media changers # device da # Direct Access (disks) #device sa # Sequential Access (tape etc) #device cd # CD # device pass # Passthrough device ( direct SCSI access) #device ses # SCSI Environmental Services (and SAF-TE) # RAID controllers interfaced to the SCSI subsystem # device amr # AMI MegaRAID # device asr # DPT SmartRAID V, VI and Adaptec SCSI RAID # device ciss # Compaq Smart RAID 5 * # Device DPT # DPT Smartcache III, IV - See Notes for Options # device IIR # Intel Integrated Raid # device ips # ibm (adaptec) Serveraid # device Mly # Mylex Acceleraid / Extremeraid

# RAID controllers # device aac # Adaptec FSA RAID # device aacp # SCSI passthrough for aac (requires CAM) #device ida # Compaq Smart RAID # device mlx # Mylex DAC960 family # device pst # Promise Supertrak SX6000 # device twe # 3ware ATA RAID

# Atkbdc0 Controls Both The Keyboard and The PS / 2 MouseDevice Atkbdc # at Keyboard ControllerDevice Atkbd # at KeyboardDevice 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 consoledevice sc

# Enable this for the PCVT (vt220 compatible) Console Driver # Device VT # Options XServer # Support for x Server on a vt console # Options Fat_Cursor # Start with block Cursor

Device AGP # Support Several Agp Chipsets

# Floating point support - Do Not Disable.Device NPX

# Power Management Support (See Notes for more option #device apm # address for the i8254. # Device Pmtimer

# PCCARD (PCMCIA) support # Pcmcia and cardbus bridge support # device cbb # cardbus (yenta) bridge # device pcic # ExCA ISA and PCI bridges # device pccard # PC Card (16-bit) bus # device cardbus # CardBus (32- Bit) bus # serial (com) Ports # Device Sio # 8250, 16 [45] 50 Based Serial Ports

# Parallel PortDevice PPCDevice PPBus # Parallel Port Bus (Required) #device LPT # PrinterDevice PLIP # TCP / IP over Paralleldevice PPI # Parallel Port Interface Device # Device VPO # Requires Scbus and DA

# If You've got a "Dumb" Serial or Parallel PCI Card That IS # supported by The PUC (4) Glue Driver, UNComment THE FOLLOWING # LINE To Enable It (Connects to The Sio and / or PPC Drivers): # device PUC

# PCI Ethernet NICS. # Device de # dec / intel dc21x4x (`` Tulip ') device em # intel pro / 1000 adapter Gigabit Ethernet card # device TXP # 3COM 3CR990 (`` Typhoon' ') # Device VX # 3COM 3C590 3C595 (`` Vortex '')

# 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 bfe # Broadcom BCM440x 10/100 ethernet # device bge # Broadcom BCM570xx Gigabit Ethernet # device dc # DEC / Intel 21143 and various workalikesdevice fxp # Intel EtherExpress PRO / 100B (82557, 82558) #device pcn # AMD Am79C97x PCI 10/100 (precedence over 'lnc') # device re # RealTek 8139C / 8169 / 8169S / 8110S # device rl # RealTek 8129/8139 # device sf # Adaptec AIC-6915 ( `` Starfire '') # device sis # Silicon Integrated Systems SiS 900 / SiS 7016 # device sk # SysKonnect SK -984x and SK-982x gigabit ethernet # device ste # Sundance ST201 (D-Link DFE-550TX) #device ti # Alteon Networks Tigon I / II gigabit ethernet # device tl # Texas Instruments ThunderLAN # device tx # SMC EtherPower II (83c170 `` Epic '') # Device VR # via Rhine, Rhine II # Device WB # Winbond W89C840F # Device XL # 3COM 3c90X (`` Boomrang '', `` CY clone '') # ISA Ethernet NICs. pccard nics included. # device cs # Crystal Semiconductor CS89x0 NIC # 'device ed' requires 'device miibus' # device ed # NE [12] 000, SMC Ultra, 3c503, DS8390 cards # device EX # Intel EthereXpress Pro / 10 and Pro / 10 # device EP # Etherlink III Based Cards # Device Fe # Fujitsu MB8696X Based Cards # Device IE # EtherExpress 8/16, 3C507, Starlan 10 etc. # device LNC # ne2100, NE32 -VL Lance Ethernet Cards # Device Sn # SMC's 9000 Series of Ethernet Chips # device xe # xircom pccard ethernet

# Isa devices That Use the old isa shims # device le

# Wireless NIC cards # device wlan # 802.11 support # device an # Aironet 4500/4800 802.11 wireless NICs. #Device awi # BayStack 660 and others # device wi # WaveLAN / Intersil / Symbol 802.11 wireless NICs. # Device wl # Older non 802.11 . Wavelan wireless NIC # Pseudo devices - the number indicates how many units to allocate.device random # Entropy devicedevice loop # Network loopbackdevice ether # Ethernet supportdevice sl # Kernel SLIPdevice ppp # Kernel PPPdevice 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 'Device Enables The Berkeley Packet Filter. # Be aware of the administrative consequences of enabling this! Device BPF # Berkeley Packet Filter

# USB supportdevice uhci # UHCI PCI-> USB interfacedevice ohci # OHCI PCI-> USB interfacedevice usb # USB Bus (required) #device udbp # USB Double Bulk Pipe devicesdevice ugen # Genericdevice uhid # "Human Interface Devices" device ukbd # Keyboard # device ulpt # Printerdevice umass # Disks / Mass storage - Requires scbus and dadevice ums # Mousedevice urio # Diamond Rio 500 MP3 player # device uscanner # Scanners # USB Ethernet, requires miidevice aue # ADMtek USB ethernetdevice axe # ASIX Electronics USB ethernetdevice cue # CATC USB EthernetDevice Kue # Kawasaki LSI USB Ethernet

# FireWire Support # Device FireWire # FireWire Bus Code # Device SBP # SCSI Over Firewire (Requires Scbus and DA) #device FWE # Ethernet over FireWire (Non-Standard!) ###################################################################################################################################################### ######################################################################################################################################################################################################################################################################################################## ###############################################

After the configuration is complete, press the ESC button, then prompted to press "A" to save the configuration file after pressing "A". Third, compile the kernel:

After the kernel file is configured, the kernel can be compiled, and there are generally two ways to compile, we take traditional compilation.

We entered / usr / src / sys / i386 / conf directory: # CD / usr / src / sys / i386 / conf

Run the config command to generate the kernel source code.

# / usr / sbin / config generic

Switch to the catalog of the built core.

# cd ../compile/generic

Compile the kernel

# Make depend # make

Install the new kernel.

# make install

OK, here, if there is no error in the middle, then our internal core has been successfully installed, and after reboot, we can use our new built kernel. If there is a

Error, then check if your steps are consistent with the above steps, while checking if your kernel configuration file is configured correctly, general compilation is unsuccessful is the problem of kernel file configuration

,please check carefully.

Fourth, the new kernel cannot start:

If your compiled kernel can't start, you can start using the previous core. Generally, after compiling the kernel, it will put the old core backup, general /boot/kernel.old is the old

Nuclear backups, problems can be used to start using long-term cores.

The specific implementation method is: You can press any key other than ENTER when the system starts 10 counts, then type the unload command, type boot kernel.old, or any kernel name that can be started.

, Then you can start the system normally and enter the system and re-perform the kernel.

Note: You can't rely on kernel.old, because when you install a new kernel, kernel.OLD will be covered by the last installed kernel, so you either manually back up a

Normal start-up kernel, or pay attention to whether your kernel.old can start the kernel.

end

Ok, here, our compiled kernel work is completed, and let's take a look at whether our kernel has decreased:

# ls -l / boot / kernel / kernel-r-xr-xr-x 1 root wheel 3090929 Sep 1 21:30 / boot / kernel / kernel

Oh, obviously turned the original 5940286 into the current 3090929, although it did not become a big double, but also small, the system is faster!

Note: This article is carried out in the FreeBSD 5.2.1 environment, not necessarily suitable for other versions, especially FreeBSD4.x, if there is a problem, please refer to the manual.

Attached: FreeBSD Chinese Manual: http://www.freebsd.org.cn/snap/doc/en_cn.gb2312/books/Handbook/index.html kernel configuration reference: http://www.freebsd.org.cn/snap /Doc/en_cn.gb2312/bos/handbook/kernelconfig.html

Writetime: 2004-9-2 13:20

转载请注明原文地址:https://www.9cbs.com/read-120860.html

New Post(0)