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.
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
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
target=”Geared toward XPS M1330 Laptops”
bootloader=”grub | lilo (>= 19.1)”
provides=”kvm-api-4, redhat-cluster-modules, ivtv-modules, ndiswrapper-modules-1.9″
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.
That will generate new control files with subflavour descriptions in. And that it we are alllll-most done.
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.
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.
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.