Thursday, January 14, 2010

Building a Custom Ubuntu Linux Kernel on a Dell Latitude E6400

I am now running on a custom build of the 2.6.31.6 kernel. I haven’t made any source mods yet, but I am now armed and dangerous. This post will cover what I had to go through.

More or less, I had a smooth experience aside from one bug. I will try and recap what I did. I didn’t take notes, so this list comes from looking back over the reference guides. There may be some things missing, sorry.

1. Found a few good references

2. Download the source

  • I used Synaptic to get a source archive instead of going with Git
  • I grabbed linux-source-2.6.31

3. Unpack the source into ~/dev/linux-source-2.6.31

  • cp /usr/src/linux-source02.6.31.tar.bz2 ~/dev
  • cd ~/dev
  • tar xjf linux-source02.6.31.tar.bz2

4. Grab a whole mess of dev stuff

  • sudo apt-get install fakeroot kernel-wedge build-essential makedumpfile
  • sudo apt-get build-dep linux
  • I didn’t take good notes, but I remember having to grab more things. You’re on your own, kid.

5. Create a kernel config file using the current as a base

  • cp /boot/config-[whatever] ~/.config

6. Run menuconfig

  • cd ~/dev/linuxwhatever
  • make menuconfig
  • Note the instruction on turning off “Kernel hacking” –> “Compile the kernel with debug info”

7. Gets me some compiler go fast

  • export CONCURRENCY_LEVEL=3

8. Compile, and then wait

  • fakeroot make-kpkg --initrd --append-to-version=-plaird kernel-image kernel-headers
  • Be sure to replace plaird with something meaningful to you
  • This took about 30 minutes for me
  • It puts two .deb files into the parent directory (~/dev)

9. Install the kernel, unsuccessfully

  • sudo dpkg -i linux-image-xxx_i386.deb
  • sudo dpkg -i linux-headers-xxx_i386.deb

This should have worked, but there currently is a weird bug in dkms that affects folks with nvidia graphic cards:

run-parts: /etc/kernel/postinst.d/nvidia-common exited with return code 20

10. Find fix for Bug #292606

It turns out this bug is known, and there is a fix. Since it took the devs a while to figure out the solution, there were some dead ends before I found the right fix.

  • sudo gedit /etc/kernel/postinst.d/kernel_postinst.d_dkms
  • add ‘> /dev/null’ after ‘start dkms_autoinstaller KERNEL=$inst_kern’

11. Install the kernel, successfully

Rerun step 9.

12. Make sure /boot/grub/menu.lst has an entry for your new kernel

  • The install process might have already done this if you haven’t manually modified menu.lst (I had)

13. Reboot and enjoy

  • Armed and dangerous.

Diagnosing slow system start time on Linux with Bootchart

I am probably the last one to this party, but I found this to be cool enough to post.

While my Ubuntu isn’t Windows slow, it is starting to get a bit pokey on startup. I have installed a lot of crap, but most are apps and libraries which shouldn’t affect start time.

I wasn’t actively looking for a solution, but saw mention of Bootchart and thought I’d give it a quick whirl. Its a nice tool. It not only collects data on where time is spent on boot, but it graphs it in a really nice chart.

The reason I think I might be the last to the party on this is that Bootchart has been around for some time – since 2005. It has had time to polish and it is sweet.

In a nutshell, you install it on your machine. It installs itself early on into the init.d chain, and then monitors /proc to see what’s cooking. It collects data on disk usage and CPU usage. Once booted, it then renders a nice image of the boot sequence into /var/log/bootchart.

Below is a snapshot of my boot (hmmm, that’s probably a NSFW statement in some countries). It takes about a minute. I didn’t find anything totally whack on my machine. The main area of optimization would be to not have Postgres start on boot. But, its only about 5 seconds, and I do use it, so I don’t think I am going to do modify that.

Another suspect is Ubuntu One, which is a Dropbox style file sync utility. Its even tech fanboy compatible – you can see that it launches couchdb. I rely on this for my backup strategy, so its an easy decision to keep this one too.

OK, so here it is.

plaird-laptop-karmic-20100114-6