пятница, 15 апреля 2016 г.

Build a custom kernel

Build a custom kernel

Today I will show you how to build your custom kernel based on the standard GENERIC kernel.

Why?

Let me explain a situation when the custom kernel is useful. I love the MATE desktop environment with the classic GNOME2ish design. The MATE contains the libmatemixer package which provides, for example, possibility to adjust volume level using the according volume panel applet. The libmatemixer's package built with 4FRONT OSS support. Every time I upgrade software packages I have to make libmatemixer with ALSA support from the port.

This is not good. I think so. But I can't merely do `pkg remove alsa ; pkg install oss` because the 4FRONT OSS conflicts with NewPCM OSS built in FreeBSD 10's kernel by default. So before I will be able to install and use OSS from 4FRONT Technologies, I have to cut off all the audio drivers from the default GENERIC kernel.

To do this...

Create a new kernel configuration

Log in to the system as root. Go to the /usr/src/sys/i386/conf directory (where i386 is the architecture of your machine). Then create (if not exists) a directory where you are going to work with your kernels (/root/kernels for example). Then copy an existing kernel configuration to start from and open it in your favorite editor.

cd /usr/src/sys/i386/conf
mkdir /root/kernels
cp GENERIC /root/kernels/F1
ln -s /root/kernels/F1
vi F1

I started from the supplied GENERIC kernel. The first screen of its configuration looks like on the next screenshot.


Configure new kernel

Do not hesitate changing the title and the description of the new kernel in its configuration file.

I recommend you to save the kernel configuration after typing the comment to avoid a possible data lost. If you use vi, just press ESC, type the :w command and press ^j.

I am too lazy to make long description of kernels, so I just noted that my custom kernel called F1 (like the first generation in the biology/genetics) and that it does not contain any sound driver.

To configure (cut off) sound drivers, find the Sound support section in the kernel configuration file using the /Sound vi command.

In vi: press ESC, type /Sound and then press ^j.

This command will toggle you to at about 340 line.


To remove all sound devices drivers, commend out all the lines in the "sound support" section.


Comment all the lines in the "Sound support" section. In vi you may use the next command:
:342,349s/^/#

In vi you may use the :342,349s/^/# command to add the # sign to the beginning of all lines from 342 to 349 (in your configuration file sound support section may be located in the different lines interval!).

vi says that 8 sound devices drivers was excluded from the kernel

Save changes in the kernel configuration file.

Use :wq command of vi to save changes in the kernel configuration file and exit the editor.

Build the kernel

After the kernel is configured, you can build it. Go to the /usr/src directory and start build process.

cd /usr/src
make buildkernel KERNCONF=
F1
# where F1 is the name of the kernel you want to build

The kernel build process takes several minutes and looks like this


On my system it took ten or even twenty minutes.

After the kernel is built you will see the according message on the screen. Now it is possible to...

Install the kernel

To do this just enter the next command


make installkernel KERNCONF=F1

and wait several minutes.

The kernel installation process

Reboot the machine after kernel installation complete.

shutdown -r now
or simple
reboot

Check your work

Look at the output of the uname -a command after reboot. The output should contain the name of the newly installed kernel.

uname -a

To ensure that my new kernel does not support my audio card I started the MPlayer and noticed that there is no sound now. Also I noticed the error message from OSS about missing audio device file.


Advanced. Configuration including

It is possible to include the one kernel configuration to the yours. Like "inheritance" in OOP. " This allows another configuration file to be included in the current one, making it easy to maintain small changes relative to an existing file" documentation says.

You are able to use the next self-descriptive options.
  • option
  • nooption
  • device
  • nodevice
Below is the example of the my kernel configuration based on the GENERIC kernel. My configuration just disables sound devices support from the kernel.
nodevice sound
nodevice snd_cmi
nodevice snd_csa
nodevice snd_emu10kx
nodevice snd_es137x
nodevice snd_hda
nodevice snd_ich
nodevice snd_via8233

Conclusion

So, I proud to say: the mission is complete. I removed audio support from the system. I am going to install the 4FRONT OSS sound system package next week or to. Thank you for your interest.

Bibliography

  1. Руководство FreeBSD. Глава 9. Настройка ядра FreeBSD, 9.5. Сборка и установка собственного ядра.
  2. Open Sound System for FreeBSD
  3. Configuring the FreeBSD Kernel. The Configuration File.


Комментариев нет:

Отправить комментарий