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 kernel.org and pick an XZ archive version. We use /project/linux as our base working directory.
$ cd /project/linux
$ wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.4.10.tar.xz
$ 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
vmlinuz-4.4.10
initrd.img-4.4.10
config-4.4.10
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.
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts
Saturday, May 14, 2016
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:
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:
$ 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.
Below are GTK+ 3 components that need to be downloaded from their respective project site:
- GTK+, Glib, Pango, Atk, gdk-pixbuf, gtk-doc - http://gnome.org
- Cairo - http://cairographic.org
- FreeType, Fontconfig, HARFBUZZ - http://freedesktop.org
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
$ 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!.
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, March 15, 2012
systemd rc.local
In Fedora 16 (Verne) the init program has been completely replaced by systemd. systemd still provide SysVinit script compability such as the famous rc.local script. I noticed that Fedora 16 doesn't enable this by default, here a solution to enable this.
Create a rc.local script file at /etc/rc.d, for convenience we can provide this as link to it's common location with
# ln -sf /etc/rc.d/rc.local /etc/rc.local
Then activate the service and start it with
# systemctl enable rc-local.service
# systemctl start rc-local.service
Now systemd should run the rc.local script through the rc-local.service
Create a rc.local script file at /etc/rc.d, for convenience we can provide this as link to it's common location with
# ln -sf /etc/rc.d/rc.local /etc/rc.local
Then activate the service and start it with
# systemctl enable rc-local.service
# systemctl start rc-local.service
Now systemd should run the rc.local script through the rc-local.service
Friday, July 15, 2011
Scatter/gather I/O operation
This is a common way to do scatter/gather I/O (sometime called vectored I/O), it has great performance over large chunk of data. The readv() and writev() function are atomic means these system call only issued for once to transfer multiple data into the kernel.
unsigned len;
long iovcnt, iovcnt_max;
iovcnt_max = sysconf(_SC_IOV_MAX);
/* Determine how many part of data to be written */
while (len > 0) {
iovcnt = len >= iovcnt_max ? iovcnt_max : len;
struct iovec iov[iovcnt];
/* Initialize iov's members, process with readv() or writev() */
len -= iovcnt;
}
The above code first determine maximum allowed size of iovcnt, in Linux this value is 1024 but we should not rely on this but using system specific sysconf() function, after that the code determine struct iovec array and declare it as VLA and loop to write or read data until all data has been processed.
unsigned len;
long iovcnt, iovcnt_max;
iovcnt_max = sysconf(_SC_IOV_MAX);
/* Determine how many part of data to be written */
while (len > 0) {
iovcnt = len >= iovcnt_max ? iovcnt_max : len;
struct iovec iov[iovcnt];
/* Initialize iov's members, process with readv() or writev() */
len -= iovcnt;
}
The above code first determine maximum allowed size of iovcnt, in Linux this value is 1024 but we should not rely on this but using system specific sysconf() function, after that the code determine struct iovec array and declare it as VLA and loop to write or read data until all data has been processed.
Sunday, June 12, 2011
no shell: Permission denied
Last night I was working to copy the Fedora 15 (Livelock) filesystem into another filesystem, the reason is I want bigger filesystem space. Created a ext4 filesystem for that after I failed with btrfs, shit, I will working with that next time.
So here the mighty command that did the magic, both of the filesystem is ext4 and mounted, the cp's -p option is to preverse file's mode, ownership and timestamp while copying.
cp -rp /mnt/livelock/* /mnt/new-livelock
Boot the new filesystem and I got this when logging into bash.
no shell: Permission denied
I did regular procedure (ask uncle Google), someone at Fedora Forum got this problem and answered. It's about SELinux. SELinux's file labeling mechanism might intended to identify file changes outside its control. The solution is to re-labeling the new filesystem's contents or just disable SELinux. Option 1 is fine for me, remount the new filesystem and issue
touch /mnt/new-livelock/.autorelabel
SELinux will auto-relabel filesystem contents and I got new Livelock that has bigger space.
So here the mighty command that did the magic, both of the filesystem is ext4 and mounted, the cp's -p option is to preverse file's mode, ownership and timestamp while copying.
cp -rp /mnt/livelock/* /mnt/new-livelock
Boot the new filesystem and I got this when logging into bash.
no shell: Permission denied
I did regular procedure (ask uncle Google), someone at Fedora Forum got this problem and answered. It's about SELinux. SELinux's file labeling mechanism might intended to identify file changes outside its control. The solution is to re-labeling the new filesystem's contents or just disable SELinux. Option 1 is fine for me, remount the new filesystem and issue
touch /mnt/new-livelock/.autorelabel
SELinux will auto-relabel filesystem contents and I got new Livelock that has bigger space.
Thursday, April 28, 2011
Asterisk Notes
Simple call file contents
Channel: Local@s/default
Callerid: 911
Extension: 12345
Then move the file to /var/spool/asterisk/outgoing (not by copying it) to make a call to default channel.
Creating an extension
[default]
exten => 12345,1,Answer()
exten => 12345,n,Wait(0.5)
exten => 12345,n,AGI(demo)
exten => 12345,n,Hangup()
This will create extension number 12345 at default channel, when dialled it will excecute an AGI file.
Connect to a SIP account
Edit /etc/asterisk/sip.conf and enter the registration information. For this example, I will add SIP server 192.168.1.100 with extension 12345 to be dialled when the extension is called, remember that 12345 must be already defined.
register => username:password@192.168.1.100/12345
SIP server
First create the SIP account, in this example account will use user extension context.
[sip_user]
type=peer
username=sip_user
secret=1234
host=dynamic
context=user
then register it.
register => sip_user:1234@192.168.24.203
Channel: Local@s/default
Callerid: 911
Extension: 12345
Then move the file to /var/spool/asterisk/outgoing (not by copying it) to make a call to default channel.
Creating an extension
[default]
exten => 12345,1,Answer()
exten => 12345,n,Wait(0.5)
exten => 12345,n,AGI(demo)
exten => 12345,n,Hangup()
This will create extension number 12345 at default channel, when dialled it will excecute an AGI file.
Connect to a SIP account
Edit /etc/asterisk/sip.conf and enter the registration information. For this example, I will add SIP server 192.168.1.100 with extension 12345 to be dialled when the extension is called, remember that 12345 must be already defined.
register => username:password@192.168.1.100/12345
SIP server
First create the SIP account, in this example account will use user extension context.
[sip_user]
type=peer
username=sip_user
secret=1234
host=dynamic
context=user
then register it.
register => sip_user:1234@192.168.24.203
Thursday, April 14, 2011
Beside to clone the kernel development tree directly from its git repository, I want to create repository from a stable kernel and its patches, I wil
Beside to clone the kernel development tree directly from its git repository,
I want to create repository from a stable kernel and its patches, I will have
commit for each subversion patch. The last stable kernel at this time is 2.6.38.
First download the 2.6.38 first release (not the subversion releases) named
linux-2.6.38.tar.bz2, extract it with (my favourite bzip2 - tar style)
$ bzip2 -dc linux-2.6.38.tar.bz2 | tar xf -
Initialize git repository, add files and do initial commit.
$ cd linux-2.6.38
$ git init && git add .
$ git commit -m 'Linux 2.6.38'
Time to download the patches, please note that the kernel patch system is not a
increment patch, this means when we got version 2.6.38.3 patch this must be
applied to the first version in this case 2.6.38, not any of its subversion, eg.
2.6.38.2 or 2.6.38.1. At this time, I have these following patch files
patch-2.6.38.1.bz2
patch-2.6.38.2.bz2
After we got out desired patches, so now lets create another branch for patching
purposes, still at our master branch.
$ git branch 2.6.38
$ git branch 2.6.38.1
$ git checkout 2.6.38.1
Issue patch command with (also my favourite bzip2 - patch command style)
$ bzip2 -dc /path_to/patch-2.6.38.1.bz2 | patch -p1
$ git commit -m 'Linux 2.6.38.1'
Now we have 2.6.38.1 version at 2.6.38.1 branch, then lets create 2.6.38.2
branch for 2.6.38.2 patch as well, remember that we must have first version to
apply a patch, so create this branch based the first version branch.
$ git checkout 2.6.38
$ git branch 2.6.38.2
$ bzip2 -dc /path_to/patch-2.6.38.2.bz2 | patch -p1
$ git commit -m 'Linux 2.6.38.2'
Lets describe what we have in our repository, we already have 4 branches with
its branch's name as its version, except for master branch, it has 2.6.38
version. I want to have each version has its commit on the master branch, but I
don't have increment path for version 2.6.38.1 to 2.6.38.2, it is impossible to
just merging 2.6.38.1 and 2.6.38.2 branch, so we must result a diff file from
version 2.6.38.1 to 2.6.38.2, those commands simply do the magic.
$ git checkout 2.6.38.2
$ mkdir /path_to/2.6.38.2
$ cp -r . /path_to/2.6.38.2/
$ git checkout 2.6.38.1
$ diff -ur . /patch_to/2.6.38.2 | bzip2 -zc > /path_to/patch-inc-2.6.38.2.bz2
The 2.6.38.1 to 2.6.38.2 patch is now generated in bz2 format, this an
increament patch, we can now apply this patch to the master branch.
$ git checkout master
$ bzip2 -dc /path_to/patch-inc-2.6.38.2.bz2 | patch -p1
$ git commit -m 'Linux-2.6.38.2'
$ git log
As you can see the master branch log is now have increment version for each
commit, this will be helpfull if we want to trace patches for every subversion.
I want to create repository from a stable kernel and its patches, I will have
commit for each subversion patch. The last stable kernel at this time is 2.6.38.
First download the 2.6.38 first release (not the subversion releases) named
linux-2.6.38.tar.bz2, extract it with (my favourite bzip2 - tar style)
$ bzip2 -dc linux-2.6.38.tar.bz2 | tar xf -
Initialize git repository, add files and do initial commit.
$ cd linux-2.6.38
$ git init && git add .
$ git commit -m 'Linux 2.6.38'
Time to download the patches, please note that the kernel patch system is not a
increment patch, this means when we got version 2.6.38.3 patch this must be
applied to the first version in this case 2.6.38, not any of its subversion, eg.
2.6.38.2 or 2.6.38.1. At this time, I have these following patch files
patch-2.6.38.1.bz2
patch-2.6.38.2.bz2
After we got out desired patches, so now lets create another branch for patching
purposes, still at our master branch.
$ git branch 2.6.38
$ git branch 2.6.38.1
$ git checkout 2.6.38.1
Issue patch command with (also my favourite bzip2 - patch command style)
$ bzip2 -dc /path_to/patch-2.6.38.1.bz2 | patch -p1
$ git commit -m 'Linux 2.6.38.1'
Now we have 2.6.38.1 version at 2.6.38.1 branch, then lets create 2.6.38.2
branch for 2.6.38.2 patch as well, remember that we must have first version to
apply a patch, so create this branch based the first version branch.
$ git checkout 2.6.38
$ git branch 2.6.38.2
$ bzip2 -dc /path_to/patch-2.6.38.2.bz2 | patch -p1
$ git commit -m 'Linux 2.6.38.2'
Lets describe what we have in our repository, we already have 4 branches with
its branch's name as its version, except for master branch, it has 2.6.38
version. I want to have each version has its commit on the master branch, but I
don't have increment path for version 2.6.38.1 to 2.6.38.2, it is impossible to
just merging 2.6.38.1 and 2.6.38.2 branch, so we must result a diff file from
version 2.6.38.1 to 2.6.38.2, those commands simply do the magic.
$ git checkout 2.6.38.2
$ mkdir /path_to/2.6.38.2
$ cp -r . /path_to/2.6.38.2/
$ git checkout 2.6.38.1
$ diff -ur . /patch_to/2.6.38.2 | bzip2 -zc > /path_to/patch-inc-2.6.38.2.bz2
The 2.6.38.1 to 2.6.38.2 patch is now generated in bz2 format, this an
increament patch, we can now apply this patch to the master branch.
$ git checkout master
$ bzip2 -dc /path_to/patch-inc-2.6.38.2.bz2 | patch -p1
$ git commit -m 'Linux-2.6.38.2'
$ git log
As you can see the master branch log is now have increment version for each
commit, this will be helpfull if we want to trace patches for every subversion.
Saturday, April 09, 2011
Local Kernel Repository
Beside to clone the kernel development tree directly from its git repository, I want to create repository from a stable kernel and its patches, I will have commit for each subversion patch. The last stable kernel at this time is 2.6.38.
First download the 2.6.38 first release (not the subversion releases) named linux-2.6.38.tar.bz2, extract it with (my favourite bzip2 - tar style)
$ bzip2 -dc linux-2.6.38.tar.bz2 | tar xf -
Initialize git repository, add files and do initial commit.
$ cd linux-2.6.38
$ git init && git add .
$ git commit -m 'Linux 2.6.38'
Time to download the patches, please note that the kernel patch system is not a increment patch, this means when we got version 2.6.38.3 patch this must be applied to the first version in this case 2.6.38, not any of its subversion, eg. 2.6.38.2 or 2.6.38.1. At this time, I have these following patch files
patch-2.6.38.1.bz2
patch-2.6.38.2.bz2
After we got out desired patches, so now lets create another branch for patching purposes, still at our master branch.
$ git branch 2.6.38
$ git branch 2.6.38.1
$ git checkout 2.6.38.1
Issue patch command with (also my favourite bzip2 - patch command style)
$ bzip2 -dc /path_to/patch-2.6.38.1.bz2 | patch -p1
$ git commit -m 'Linux 2.6.38.1'
Now we have 2.6.38.1 version at 2.6.38.1 branch, then lets create 2.6.38.2 branch for 2.6.38.2 patch as well, remember that we must have first version to apply a patch, so create this branch based the first version branch.
$ git checkout 2.6.38
$ git branch 2.6.38.2
$ bzip2 -dc /path_to/patch-2.6.38.2.bz2 | patch -p1
$ git commit -m 'Linux 2.6.38.2'
Lets describe what we have in our repository, we already have 4 branches with its branch's name as its version, except for master branch, it has 2.6.38 version. I want to have each version has its commit on the master branch, but I don't have increment path for version 2.6.38.1 to 2.6.38.2, it is impossible to just merging 2.6.38.1 and 2.6.38.2 branch, so we must result a diff file from version 2.6.38.1 to 2.6.38.2, those commands simply do the magic.
$ git checkout 2.6.38.2
$ mkdir /path_to/2.6.38.2
$ cp -r . /path_to/2.6.38.2/
$ git checkout 2.6.38.1
$ diff -ur . /patch_to/2.6.38.2 | bzip2 -zc > /path_to/patch-inc-2.6.38.2.bz2
The 2.6.38.1 to 2.6.38.2 patch is now generated in bz2 format, this an increament patch, we can now apply this patch to the master branch.
$ git checkout master
$ bzip2 -dc /path_to/patch-inc-2.6.38.2.bz2 | patch -p1
$ git commit -m 'Linux-2.6.38.2'
$ git log
As you can see the master branch log is now have increment version for each commit, this will be helpfull if we want to trace patches for every subversion.
First download the 2.6.38 first release (not the subversion releases) named linux-2.6.38.tar.bz2, extract it with (my favourite bzip2 - tar style)
$ bzip2 -dc linux-2.6.38.tar.bz2 | tar xf -
Initialize git repository, add files and do initial commit.
$ cd linux-2.6.38
$ git init && git add .
$ git commit -m 'Linux 2.6.38'
Time to download the patches, please note that the kernel patch system is not a increment patch, this means when we got version 2.6.38.3 patch this must be applied to the first version in this case 2.6.38, not any of its subversion, eg. 2.6.38.2 or 2.6.38.1. At this time, I have these following patch files
patch-2.6.38.1.bz2
patch-2.6.38.2.bz2
After we got out desired patches, so now lets create another branch for patching purposes, still at our master branch.
$ git branch 2.6.38
$ git branch 2.6.38.1
$ git checkout 2.6.38.1
Issue patch command with (also my favourite bzip2 - patch command style)
$ bzip2 -dc /path_to/patch-2.6.38.1.bz2 | patch -p1
$ git commit -m 'Linux 2.6.38.1'
Now we have 2.6.38.1 version at 2.6.38.1 branch, then lets create 2.6.38.2 branch for 2.6.38.2 patch as well, remember that we must have first version to apply a patch, so create this branch based the first version branch.
$ git checkout 2.6.38
$ git branch 2.6.38.2
$ bzip2 -dc /path_to/patch-2.6.38.2.bz2 | patch -p1
$ git commit -m 'Linux 2.6.38.2'
Lets describe what we have in our repository, we already have 4 branches with its branch's name as its version, except for master branch, it has 2.6.38 version. I want to have each version has its commit on the master branch, but I don't have increment path for version 2.6.38.1 to 2.6.38.2, it is impossible to just merging 2.6.38.1 and 2.6.38.2 branch, so we must result a diff file from version 2.6.38.1 to 2.6.38.2, those commands simply do the magic.
$ git checkout 2.6.38.2
$ mkdir /path_to/2.6.38.2
$ cp -r . /path_to/2.6.38.2/
$ git checkout 2.6.38.1
$ diff -ur . /patch_to/2.6.38.2 | bzip2 -zc > /path_to/patch-inc-2.6.38.2.bz2
The 2.6.38.1 to 2.6.38.2 patch is now generated in bz2 format, this an increament patch, we can now apply this patch to the master branch.
$ git checkout master
$ bzip2 -dc /path_to/patch-inc-2.6.38.2.bz2 | patch -p1
$ git commit -m 'Linux-2.6.38.2'
$ git log
As you can see the master branch log is now have increment version for each commit, this will be helpfull if we want to trace patches for every subversion.
Thursday, November 25, 2010
WAFER-LX800 as TCT board
Today I managed to configure IEI WAFER LX-800 board, the most important thing that the board has AMD Geode LX800 500MHz processor and 8 RS-232 port, it will also has to support PM-1028 multi-port PC-104 card.
The board has a configurable IO address at it's BIOS that need to be adjusted in order to make the PM-1028 work, so here the configuration.
WAFER LX2-800 IT8888 ISA Decode IO
----------------------------------
Decode I/O Space 1 [Enabled]
Decode I/O Speed 1 [Slow Speed]
Decode I/O Addr. 1 [15:0] [0200]
Decode I/O Size 1 [ 64 Bytes]
The 64 bytes size means that address range that PM-1028 used, the PCM-1028 multi-port module has 200H - 238H address range by default so 64 bytes will more than enough and it is the only option after 32 bytes size.
I also configure the PM-1028 multi-port to share one IRQ by using IRQ 5.
The Debian Lenny doesn't provide GEODE Xorg chipset driver by dafault. The package was named xserver-xorg-video-geode, without it the X server will fail to run no matter how the X configuration file is configured.
The board has a configurable IO address at it's BIOS that need to be adjusted in order to make the PM-1028 work, so here the configuration.
WAFER LX2-800 IT8888 ISA Decode IO
----------------------------------
Decode I/O Space 1 [Enabled]
Decode I/O Speed 1 [Slow Speed]
Decode I/O Addr. 1 [15:0] [0200]
Decode I/O Size 1 [ 64 Bytes]
The 64 bytes size means that address range that PM-1028 used, the PCM-1028 multi-port module has 200H - 238H address range by default so 64 bytes will more than enough and it is the only option after 32 bytes size.
I also configure the PM-1028 multi-port to share one IRQ by using IRQ 5.
The Debian Lenny doesn't provide GEODE Xorg chipset driver by dafault. The package was named xserver-xorg-video-geode, without it the X server will fail to run no matter how the X configuration file is configured.
Tuesday, November 09, 2010
Repairing TCT CF disk
The TCT uses Compact Flash (CF) as it's storage device, the CF technology is cheap now. Depends on CF quality, CF operate in variety of speed, some well known manufacturer produce high-speed transfer rate CF. TCT uses Sandisk Ultra CF which expected to work at 15MB/s theoretically. Like another flash-based memory that use NAND, beside it has write cycle endurance it also being sensitive with electro static and improper handle. Many TCT's CF were suffer from this, fortunately, this problem didn't affect all memory part of the CF, usually errors only located on several block segment.
First for all notice that in this writing, the CF has master disk with device's name /dev/sdc, to diagnose the bad block, we need to scan the broken CF then it should show up some warnings, maybe something like these
#e2fsck /dev/sdc1
...
Buffer I/O error on device sdc, logical block 1082045
end_request: I/O error, dev sdc, sector 1082045
Buffer I/O error on device sdc, logical block 1082050
end_request: I/O error, dev sdc, sector 1082050
...
Now we know the damaged block, with fdisk we can create a partition with this trick.
Let assume the CF has 1964088 logical block, we noticed in above e2fsck log that blocks upto 1082044 were unusable, we can safely create a partition which has about 1082044 logical block by set the last logical block equal or less than 1082044.
#fdisk /dev/sdc
Command (m for help): u
Changing display/entry units to sectors
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (62-15761087, default 62):
Using default value 62
Last sector, +sectors or +size{K,M,G} (62-1964088, default 1964088): 1082044
The partition table has been altered!
After the new partition has been created, first make sure the partition boot flag also already been activated with fdisk, then create the root filesystem of type ext3 with
#mke2fs -j /dev/sdc1
We need to extracting tar.gzip'ed TCT root filesystem to the partition with
#mount -t ext3 /dev/sdc1 /mnt
#tar xzf tct-rootfs.tar.gz -C /mnt
The tar.gzip'ed root filesystem created by compressing a previously working filesystem, assuming that the current working directory is the root directory of working filesystem.
#tar czf /path/to/save/tct-rootfs.gz .
Now we have a working root filesystem, but one feature that is still missing is bootloader, using GRUB is very complicated, why not use a small and simple bootloader EXTLINUX, from this time the TCT system should use EXTLINUX instead GRUB.
#extlinux --install /mnt/boot
#cat /usr/lib/syslinux/mbr.bin > /dev/sdc
Create a simple configuration file, similar to syslinux configuration file. Use blkid to retrieve device UUID.
# /boot/extlinux.conf
LABEL Lenny
KERNEL /vmlinuz
APPEND initrd=/initrd.img root=UUID=06e8bee6-ad09-41e8-8290-87ef6aa71df8 ro quiet vga=0x314 8250.nr_uarts=12
TIMEOUT 20
PROMPT 0
Unmount and test for it, hopefully it should works!
When working with this problem, I made stupid thing by rm -rf /media, this fuck my important data.
Thursday, September 02, 2010
Improving the TCT Tool
This previous post describes how TCT Tool was written, It is using POSIX Message Queue to exchange data. Basic on work, TCT Tool's message queue implementation almost work, only the main problem is the sender could read it's sent data, this sound weird because the TCT Tool would read it's data that intended to be read by the TCT. On the Toll, this problem hung up the TCT.
I change the IPC implementation using UNIX Domain Socket, first with datagram socket, the problem was just like the message queue, the TCT Tool receive it's sent data. The TCT Tool was not work until I use reliable stream socket, here the source code.
I change the IPC implementation using UNIX Domain Socket, first with datagram socket, the problem was just like the message queue, the TCT Tool receive it's sent data. The TCT Tool was not work until I use reliable stream socket, here the source code.
Wednesday, August 25, 2010
Linus uses Fedora 12
Monday, August 16, 2010
ARM based Notebook

This is maybe a ARM week for me, Trio my office friend told me about this notebook, produced by an Indonesian made Notebook vendor ELEVO. It is using ARM9-533 Mhz processor comes with 10" display, 128 MB RAM, 2 GB Nano Flash storage, 802.11g Network Adapter, Built-in camera, 3 USB port, 1 SD card port. The more exciting thing is it's prices, sold only for about Rp.1.398.000. The ELEVO ARM based notebook series come with 2 model, the R7 and R10, the difference between them is only the display size.
I'm very interesting to buy the R10, yes it is! it is based on ARM board, it is a `litle' unique processor for notebook, isn't it?. The bundled OS is Windows CE 6.0 but i want to make it Linux heh.
Wednesday, August 11, 2010
QEMU emulated ARM System
This is my notes basic on my own expirement (alone of-course) to build Linux system on QEMU emulated ARM Versatile board. I use Linux 2.6.27.49 and BusyBox 1.17.1. My host is a x86-PC, run Fedora 12 (Constantine), the Fedora's developer fortunately provide ARM toolchain repository in this page. Okay here my steps
Getting the Toolchains
Activate the repo by adding these lines to /etc/yum.conf
[fedora-arm-toolchain]
name=Fedora ARM Toolchain
failovermethod=priority
baseurl=http://ftp.linux.org.uk/pub/linux/arm/fedora/cross/latest/i386/
enabled=1
gpgcheck=0
After this, we are going to install the toolchains. Issuing this command will also install all of it's dependencies.
# yum install armv5tel-redhat-linux-gnueabi-gcc
and tell the world for our new toolchain's family commands
$ export ARM_TOOLCHAIN=armv5tel-redhat-linux-gnueabi-
Preparing BusyBox and the initramfs
It's time to configure BusyBox, feel free to customize for your own configuration, all configuration below is only for my own experiment.
$ make ARCH=arm defconfig
$ make ARCH=arm CROSS_COMPILE=$ARM_TOOLCHAIN install
Goto BusyBox install directory to create our rootfs for initramfs, create these following directories and files
# cd _install
# mkdir -p etc/init.d/
# mkdir proc/
Here a simple /etc/inittab file
# /etc/inittab
::sysinit:/etc/init.d/rcS
::respawn:-/bin/sh
and a simple /etc/init.d/rcS file
#!/bin/sh
echo "Mounting /proc file system"
mount -t procfs /proc
echo
echo "Welcome to `uname -rsm`"
echo
Create minimal device files
# mknod dev/tty c 5 0
# mknod dev/console c 5 1
And create the rootfs archive
# ln -sf bin/busybox init
$ find . | cpio -o -H newc | gzip > /path/to/rootfs.cpio.gz
Build the Kernel
Prepare our kernel, we use initramfs support through the kernel config. This page contains great documentation for initramfs and rootfs creation.
IMPORTANT since we are using toolchain that support ARM ABI (EABI), don't forget to enable this in kernel configuration called CONFIG_EABI, otherwise you will get "Kernel panic not syncing" error because different ABI version between the kernel and the toolchains.
You will need to enable initramfs/initrd support in kernel configuration and point your rootfs archive, that is our rootfs.cpio.gz
$ make ARCH=arm versatile_defconfig
$ make ARCH=arm menuconfig
$ make ARCH=arm CROSS_COMPILE=$ARM_TOOLCHAIN zImage
After compiling, lets try and pray for our new ARM Versatile's kernel, testing the kernel with
$ qemu-system-arm -M versatilepb -kernel /path/to/zImage
If everything okay, you would see the kernel is boot up and bring the init process, congrats! your kernel is running, you are probably taken to the shell and playing with our very simple and emulated embedded system.
to be hardly re-written...
Getting the Toolchains
Activate the repo by adding these lines to /etc/yum.conf
[fedora-arm-toolchain]
name=Fedora ARM Toolchain
failovermethod=priority
baseurl=http://ftp.linux.org.uk/pub/linux/arm/fedora/cross/latest/i386/
enabled=1
gpgcheck=0
After this, we are going to install the toolchains. Issuing this command will also install all of it's dependencies.
# yum install armv5tel-redhat-linux-gnueabi-gcc
and tell the world for our new toolchain's family commands
$ export ARM_TOOLCHAIN=armv5tel-redhat-linux-gnueabi-
Preparing BusyBox and the initramfs
It's time to configure BusyBox, feel free to customize for your own configuration, all configuration below is only for my own experiment.
$ make ARCH=arm defconfig
$ make ARCH=arm CROSS_COMPILE=$ARM_TOOLCHAIN install
Goto BusyBox install directory to create our rootfs for initramfs, create these following directories and files
# cd _install
# mkdir -p etc/init.d/
# mkdir proc/
Here a simple /etc/inittab file
# /etc/inittab
::sysinit:/etc/init.d/rcS
::respawn:-/bin/sh
and a simple /etc/init.d/rcS file
#!/bin/sh
echo "Mounting /proc file system"
mount -t procfs /proc
echo
echo "Welcome to `uname -rsm`"
echo
Create minimal device files
# mknod dev/tty c 5 0
# mknod dev/console c 5 1
And create the rootfs archive
# ln -sf bin/busybox init
$ find . | cpio -o -H newc | gzip > /path/to/rootfs.cpio.gz
Build the Kernel
Prepare our kernel, we use initramfs support through the kernel config. This page contains great documentation for initramfs and rootfs creation.
IMPORTANT since we are using toolchain that support ARM ABI (EABI), don't forget to enable this in kernel configuration called CONFIG_EABI, otherwise you will get "Kernel panic not syncing" error because different ABI version between the kernel and the toolchains.
You will need to enable initramfs/initrd support in kernel configuration and point your rootfs archive, that is our rootfs.cpio.gz
$ make ARCH=arm versatile_defconfig
$ make ARCH=arm menuconfig
$ make ARCH=arm CROSS_COMPILE=$ARM_TOOLCHAIN zImage
After compiling, lets try and pray for our new ARM Versatile's kernel, testing the kernel with
$ qemu-system-arm -M versatilepb -kernel /path/to/zImage
If everything okay, you would see the kernel is boot up and bring the init process, congrats! your kernel is running, you are probably taken to the shell and playing with our very simple and emulated embedded system.
to be hardly re-written...
Saturday, August 07, 2010
Debian Squeeze frozen
Menjelang DebConf10, yang saat ini diselenggarakan di New York, para developer Debian mengumumkan bahwa Debian 6.0 "Squeeze" telah memasuki tahap frozen. Ini berarti pengembangan selanjutnya dari versi berikutnya telah berada pada babak baru dimana lebih fokus ke perbaikan bug dan membenahi distro untuk tahap release.
Freeze berarti bahwa saat ini memungkinkan untuk melihat apa yang akan Debian 6.0 tawarkan. Menurut pemberitahuan, "Squeeze" akan menghadirkan kernel Linux 2.6.32 pada instalasi standar di semua arsitektur. Untuk lingkungan desktop, "Squeeze" akan menyediakan KDE 4.4.5, GNOME 2.30.0, LXDE 0.5.0, XFCE 4.6.2, yang didukung oleh X.org 7.5 dan termasuk OpenOffice 3.2.1. Aplikasi server seperti Apache 2.2.16, PHP 5.3.2, MySQL 5.1.48, PostgreSQL 8.4.4 dan Samba 3.4 akan turut dimasukkan. Pengembang akan menemukan interpreter dan compiler untuk Python 2.6 and 3.1, Perl 5.10, GHC 6.12 dan GCC 4.4 yang disertakan.
"Squeeze" juga akan disertakan dengan beberapa varian versi yang berasal dari kernel FreeBSD sistem 32 dan 64-bit x86 menggunakan GNU libc dan GNU userland. Versi ini terlihat seperti "review teknologi" tapi para pengembang yakin bahwa ini adalah pertama kali sebuah distro Linux dikembangkan untuk menggunakan kernel non-Linux.
Sumber: H-Online
Freeze berarti bahwa saat ini memungkinkan untuk melihat apa yang akan Debian 6.0 tawarkan. Menurut pemberitahuan, "Squeeze" akan menghadirkan kernel Linux 2.6.32 pada instalasi standar di semua arsitektur. Untuk lingkungan desktop, "Squeeze" akan menyediakan KDE 4.4.5, GNOME 2.30.0, LXDE 0.5.0, XFCE 4.6.2, yang didukung oleh X.org 7.5 dan termasuk OpenOffice 3.2.1. Aplikasi server seperti Apache 2.2.16, PHP 5.3.2, MySQL 5.1.48, PostgreSQL 8.4.4 dan Samba 3.4 akan turut dimasukkan. Pengembang akan menemukan interpreter dan compiler untuk Python 2.6 and 3.1, Perl 5.10, GHC 6.12 dan GCC 4.4 yang disertakan.
"Squeeze" juga akan disertakan dengan beberapa varian versi yang berasal dari kernel FreeBSD sistem 32 dan 64-bit x86 menggunakan GNU libc dan GNU userland. Versi ini terlihat seperti "review teknologi" tapi para pengembang yakin bahwa ini adalah pertama kali sebuah distro Linux dikembangkan untuk menggunakan kernel non-Linux.
Sumber: H-Online
Friday, June 25, 2010
setuid
The setuid system call will set effective user IDs for the calling process. Some system call require privileged user. Linux implements POSIX 1e for capabilities since Kernel 2.2. Take a look the ping program which create raw socket that require CAP_SYS_RAW capabilities. Here the permission attributes for this program.
[ajhwb@ajhwb-constantine ~]$ ls -l $(which ping)
-rwsr-xr-x. 1 root root 41976 2010-05-11 21:03 /bin/ping
[ajhwb@ajhwb-constantine ~]$ stat --printf="owner permission:%a uid:%U gid:%G\n" $(which ping)
owner permission:4755 uid:root gid:root
Take a look for owner permission mode, rws (4755) define a setuid to owner (root) for calling process. Unprivileged user can run this process as root privilege that is to create the raw socket. So, any setuid program must be carefully designed to prevent exploitation.
Linux capabilities FAQ: http://pastebin.com/raw.php?i=3SbfSN8s
[ajhwb@ajhwb-constantine ~]$ ls -l $(which ping)
-rwsr-xr-x. 1 root root 41976 2010-05-11 21:03 /bin/ping
[ajhwb@ajhwb-constantine ~]$ stat --printf="owner permission:%a uid:%U gid:%G\n" $(which ping)
owner permission:4755 uid:root gid:root
Take a look for owner permission mode, rws (4755) define a setuid to owner (root) for calling process. Unprivileged user can run this process as root privilege that is to create the raw socket. So, any setuid program must be carefully designed to prevent exploitation.
Linux capabilities FAQ: http://pastebin.com/raw.php?i=3SbfSN8s
Wednesday, June 16, 2010
TCT Tool
TCT Tool is a application that do some privileged tasks in the TCT machine. By default, TCT run in non-privileged mode so it can't do for example sending ioctl to the ethernet driver, update the system time, and many more. They use POSIX message queue for communication. Thanks for Glynn Clements at linux-c-programming who helped me out with message queue descriptor permission.
http://pastebin.com/raw.php?i=x4X6G4uf
http://pastebin.com/raw.php?i=x4X6G4uf
Tuesday, June 01, 2010
Fedora 13 (Goddard)

Fedora 13 is out now, most significant features are a new live installer, color management and 3D View based on GNOME Shell. Use Kernel 2.6.33, X.Org X Server 1.8.0, GNOME 2.30, Mozilla Firefox 3.6.3 and many more.
New included applications are Shotwell Photo Manager, Planner Project Management, pino (Twitter and Identi.ca client), Déjà Dup backup utility, Simple Scan and new Disk Utility.
Saturday, May 08, 2010
Web server's DocumentRoot
Actually this is a old problem for me, i can't set Apache or Lighttpd document root's to a mounted FAT filesystem, i got
DocumentRoot must be a directory
After googling for some pages, i found that SELinux cause this. Then disable SELinux by editing /etc/selinux/config file on Fedora 12, set mounted device with Apache's or Lighttpd's UID and GID.
[root@thinkpad /]# cat /etc/passwd | grep lighttpd
lighttpd:x:491:480:lighttpd web server:/var/www/lighttpd:/sbin/nologin
[root@thinkpad /]# mount -t /dev/the_device_name -t vfat -o rw,nosuid,nodev,uid=491,gid=480 /mount_place
Small changes to appropriate server's configuration, and the web server are ready to be my local repository.
DocumentRoot must be a directory
After googling for some pages, i found that SELinux cause this. Then disable SELinux by editing /etc/selinux/config file on Fedora 12, set mounted device with Apache's or Lighttpd's UID and GID.
[root@thinkpad /]# cat /etc/passwd | grep lighttpd
lighttpd:x:491:480:lighttpd web server:/var/www/lighttpd:/sbin/nologin
[root@thinkpad /]# mount -t /dev/the_device_name -t vfat -o rw,nosuid,nodev,uid=491,gid=480 /mount_place
Small changes to appropriate server's configuration, and the web server are ready to be my local repository.
Subscribe to:
Posts (Atom)