• Home
  • Whiteboard Kernel Project

Me, MyBlog and Linux

Just another WordPress.com weblog

Feeds:
Posts
Comments
« New team created for XPS-M1330 project
Stats after first successful run… »

How to compile kernel in Karmic

July 30, 2009 by rednus


I have recently started a project to reconfigure and compile kernel specific to Dell XPS-M1330 laptop, so I have downloaded latest development version of the kernel (ubuntu-linux-image 2.6.31-4.23). I have tried to use how-to’s on the internet but found out that ubuntu/debian scripts in Karmic have changed(Thanks to Tim Gardner). The old way was to completely create a new flavour and recompile the kernel. However from Karmic they have removed the flavour creation and added new sub-flavours.

So, I have decided to create a new subflavour based on amd64, alter the config and compile. First I have created subflavour and compiled without any changes, to see if it works, voila it worked, expcept one problem, nvidia drivers. So I have removed nvidia drivers from the system to get the kernel right and then worry about nvidia.

Here is how-to.

Preparation

STEP 1: Lets get started by installing required packages. So open a terminal, and start with following.

sudo apt-get install fakeroot build-essential
sudo apt-get build-dep linux-image-$(uname -r)

Remember, you don’t need to be sudo or su from now on. You can do all this in your home directory.

STEP 2: Get the sources

apt-get source linux-image-$(uname -r)

STEP 3: This will install sources in linux-$(uname -r) folder. Run the command below to create an easy link.

ln -s ./linux-$(uname -r) ./linux

STEP 4: Now enter this directory

cd linux

Create Sub-Flavour

Now if you observe, there is a directory called debian, which contains all the scripts for compiling the kernel and create linux-image and other deb packages the Ubuntu/Debian way. Ubuntu have modified the scripts a lot, so we can say its Ubuntu way :) We have to change and create some files in this directory to create our subflavour.

STEP 5: Now copy the amd64 standard config to new subflavour’s config.

cp debian/config/amd64/config.flavour.generic debian/config/amd64/config.flavour.xpsm1330

STEP 6: Now we have to enter a line into rules file to add new subflavour. Edit debian/rules.d/amd64 and add the line

generic_sub     = xpsm1330

That will enable the build script to identify the flavour xpsm1330 as subflavour of amd64. But there is still one thing left, which is to define the variables and files list for new subflavour.

STEP 7: Create file debian/sub-flavours/xpsm1330.vars with text below

# Based on amd64 flavour
arch=”i386 amd64″
supported=”XPSM1330″
target=”Geared toward XPS M1330 Laptops”
desc=”x86/x86_64″
bootloader=”grub | lilo (>= 19.1)”
is_sub=”true”
darch=”`dpkg-architecture -qDEB_HOST_ARCH`”
based_on=”amd64″
provides=”kvm-api-4, redhat-cluster-modules, ivtv-modules, ndiswrapper-modules-1.9″
conflicts=”linux-image-PKGVER-ABINUM-${based_on}”

STEP 8: Create a file debian/sub-flavours/xpsm1330.list with text “*” (without quotes) in the file for now. If you know full list of files you want you can write them here. A star will mean all files which are compiled.

STEP 9: One last thing to do, regenerate control and control.stub files.

rm debian/control
rm debian/control.stub
debian/rules debian/control

That will generate new control files with subflavour descriptions in. And that it we are alllll-most done.

Configure

STEP 10: Karmic uses distributed config, which is thrown over separate files, like config.common.ubuntu, config.common.amd64 and config.flavour.<flavour>. So we cannot edit the config using make menuconfig so follow the procedure below.

debian/scripts/misc/kernelconfig editconfig

This will start editing the files one by one, you will see message asking you to press a key, which will also show the file its editing, so when you see config.flavour.xpsm1330, start editing. Once you have iterated through all make a backup of this file so that you dont have to edit everything next time.

Compile & Create Package

STEP 11: This is the simplest part, but will be the most time consuming one and probably if there are any errors, you are in gutter :( Just run the command below, it will create linux-image-<ver>-xpsm1330 and linux-headers-<ver>-xpsm1330 in root folder of ./linux. Change the concurrency_level to number of processors/cores you have.

CONCURRENCY_LEVEL=2 NOEXTRAS=1 skipabi=true skipmodule=true fakeroot debian/rules binary-xpsm1330

Once you see the deb packages, install and restart your system to see if it worked.

PS: As I said, if you have nvidia drivers, remove the nvidia drivers, restart the pc and then you can reinstall them (hopefully).

Let me know how it goes.

This is my first ever how-to so your comments are very valuable, if you think any part should be changed, please let me know, I will edit accordingly.

TODO:

1. Find out how to give version numbers for sub-flavour like linux-image-<flavour_version>-xpsm1330-<subflavour_ver>

2. debian/rules debian/control does not create stub entry for linux-headers-<vers>-<subflavour>, currently linux-headers-<vers>-generic section should be copied and edited

3. Create scripts to make and do overlay directory and files and edits. Also make overlay script should backup sub-flavour config file and add version number.

Like this:

Like
Be the first to like this post.

Posted in Projects | Tagged compile, kernel, Linux, ubuntu, xps-m1330 | 8 Comments

8 Responses

  1. on August 2, 2009 at 12:38 pm How to compile kernel in Karmic | Ubuntu-News - Your one stop for news about Ubuntu

    [...] kernel. However from Karmic they have removed the flavour creation and added new sub-flavours. More here So, I have decided to create a new subflavour based on amd64, alter the config and compile. First I [...]


  2. on August 17, 2009 at 2:22 pm japitaki

    Change the concurrency_level to number of processors/cores you have !!! actually the number shoulbe cpu core +1 .

    Anyway I was searching for solution on karmic since I have failed to compile in the debian way.
    Also you could use git to pull the latest kernel. with different branches you can test differrent setup.


  3. on September 9, 2009 at 10:01 pm freakazoo

    the folders debian/config/amd64 does not exist.

    rm debian/control
    rm debian/control.stub
    debian/rules debian/control

    does not work either


    • on September 10, 2009 at 8:25 am rednus

      If you are using the latest 2.6.31-8 or later sources, they have changed the name of the debian folder to debian.master. I haven’t got a chance yet to compile these sources. But replace string debian with debian.master and try it again. I am not sure what other changes they have made.


  4. on September 10, 2009 at 10:27 am freakazoo

    ok I figured that out, just wanted to be sure ;)

    I still get following error as root:
    bash: debian/control: Permission denied


    • on September 10, 2009 at 10:54 am rednus

      I am exactly not sure where you are getting permission error, but in my procedure you do not have to be root or su after step 2. You should be a normal user through out the procedure.

      Can you please let me know what you are doing?


  5. on February 24, 2010 at 5:01 pm 84matte84

    Hi rednus, I found your “how-to” very nice…I’m trying to understand how the kernel configuration works…I would like to deeply understand how the “compile procedure” works, so for example “what is SUB-FLAVOUR” etc etc….could you suggest to me some guides books or tutorials to study it???
    thank u guy!!!!
    bye bye


  6. on April 28, 2010 at 6:19 pm Linux Kernel Debugging with kgdb « Tardis for a Toolbox

    [...] building on ubuntu is found here with special information for karmic here.  I ended up making a new sub-flavour as described here. Once the kernel was installed and booting I turned to getting symbols for my kernel module.  I [...]



Comments are closed.

  • Search

  • About Me

    My Name is Shyam, and I am a Linux enthusiast. I work as a SAP Developer and spend my free time learning Linux. I use Ubuntu as my home Desktop system which I have changed to Alpha version to run tests. I write this blog as a repository and learning portal for myself and other new comers.
  • Blog Stats

    • 3,555 hits
  • Top Posts

    • None
  • Categories

    • Hardware (2)
    • Info (3)
    • Linux (3)
    • Linux Games (1)
    • News (1)
    • Projects (11)
    • Stats (1)
  • Tags

    boot bootchart ccache compile Dell development drivers General generic kernel God Help This World Installation kernel Linux OS PCs project RTS Games Scripts things-to-do ubuntu XPS xps-m1330
  • Recent Posts

    • What have I been doing in the past one year
    • XPS-M1330 – No more
    • RTS Linux game – Hive Rise
    • Speeding up the build with ccache..
    • Kvetch’d.. and now fedup..
  • Archives

    • August 2010
    • August 2009
    • July 2009
  • Meta

    • Register
    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.com

Blog at WordPress.com.

Theme: MistyLook by Sadish.


Follow

Get every new post delivered to your Inbox.

Powered by WordPress.com