FreeBSD Stable Release 4.11 Installer Guide
Home______________________________________________________________________
The kernel that comes with the FBSD install includes device statements for many of the most common devices on the market. It's very general on purpose so it will work for the majority of PC hardware configurations in public use. It's a rare occurrence when a FBSD system user never builds a custom kernel to fix problems or adds functions or hardware unique to their needs. Building a custom kernel is a normal process in the life of a FBSD system. If nothing else, just removing all the devices your particular system does not use will decrease the size of the kernel module causing it to load faster at boot time. As part of the basic FBSD install, FBSD provides a copy of the kernel source used to build the running kernel named GENERIC. Another kernel source named LINT contains all the kernel configuration statements with comments that are allowed in the kernel. The LINT file is your reference place where you would look for configuration statements for hardware devices or kernel options not in the GENERIC file. Please note the spelling of the names of these two files, Their names are in capital letters, and that's the way their file names are really spelled in the directory where they live.
Do not edit GENERIC directly, as it may get overwritten the next time you CVS update your kernel source and your kernel modifications will be lost. The GENERIC kernel config file lives in a directory which is five sub-directories deep. This becomes such a pain in the butt, typing in this long path every time you want to edit your custom kernel file. Your custom kernel config file is a very important element of your FBSD system. It should really live in the /etc directory with the other FBSD config files for easy backup. There is no reason your custom kernel config has to live in the same directory with GENERIC. It's a good idea to name your custom kernel config file after your machine's hostname= statement in rc.conf. You should call the new customized kernel config file 'gateway'.
Follow these instructions
cd /usr/src/sys/i386/conf # point to correct directory
cp GENERIC /etc/kernel.gateway # copy and rename to whatever you want
ln -s /etc/kernel.gateway # create a link to it’s new home
ee /etc/kernel.gateway # edit your kernel source
Edit your gateway file making the changes you want. Feel free to change the comment lines at the top to reflect your configuration or the changes you have made to differentiate it from GENERIC.
You must execute all of the following commands under the root account or you will get permission denied errors.
1. Change into this directory location (mandatory)
cd /usr/src/sys/i386/conf
2. Run config program against kernel.gateway to generate the kernel source code.
/usr/sbin/config kernel.gateway
3. Change into the build directory.
cd ../../compile/kernel.gateway
4. Issue compile commands
make depend # When this completes then issue next command
make # When this completes then issue next command
make install # When this completes reboot to enable new kernel
Or combine all the single commands into one command line so all the make steps will run one after the other.
make depend && make && make install
The new kernel will be copied to the root directory as /kernel and the old kernel will be moved to /kernel.old. Now, reboot the system to use your new kernel.
FBSD only maintains the current kernel; named /kernel, the previous kernel; named /kernel.old, and a failsafe /kernel.GENERIC. Never delete the /kernel.GENERIC file. The /kernel.generic should be kept in case you compile a faulty kernel that won't boot properly and you need to boot from a kernel known to work. After you perform a couple of compiles in a row your original working kernel has rolled off and you have nothing to recover to. Say in this current kernel you added IPFW statements. You should make a copy of /kernel and give it a name that has meaning to you.
cp /kernel /kernel.ipfw
Later if you want to know what /kernel really is, just compare the file size of the /kernel.whatever to the file size of /kernel for a match.
Use this command to list kernel modules
ls -lo /kernel*
-r-xr-xr-x 1 root wheel schg 1918326 Jan 30 2004 /kernel
-r-xr-xr-x 1 root wheel - 4028952 Oct 9 2003 /kernel.GENERIC
-r-xr-xr-x 1 root wheel - 1918326 Jan 18 2004 /kernel.ipfilter>
-r-xr-xr-x 1 root wheel - 1865270 Jan 18 2004 /kernel.ipfw
-r-xr-xr-x 1 root wheel - 1918326 Jan 2 2004 /kernel.old
The /kernel file has the immutable flag on, which means the file is marked as being protected from being written over. The immutable flag has to be set off before you can copy another /kernel.whatever over it.
Use these commands
chflags noschg /kernel # turn off immutable flag
cp /kernel.whatever /kernel # replace kernel with different one
chflags schg /kernel # turn on immutable flag
There maybe times when you have made changes to /etc/rc.conf or created a new /kernel, and the FBSD will not boot successfully, or you forgot the root password.
You need to gain access to your FBSD system in some way so you can fix your problems. You do this be going into single user mode. This can only be done from the FBSD system console.
During the normal boot process, it pauses for 10 seconds. At this pause hit the keyboard space bar.
At the 'ok' prompt enter this command to enter single user mode:
boot -s
At the prompt for shell path, just hit enter on keyboard.
When the system comes up you have to manually mount all filesystems to gain access:
fsck -p
mount -u /
mount -a -t ufs
swapon -a
Now you have a running system as normal except you are the only one with access from the system console. Do whatever you need to do to repair your problem. When you have completed your repairs, enter the reboot command.
Follow the instruction above to get in single user mode, then enter:
passwd root
and follow the prompts. When complete, enter the reboot command.
During the normal boot process, it pauses for 10 seconds. At this pause hit the keyboard space bar.
At the 'ok' prompt enter these commands to locate and load the GENERIC kernel or the kernel you want.
ls –l kernel* # Display the contents of the / directory
unload # unloads all modules that are positioned to boot from
load /kernel.GENERIC # Load the kernel you want or the generic one
boot # start the boot process over again using your kernel
______________________________________________________________________
This FreeBSD Installer Guide is an public domain HOW-TO. This content may be reproduced, in any form or by any means, and used by all without permission in writing from the author.
Recent comments