Wednesday, April 29, 2009

Update: CityCell Zoom in Ubuntu 9.04

So far so goood. The new Ubuntu boots in less than 15 minues, has more eye candy than anything before. But at what cost? They have stripped the new distro of wvdial. Yes, its true.

Not only that, the usbserial module is built into kernel. This might sound advantageous in the first glance, but what about when you have to pass the module parameters into kernel, every time you boot?

I have found a work around for this problem, hope it helps people like me who are dependent on EDGE/GPRS. Here I'm going to describe the extra things that needs to be done to get things working. Details are in  my previus post, hope you don't mind. :)

First you need to open /boot/grub/menu.lst and add some parameters to the kernel. Find the line which is similar to this:

kernel /boot/vmlinuz-2.6.29.1-macbook root=UUID=c660e7d4-95e3-42a0-8967-8de554d76fb4 ro quiet splash


and change it to this:

kernel /boot/vmlinuz-2.6.29.1-macbook root=UUID=c660e7d4-95e3-42a0-8967-8de554d76fb4 ro quiet splash usbserial.vendor=0x05c6 usbserial.product=0x3197


The vendor and product sting can be found using lsusb command. Reboot the system.

Now comes the stupid part. Jaunty come with no wvdial, so you need to download the files manually. The files are

libuniconf4.4_4.4.1-0.2ubuntu2_i386.deb
libwvstreams4.4-base_4.4.1-0.2ubuntu2_i386.deb
libwvstreams4.4-extras_4.4.1-0.2ubuntu2_i386.deb
libxplc0.3.13_0.3.13-1build1_i386.deb
wvdial_1.60.1+nmu2_i386.deb


Try looking them up in http://archive.ubuntu.com/ubuntu/pool/. Once you download them put those downloaded files in the same folder, and then do a $sudo dpkg -i *.deb.

The rest of the process is pretty straightforward. You can find those here

Saturday, April 18, 2009

Subversion 101

This post covers the fundamentals of subversion, the popular version control system. I'll show how to use subversion to version-control linux-2.6.29.1 kernel on your local server (I had to set this up for easy management of my kernel assignment). But before we begin, let's get familiar with some of the subversion terms.


You do a check-out when you download some project from the server to your local machine, this creates the working copy for your subsequent modification.


You do a check-in or commit when you upload your changes to the server.


Self explanatory, update updates your code with the latest changes from the server.


Doing an export will download the latest update from the server, but without subversion metadata, so you cannot upload the changes to the server from here. This mode is generally used to make the distribution tars.


import will bring the data imported under subversion's control system.


Now that we know the basic, let's do some command line stuff. I'm assuming you have subversion installed in your system by now. In Ubuntu you can easily do this by sudo apt-get install subversion svnadmin.


First step is to create the repository, typically its created in /var/svn/. So issue the command svnadmin create /var/svn.


subversion can be run under several protocols, like svn:// or http://. But right now we don't want to bother with that, we'll use simple file:// for local access.


First we need to create several folders in our repository. trunk is the folder where we'll put or main code. We'll use branches and tags when we think that we need to create several fork of the same project. So,



svn mkdir file:///var/svn/trunk
svn mkdir file:///var/svn/branches
svn mkdir file:///var/svn/tags


Now import your linux source code into svn,

svn import ~/src/linux-2.6.29 file:///var/svn/trunk/linux-2.6.29.1 --message "Importing linux kernel 2.6.29.1"


Go to the folder where you want to create the working copy.

svn checkout file:///var/svn/trunk/linux-2.6.29.1


Edit files as needed. Then check status by,

svn status


Update code from server

svn update


Commit your changes

svn commit --message "Added some feature"


Create a branch

svn cp file:///var/svn/trunk/linux-2.6.29.1 file://var/svn/branches/linux-2.6.29.1-vanilla -m "Creating a branch for the vanilla kernel"


If you don't like command line, use rapidsvn. It has a really nice GUI. Also popular IDE like Netbeans and Eclipse has build in subversion support.

I'll try to cover using subversion over http in my next post.

Friday, April 17, 2009

Linux Kernel: Speed Up Compilation

I have been having a hard time for the last few days in doing my "Linux Kernel Assignment". No, programming is not the hardest part. Waiting for the kernel to compile is the main problem. Its pathetically the moment when you become the sitting duck. :). So here are some of the things I came across to speed up the compilation.
  1. Make sure you have ccache installed and configured. As the name suggests, ccache dramatically speeds up subsequent compilations by caching the object files. In most new Fedora distros, its enabled by default. You can check it by doing $which gcc. If it says something like /usr/lib/ccache/gcc, you are all set up. If not, try google, :)
    You can see see its status by issuing command $ccache -s. Its good to set the cache amount a bigger than default, so $ccache -M 2G will set the cache to 2GB which is enough for everyone.
  2. Use gcc option -pipe whenever possible. Self explanatory, it uses pipes instead of temporary files.
  3. If you have dual core or quad core processor and a lot of RAM, you'll notice that while compiling, only a fraction of your processor and RAM gets used. This is because there is only one compile process running at a time. You can specify multiple make jobs by passing parameter like this $make -j 2. Here, make will run at most 2 jobs at a time, taking full advantage of your multi-core CPU and RAM. Some argue on setting higher value, but I do not recommend it, as it likely to have negative effect because of the large amount of context switched in the CPU. People say that this approach leads to race conditions but I haven't bumped into any of that yet.
  4. For Linux Kernel compilation, make sure you have CONFIG_DEBUG_KERNEL unset in .config file. If set, this builds your kernel with debugging symbol making your kernel a lot bigger and significantly longer to build. It will make kernel debugging impossible though, but when you are in a hurry, this really makes more sense. Also strip the .config file from any unnecessary drivers/modules you don't require, but this will require you to have a thorough knowledge about both your PC and running kernel.
  5. For those with high speed network (ethernet or more), give a try to distcc, that distributes the compilation among multiple machine. The configuration is quite straight forward. Check the references section for details. 
  6. Try tmpfs. It enables you to mount any folder in your file system in RAM, so theoretically speeding up the compilation. Try mounting your build folder with tmpfs like this $sudo mount -t tmpfs -o size=500M,mode=0777 tmpfs /usr/src/linux-build.
Using the above mentioned method, you can get a clean build of 2.6.29 kernel in less than 15 minutes. Let me know if you have any problems or come up with any better solutions. :)

References:

https://help.ubuntu.com/community/Kernel/Compile

http://www.linux.org/docs/ldp/howto/Modules/speedup.html

http://en.gentoo-wiki.com/wiki/Portage_TMPDIR_on_tmpfs

http://www.ibm.com/developerworks/linux/library/l-distcc.html

Friday, April 03, 2009

Ubuntu: Easy kernel compile for newbies

Building a fully optimised kernel just for your pc is one of most exiting things to do. But manual kernel compilation not an easy task and occasionally things go haywire all the time. Luckily Ubuntu comes with some nifty tools to make it easier than ever. Here is a short how-to for the starters. Remember, these are the basic steps. I've skipped most of the exiting parts to make it as simple as possible.
  • Download the latest Kernel from http://kernel.org/. For e.g. linux-2.6.29.tar.bz2
  • Create a folder named src in your home folder and put the downloaded file in it.
  • Untar the file
      $tar xvjf ~/src/linux-2.6.29.tar.bz2
      $cd ~/src/linux-2.6.29
    Run the Following commands to install the necessary packages to build the kernel
      $sudo apt-get install build-essential fakeroot initramfs-tools libncurses5 libncurses5-dev
  • Create a base config file, we'll reuse the current kernel's config
      $cp -vi /boot/config-`uname -r` .config
  • Run this command, a graphical window will appear. Here you can make change to the kernel configs. Right now we won't change anything. So just run it and save.
      $make menuconfig
  • Do a cleaning in the source tree
      $make-kpkg clean
  • The real stuff, build the kernel (this will take a really long time, so grab a cup of cofee). I'll call this version 'paladin'.
      $fakeroot make-kpkg --initrd --append-to-version=-paladin kernel-image kernel-headers
  • Install the packages
      $sudo dpkg -i ~/src/*.deb
  • Do a reboot and enjoy the new kernel
  • If anything goes wrong (kernel panic !!!), you might need to take a socond look at the configurations.



Back to Blogging

After a failed attempt last year to get back to blogging, I'm trying it again this year. I really wanted to get back, but got busy will...