Saturday, May 14, 2016

Linux Distribution Kernel Upgrade

In this post I want to write some steps to upgrade Distribution's Linux kernel from the source (yeah, not by specific distribution package manager), this assuming all required build tools has been installed and configured properly, consult to the distribution's resources to build a kernel from source.

I'm using Linux Mint 13 32bit (codename Maya, a Ubuntu 12.04 LTS derivative) as the host, running kernel version 3.13.0 which I steal from Linux Lite 2.4. Here I upgrade it to kernel version 4.4.10 (LTS). These steps here are not limited to Ubuntu derivate distributions, it can be for other distribution such as Debian, Fedora, Arc Linux and the others.

Get the kernel source

Firstly, download and unpack the kernel source, here I download it directly from and pick an XZ archive version. We use /project/linux as our base working directory.

$ cd /project/linux
$ wget
$ tar xJf linux-4.4.10.tar.xz

Apply current kernel configuration

To match the current kernel configuration and to avoid too much dives in kernel configuration, we will reuse a configuration file that is very likely shipped by the distribution we are using, usually it is located inside the /boot directory, copy this file into our kernel source tree as .config

$ cd linux-4.4.10 
$ make mrproper
$ cp /boot/config-`uname -r` .config 

Building the kernel

Issue this to enter the kernel build configuration, for any errors that may occurred, again please refer to distribution documentation describing a system preparation to build kernel from source.

$ make menuconfig

The text based (ncurses) configuration menu appears, since we already have a .config file, we don't *really* care to configure some options again but let the configuration it self adjust and adapt against our existing configuration file. Exit from the configuration menu and confirm to save the configuration. Now we are ready to build the kernel by issuing

$ make

The build system should now begin to compile, various build messages or compiler warnings appear. The build time depends on hardware speed (CPU, RAM, disk I/O) and how many kernel's components we enabled in configuration. When the build has been finished, install all kernel's modules with superuser privilege

$ sudo make modules_install
$ cp arch/x86/boot/bzImage /project/linux/vmlinuz-4.4.10
$ cp .config /project/linux/config-4.4.10

This will install kernel modules inside /lib/modules/4.4.10 directory and copy the new kernel image as vmlinuz-4.4.10-generic inside our base working directory. For reference, we ought to copy configuration file for our future reference, of course like what we are doing now.

Rebuild initial ramdisk image

Since our distribution uses an initial ramdisk or so called initrd then we need to rebuild it to contain our new kernel's modules, we will use the existing initrd as our base.

Anyway, this is the most interesting part of upgrading process, the initrd file is a cpio archive and was gz compressed so we will use zcat and cpio utilities to extract and uncompress it. Assuming cpio and zcat are installed, issue these following commands

$ cd /project/linux
$ mkdir initrd
$ cd initrd
$ zcat /boot/initrd.img-`uname -r` | cpio -i

In above commands, we've created a directory named initrd as our initrd's files location after the extraction, we only need to replace old (current) kernel modules to our new modules. Ideally, by initrd nature which only provide basic init system, utilities and kernel modules need to boot, we only need to replace each module that are inside the old kernel, but since I'm too lazy to pick each one, I just copy full module directory here. Make it is easy, the downsize is just getting the final initrd file much bigger, don't worry about that. Issue these following commands to copy.

$ cd lib/modules
$ rm -rf `uname -r`
$ cp -r /lib/modules/4.4.10 .

And its time to rebuild the initial ramdisk image, first we back to our initrd base directory and optionally make sure all initrd files are owned by Linux's UID 0 (root) then archive and compress it into a new initrd image. Switch to root and issue

# cd /project/linux/initrd
# chown -R root:root *
# find . | cpio -o -H newc | gzip -9 > /project/linux/initrd.img-4.4.10

Now, we should have these files in the base working directory


We may need to copy or move these files into /boot directory if we like. And that's all, we can now test to boot the new kernel by modifying the GRUB boot loader configuration that usually in /boot/grub/grub.cfg (GRUB v2), see GRUB manual for that.

Thursday, May 12, 2016

Back To Write Again

It's been a long way since my last update in 2013, many thing was happened, I was too busy with rocking in, life, code, GTA V and all the for-nothing stuff. Now I'm back (hopefully with a great consistency) to write again.

The web technology has been advanced so fucking great so does the Blogger, it has many improvements such as the cool editor interface, personally I like it and want to switch from my old favorite half syntax HTML editor. Also, I may need to change this blog template since its begin look old to me then add a nice commenting system like Disqus. That's all for now, there are tons of stuff in my brain that open for fire.

Monday, May 06, 2013

Building GTK+ 3 Library

I have spent my days building GTK+ 3 and components for my project inside my Thinkpad E125 running on Ubuntu 10.04 LTS (Lucid Lynx).

Below are GTK+ 3 components that need to be downloaded from their respective project site:
Installation directory is under /opt/gtk, pkg-config ($PKG_CONFIG_PATH), dynamic library ($LD_LIBRARY_PATH) and system path ($PATH) environment variable should be determined (depends on package) in order to configure and compile each package. Notice that I passed extraction process for each package and cover only build and installation.

Also it is important to have a correct version for package dependency, for example GTK+ 3.6.4 requires at least version 2.34.x of Glib, as well as other package. gtk-doc is optional (enabled with --enable-gtk-doc configure argument) to generate GTK+ HTML style documentation which very important to me.

So here are the building steps:
  • gtk-doc-1.18
    $ ./configure && make && sudo make install
  • glib-2.34.3
    $ ./configure --prefix=/opt/gtk --enable-gtk-doc
    $ make && sudo make install
  • atk-2.6.0
    $ PKG_CONFIG_PATH=/opt/gtk/lib/pkgconfig LD_LIBRARY_PATH=/opt/gtk/lib ./configure --prefix=/opt/gtk --enable-gtk-doc
    $ make && sudo make install
  • at-spi2-core-2.6.3
    $ PKG_CONFIG_PATH=/opt/gtk/lib/pkgconfig LD_LIBRARY_PATH=/opt/gtk/lib ./configure --prefix=/opt/gtk
    $ make && sudo make install
  • at-spi2-atk-2.6.2
    $ PKG_CONFIG_PATH=/opt/gtk/lib/pkgconfig LD_LIBRARY_PATH=/opt/gtk/lib ./configure --prefix=/opt/gtk
    $ PATH=/opt/gtk/bin:$PATH make
    $ sudo PATH=$PATH:/opt/gtk/bin make install
  • pixman-0.28.2
    $ ./configure --prefix=/opt/gtk
    $ make && sudo make install
  • cairo-1.2.14
    $ PKG_CONFIG_PATH=/opt/gtk/lib/pkgconfig ./configure --prefix=/opt/gtk --enable-gtk-doc
    $ make && sudo make install
  • gdk-pixbuf-2.29.0
    $ PKG_CONFIG_PATH=/opt/gtk/lib/pkgconfig LD_LIBRARY_PATH=/opt/gtk/lib ./configure --prefix=/opt/gtk --enable-gtk-doc --without-libtiff
    $ make && sudo make install
  • freetype-2.4.11
    $ ./configure --prefix=/opt/gtk
    $ make && sudo make install
  • fontconfig-2.10.91
    $ ./configure --prefix=/opt/gtk
    $ make && sudo make install
  • harfbuzz-0.9.16
    $ ./configure --prefix=/opt/gtk
    $ make && sudo make install
  • pango-1.32.5
    $ PKG_CONFIG_PATH=/opt/gtk/lib/pkgconfig ./configure --prefix=/opt/gtk --enable-gtk-doc
    $ make && sudo make install
  • gtk+-3.6.4
    $ PATH=/opt/gtk/bin:$PATH PKG_CONFIG_PATH=/opt/gtk/lib/pkgconfig LD_LIBRARY_PATH=/opt/gtk/lib ./configure --prefix=/opt/gtk --enable-gtk-doc --enable-packagekit=no
    $ PATH=/opt/gtk/bin:$PATH make
    $ PATH=/opt/gtk/bin:$PATH sudo make install
To test if the build was successful, the easy way is to run gtk3-demo program inside /opt/gtk/bin, previously have provided dynamic module path either in or by set LD_LIBRARY_PATH environment variable at the runtime, for example:

$ LD_LIBRARY_PATH=/opt/gtk/lib /opt/gtk/bin/gtk3-demo

To compile and link against GTK+ 3 (or any component), use pkg-config environment variable PKG_CONFIG_PATH to set GTK+ 3 pkg-config file location for both --cflags and --libs argument.

Monday, October 01, 2012

Leaving DB

Back to October 2008, when I was in Bandung, I got a call from a HR manager in Jakarta asked me for a job interview. Then 1 week after it, I go to Jakarta to meet the HR manager, after a long negotiation and spending some weeks in the city I'm officially hired by the company.

I started my days to build their network infrastructure and next advance to system programmer. I design Linux device and application for one of their most important device. From this experience I proofed how good Linux for the industry, tons of features, highly customizable and undoubtedly reliable. I proofed how good the collaboration of the Debian project, proofed the GTK+ interface and usability, proofed how good POSIX thread was implemented and more. I have learned many things from serial port devices to card and reader interfaces.

For some personal decisions (human natures such as dislike and disagree) I decided to leave the company and advance to the next level of complexity. I have worked with peoples who has great determination and spirit, got so many friends there. This is my 4th years relation with the company, thanks for giving me such a great experience, wish the best success for you. And I hate to say Goodbye!.

Thursday, April 26, 2012

Dream Theater World Tour

Time is running quickly but what I was missing? nothing, especially it is one of my favorite metal band tour, yeah Dream Theater (DT) is about to come to Jakarta at 21th April 2012. The tour is named after their 11th album's title: A Dramatic Turn of Events world tour and luckily they also pick Jakarta as tour destination, so I would like to say thanks to Variant Entertainment as promoter for bringing the progressive metal band here (and also for the high-price ticket). This is their first (might be the ONLY one) visit to Indonesia, so I will not take any compromises and must go to the show.

Saturday 21th April I wear my metal attributes: Black CONVERSE John Varvatos (limited edition), Black Led Zeppelin sweater and a old black jeans, unfortunately my DT t-shirt is out of date now, so no DT stuff. Approx. at 3 PM I start from Arion Plaza by a taxi heading to Mata Elang Indoor Stadium (MEIS) at Ancol for the metal show after withdrawing the ATM for IDR 2,000,000.

Arrived at MEIS stadium, there are already a lot of DT's fans and they are here also for one reason: A metal show from a world class band, just like me. Then I look for the official ticket sale, and I feel lucky because there are buy-1-get-1-free ticket that means if you buy 1 ticket you will get 1 free ticket, it cost IDR 1,500,000 but with one condition: the voucher will be available for exchange (for the real ticket) after 7.45 PM, yeah sounds like a marketing strategy or what the hell. I will have 2 tickets, so I call my friend Iwan and asked if is available to join me for the show, considering he was also a crazy DT fan, yeah, of course he was available.

It is on 4 PM, DT fans is keep coming from everywhere, still has a lot of time to wait before the show that begin at 9 PM. So I wasted my times by taking some pics, walking around in front of MEIS stadium, eating AW fast food and walking. At 7.30 PM, the stadium was fulled by fans who came for the live show. I was queued for ticket exchange and got it, 2 Last Entry Festival tickets, at the time peoples were entering the stadium, one I still missing is Iwan, he was still heading here. I wait this guy in front of stadium until he came at probably 9 PM.

Entering MEIS stadium and going to the festival area, it still a solo acoustic guitar player as opening, peoples are shouting while he played A Change of Session intro as his closing. The band's crew are coming, opening the black large fabric and the stage showing up. Fantastic view, so that is the Dramatic Turn of Events tour's theme, it has 3 big box as background display and fantastic lightnings, the crew also tune some well known rock song, some of them are Anything Goes (AC/DC), Welcome To The Jungle (Guns N' Roses) while preparing. And the shows begin, John Petrucci attack us with Bridges In The Sky, you know the situation should be, a metal band with almost 8000 fans are watching, the band continue with Build Me, Break Me Down also from Dramatic Turn of Events album. Then a nostalgic song: 6.00 (Awake), after that Jordan Ruddes take the intro of Sorrounded (Images And Words), I keep singing and banging my head. The spectator did the same, keep their hand higher with metal sign and follow James LaBrie singing while the lights keep it's magic. The band continue with these songs in a a row The Root of All Evil (Octavarium), A Fortune In Lies (When Dream And Day Unite). After that, John Petrucci pick a accoustic guitar and sit beside James LaBrie, it is going to be acoustic. We sing together when they playing Silent Man (Awake), a very good song, then followed by the last song of Dramatic Turn of Events album, Beneath The, what can I say, this song was so beautiful and meaningful, one of DT killer song. Continue with On The Back of Angels. Then the most liked song: The Spirit Carries On (Metropolis), yeah everybody is singing and enchanted by this one. After that is Mike Mangini drum solo, I think he is very skilled drummer who able to replace Mike Portnoy, and John Myung also rocks too. Continue to Breaking All Illusions, this song is very dynamic and complex, It has good pattern and reff lyrics to sing. We want more... We want more... we are shouting this after they left the stage, this is a ancient band ritual, the band want to hear if you are demanding more. So they back to the stage and playing Pull Me Under (Images And Words), and the fans was again enjoying the famous DT's hit. So this is will be their last song. What a very fantastic and monumental event.

So that's all, Dream Theater live. thanks DT, you are one of the best band in my soul. That's all I can say. Then me and Iwan take a rest at AW for some foods and drinks, then leaving Ancol.