OpenSource For You

Use GIT for Linux Kernel Developmen­t

This article is aimed at newbie developers who are planning to set up a developmen­t environmen­t or move their Linux kernel developmen­t environmen­t to GIT.

- By: Vinay Patkar The author works as a software developmen­t engineer at Dell India R&D Centre, Bengaluru, and has close to two years’ experience in automation and Windows Server OS. He is interested in virtualisa­tion and cloud computing technologi­es.

GIT is a free, open source distribute­d version control tool. It is easy to learn and is also fast, as most of the operations are performed locally. It has a very small footprint. Just to compare GIT with another SVN (Source Version Control) tool, refer to http://git-scm.com/ about/small-and-fast.

GIT allows multiple local copies (branches), each totally different from the other—it allows the making of clones of the entire repository so each user will have a full backup of the main repository. Figure 1 gives one among the many pictorial representa­tions of GIT. Developers can clone the main repository, maintain their own local copy (branch and branch1) and push the code changes (branch1) to the main repository. For more informatio­n on GIT, refer to http://git-scm.com/book.

The kernel

The kernel is the lowest level program that manages communicat­ions between the software and hardware using IPC and system calls. It resides in the main memory (RAM), when any operating system is loaded in memory.

The kernel is mainly of two types - the micro kernel and the monolithic kernel. The Linux kernel is monolithic, as is depicted clearly in Figure 2.

Based on the above diagram, the kernel can be viewed as a resource manager; the managed resource could be a process, hardware, memory or storage devices. More details about the internals of the Linux kernel can be found at http:// kernelnewb­ies.org/LinuxVersi­ons and https://www.kernel.org/ doc/Documentat­ion/.

Linux kernel files and modules

In Ubuntu, kernel files are stored under the /boot/ directory (run ls /boot/ from the command prompt). Inside this directory, the kernel file will look something like this:

‘vmlinuz-A.B.C-D’ … where A.B is 3.2, C is your version and D is a patch or fix. Let’s delve deeper into certain aspects depicted in Figure 3: Vmlinuz-3.2.0-29-generic: In vmlinuz, ‘z’ indicates the

‘compressed’ Linux kernel. With the developmen­t of virtual memory, the prefix vm was used to indicate that the kernel supports virtual memory. Initrd.img-3.2.0-29-generic: An initial ‘ramdisk’ for your kernel. Config3.2.029generic: The ‘config’ file is used to configure the kernel. We can configure, define options and determine which modules to load into the kernel image while compiling. System.map-3.2.0-29-generic: This is used for memory management before the kernel loads.

Kernel modules

The interestin­g thing about kernel modules is that they can be loaded or unloaded at runtime. These modules typically add functional­ity to the kernel—file systems, devices and system calls. They are located under /lib/modules with the extension .ko.

Setting up a developmen­t environmen­t

Let’s set up the host machine with Ubuntu 14.04. Building the Linux kernel requires a few tools like GIT, make, gcc and ctag/ncurser-dev. Run the following command: Sudo apt-get install git-core gcc make libncurses­5-dev exuberant-ctags

Once GIT is installed on the local machine (I am using Ubuntu), open a command prompt and issue the following commands to create an account: git config global user.name “Vinay Patkar” git config –global user. Email Vinay_Patkar@dell.com

Let’s set up our own local repository for the Linux kernel.

Now you can see a directory named linux-2.6 in the current directory. Do a GIT pull to update your repository: Cd linux-2.6 Git pull

Next, find the latest stable kernel tag by running the following code: git tag -l | less git checkout -b stable v3.9

Setting up the kernel configurat­ion

Many kernel drivers can be turned on or off, or be built on modules. The .config file in the kernel source directory determines which drivers are built. When you download the source tree, it doesn’t come with a .config file. You have several options for generating a .config file. The easiest is to duplicate cp /boot/config`uname r`* .config or cp /boot/config3.13.024generic .config Make defconfig < for default configurat­ion Or Make nconfig < for minimal configurat­ion, here we can enable or disable features At this point edit MakeFile as shown below VERSION = 3 PATCHLEVEL = 9 SUBLEVEL = 0 EXTRAVERSI­ON = rc9 < there [edit this part] NAME = Sabertooth­ed Squirrel

Now run:

Make

This will take some time and if everything goes well, install the newly built kernel by running the following command: Sudo make modules_install Sudo make install

At this point, you should have your own version of the kernel, so reboot the machine and log in as the super user (root) and check uname –a. It should list your own version of the Linux kernel (something like ‘Linux Kernel 3.9.0rc9’).

 ??  ??
 ??  ??
 ??  ?? Figure 7: Modules_install and Install
Figure 7: Modules_install and Install
 ??  ?? Figure 5: GIT checkout
Figure 5: GIT checkout
 ??  ?? Figure 6: Make
Figure 6: Make
 ??  ??

Newspapers in English

Newspapers from India