Home page of this blog

Thursday, November 22, 2012

Custom Ubuntu 64 bit Kernel 3.6.7 optimized for i3/i5/i7

This time my experiment is bit different, interesting and ambitious!

I upgraded my i7 RAM to 12 GB (Corsair Vengence 4 GB X 3) and running in triple channel mode (will tell what I did to the old RAM in another story :) )

I ran the kernel compilation in RAM mounted directory so that none of the files are read/written from/to harddisk while doing intensive kernel compilation. Infact processor scaled so well that kernel compilation took just under 19 mins which used to be 25 mins with harddisk. The real advantage is not the speed, but avoiding lots of read/writes to harddisk

To achieve this, I used tmpfs

The built script to build kernel 3.6.7 and utilize 10 GB of RAM for compilation is here

Use the above script only if you have above 10 GB of RAM

If you have less RAM use the script here

First, I created a directory and mounted that as a tmpfs. I gave a size of 10 GB RAM max for the newly mounted tmpfs.

The commands I used to create a directory and mount tmpfs is as follows

mkdir -p ~/BuildTmp
sudo mount -t tmpfs -o size=10G tmpfs ~/BuildTmp

To check the disk file size and monitor how the tmpfs is filling up, I used df -k

df -k

Calling df -k at various points of kernel compilation

 Towards the end of kernel compilation df -k reports 79 percent of 10 GB tmpfs, which is nearly 7.9 GB of RAM used!!

See the compilation time, not much gain in speed but small gain is a gain (a gain of 6 minutes)

Copying the compiled kernel debian files to harddisk

Installing the built kernel files

Unmounting tmpfs before rebooting

sudo umount ~/BuildTmp

Installing nvidia drivers for the newly built kernel, I downloaded 310.19 driver from nvidia.co.in

Here is a video of how I built nvidia kernel module using recovery kernel, (video is shot using my phone and I am not a professional photographer, it is just for learning purpose I uploaded this video to youtube)


It is simple, reboot and select recovery kernel, install nvidia driver using nvidia provided shell script, reboot into normal kernel

Here are the photographs explaining the same which was shown in video. (sorry for poor images with photo flash)

Select recovery kernel (second one usually in the boot loader screen)

 Booting into recovery...

Scroll down and select root Drop to root shell prompt

mount root filesystem read/write (and mount home if you have a separate home system) as root in recovery is mounted read only

mount -o remount,rw /
mount /home

Change to home directory where the nvidia driver is downloaded

run the driver using sh (replace the below file with whatever the driver filename using tab, :) )

sh ./NVIDIA-Linux-x86_64-310.19.run

Let nvidia installer launch

Accept nvidia license termns

Opt to uninstall previous drivers

Continue installation anyway? yes (Sorry it is blurred ...)

Register for dkms (what, no I say)

And that is it, rest by the installer ...

Install 32 bit compatibility openGL libs? yes of course

Let it run its way (won't you)

run nvidia-xconfig, yes man, yes, do it

Ah, give ok

unmount /home
mount -o remount,ro /

Unmount home and remount root read only, then reboot

From the boot loader, select the regular kernel (the first one, second is usually recovery kernel)

Now you should be into the gui with nice nvidia drivers, enjoy


  1. This comment has been removed by the author.

  2. This comment has been removed by the author.

  3. Custom kernel 3.6.7, nvidia driver Ubuntu 12.04, Ubuntu 12.04
    Hi I've done everything from "buildkernel367native-noram.sh", but I'm still with my old kernel Are there any additional steps?

    1. Did you reboot into the newly installed kennel

    2. Did you reboot into the newly installed kennel

  4. Yes, of course,This part was a little tricky for me ->

    "#give y to native config
    #Load alternate config and choose stableconfig which is untouched by editconfigs, save alternate config and save .config after changing processor type and kernel frequency"

    I set the frequency to 1000',
    My system:

    Intel® Core™ i3 CPU M 350 @ 2.27GHz × 4
    3.2.0-33-generic #52-Ubuntu SMP Thu Oct 18 16:29:15 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

    1. Yeah I agree, it is tricky indeed, you need to do this as follows

      after giving y to native flavor, it will launch menuconfig, that blue screen,

      scroll down and load stableconfig (type stableconfig after erasing .config)

      After changing whatever you want, don't just exit, scroll down again and select save an alternate config, erase stableconfig and type .config

      Now exit, all your configs will be in .config, which was built on top of stable ubuntu 12.04 config

  5. This is exactly what I did.Actuality at first I've had it for the first prompt, because I didn't pay attention that
    "native" config comes at the second prompt...but then I do the same for "native" config.Can this cause the problem?I can do it again and send you a copy of the terminal lines.

    1. We need only modify native flavor, but changing others does not impact!! as we are building only native flavor at the end

  6. Ok! I decided to try again, but this time I can't "wget" maybe because I've already had the patchs?

    niko@niko-N61Ja:~$ mkdir -p ~/Builds/Kernel367
    niko@niko-N61Ja:~$ cd ~/Builds/Kernel367
    niko@niko-N61Ja:~/Builds/Kernel367$ wget -c http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.6.7.tar.bz2
    --2012-11-24 17:03:07-- http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.6.7.tar.bz2
    Resolving www.kernel.org (www.kernel.org)...,
    Connecting to www.kernel.org (www.kernel.org)||:80... connected.
    HTTP request sent, awaiting response... 416 Requested Range Not Satisfiable

    The file is already fully retrieved; nothing to do.

    niko@niko-N61Ja:~/Builds/Kernel367$ wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.6.7-raring/0001-base-packaging.patch
    --2012-11-24 17:05:18-- http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.6.7-raring/0001-base-packaging.patch
    Resolving kernel.ubuntu.com (kernel.ubuntu.com)...
    Connecting to kernel.ubuntu.com (kernel.ubuntu.com)||:80... connected.
    HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers.

    1. seems kernel.ubuntu.com is slow or down or they removed sharing kernel patches of ubuntu

    2. http://www.downforeveryoneorjustme.com/kernel.ubuntu.com/~kernel-ppa/mainline/