Linux kernel development enviroment setup
by Wenwei Weng
Playing around Linux kernel is always something very interesting to me. In fact, it is very straightforward to run the kernel built by ourself. also in order to play around a linux driver, it is must to have a kernel build enviroment in place first.
Choose a linux distribution to start
There are so many Linux distributions around, and it could be confusing which one to use. After I did a bit homework, I landed with Fedora. Here is the path I walked through: the majorities of linux boxes in my Cisco lab run either Ubuntu or Redhat Enterprise/Centos. Since Redhat/Centos has pretty old version os kernel, I’m not that interested to use that. So initially I wanted to use Ubuntu, I love Ubuntu because it is so easy to get most tools/packages I wanted to be installed. I thought it would be awesome to have my own built kernel running in my boxes. However, after I played around it, I realized there are some wrapper layers around Ubuntu kernel build. If I want to download and build kernel from kernel.org, which is not going to work straightly. Then I looked into Gentoo and Arch Linux, which are two who are famous for providing the flexibity for the developer to customize what he wants. I did install Gentoo, but felt it was a bit too much for customization as I already used to smoothe installation of ubuntu. I want something in between. I did a bit googling, and found Fedora is the one what I look for. Some peopel said Linus Torvalds is using Fedora too.
Following are the steps to follow to set up a kernel development using Fedora 23.
Download Fedora 23 workstation.
Download and burn into a DVD if needed.
Install Fedora
There are two ways:
- Install as virtual machine, e.g. using VirtualBox. It is convient, but could lost some functionality like HPET etc.
- Install in a bare metal box.
Boot Fedora and rebuild vanilla linux kernel from mainline
- Clone Linus' GIT repository from GitHub: git clone https://github.com/torvalds/linux.git.
- In order to do kernel configuration change through "make menuconfig", ncurses-devel package needs to be installed: dnf install ncurses-devel
- By default openssl-devel package is not installed, and which is required by kernel build: dnf install openssl-devel
- kernel configuration: copy the kernel configuration file of current running kernel: cp /boot/config-$(uname -r) .config, then invoke "make menuconfig: to adjust the kernel configuration, save it.
- make oldconfig && make bzImage
- make modules && make modules_install
- make install
- reboot
Now you should have kernel built by yourself running.
You are ready to build your own kernel driver.
Subscribe via RSS