How to fix wlanO not found

The problem statement is while doing an *ip a* on the terminal and its output doesn’t show the wireless device, like below:

wlan0_not_showing_2017-01-27-22-17-20

The dmesg says like this below:

iwlwifi_firmware_not_found_2017-01-28-04-20-26

Let me cross check that file is present in the system or not,  just like below:

firmware_file_present_2017-01-28-04-23-41

So, it is very much seated there, where it suppose to be  Well, that trigger me trip to visit some kernel config variables, like below:

kernel_var_2017-01-28-04-31-25

It looks fine, then?? well, that warrant few more checks, well I made some trip to *gentoo forum* to know what is missing. And someone in the closed thread mentioned that The variable in question is CONFIG_IWLWIFI which is recommended =m and that necessarily meant I have to recompile the kernel one more time with that variable set to the module in the kernel.

Next, I went ahead and compile the kernel with that mentioned variable as the module. Okay, I have rebooted my machine and here is the outcome,

wlan0_showing_2017-01-28-05-14-35

Cool, but why we have to turn it to a module within the kernel than just straight built into the kernel not showing the device ?? The reason, by the time kernel boot and the firmware file, reside on the filesystem not yet read so it was missing.

Hope this will help.

 

 

 

 

GNU/Linux container internals aka Cgroups and Namespaces

In this post, I will shed some light on the GNU/Linux container internals.Basically, what is underlying technology driving that. Here we go,without much ado:

What is GNU/Linux Container?

Is an operating system-level virtualization method for running multiple isolated GNU/Linux systems (containers) on a single control host (LXC host). It does not provide a virtual machine, but rather provides a virtual environment that has its own CPU, memory, block I/O, network, etc. space. This is provided by cgroups ( we will give details about it later) features in Linux kernel on LXC host. It is similar to a chroot, but offers much more isolation.
Before I give you the information about LXC , let me make you aware of the two crucial aspect of it ,namely cgroups and namespace.

Cgroups AKA Control Group:

It is a Linux kernel feature to limit, police and account the resource usage of certain processes (actually process groups).

  • Create and manage them on the fly using tools like cgcreate, cgexec, cgclassify etc
  • The “rules engine daemon”, to automatically move certain users/groups/commands to groups (/etc/cgrules.conf and /usr/lib/systemd/system/cgconfig.service)
  • Through other software such as (LXC) virtualization
  • (control groups) subsystem is a Resource Management solution providing a generic process-grouping framework
  • Cgroups provide resource management solution (handling groups)

For Cgroups implementation need a few simple hook into rest of the kernel,namely :

a) For each process :/proc/pid/cgroup

b) System-wide: /proc/cgroup
But we are lucky enough that, newer distribution running systemd comes along with all those tweak by default,so don’t sweat.

A little internals does not harm!! here we go :

First,cgroups use VFS(virtual file systems),all entries created in it ,are not persistent,means deleted on reboot.

Second, all cgroups actions are performed via file systems actions(create/remove directory,reading/writing to the files in it,mounting/mount options).

For example :

cgroup inode_operations for cgroup mkdir/rmdir.

cgroup file_system_type for cgroup mount/unmount.

cgroup file_operations for reading/writing to control files.

Systemd uses control groups only for the process grouping ;not for anything else like allocating resources like block io, bandwidth,etc.

It look something like this :

#subsys_name hierarchy    enabled

cpuset  8    1    1

cpu 3    2    1

cpuacct 3    2    1

blkio   4    2    1

memory  7    2    1

devices 2    41   1

freezer 5    1    1

net_cls 6    1    1

Below are few things you can do with cgroup,provided the library is installed:

Example:

cgcreate -g cpuset:/test

cgset -r cpuset.cpus=1 /test

cgset -r cpuset.mems=0 /test

cgexec -g

I have touched the tip of ice-burg ,if you are really interested to explore more , then you should follow the below mentioned link.

To use the effect of it ,you got to install libcgroup. The best place to know about cgroups is here and here and here  . Please read those mentioned link before to get a thorough understanding of cgroups.

Namespaces:

a)It is light weight process virtualization.

b) Isolation : enable a process or group of process to view the system in different perspective.

c)Much like zones in Solaris.

d)No hypervisor layer(as in OS virtualization like kvm and xen)

There are currently 6 namespaces,those are:

  • mnt(mount points and filesystems)
  • pid(processes)
  • net(network stack)
  • ipc(system v ipc)
  • uts(hostname)
  • user(UIDs)

Namespace first appear in Linux kernel 2.4.19,way back in 2002!!

** Each namespace has a unique inode number.

You need to know which config options are get effected ,while manipulating it(namespace). Here are those :

Kernel config items:

CONFIG_NAMESPACES

CONFIG_UTS_NS

CONFIG_IPC_NS

CONFIG_USER_NS

CONFIG_PID_NS

CONFIG_NET_NS

Each and every option doing the specific duty,as mentioned earlier. And in user space you have two package to play with it,those are :

iproute and util_linux 

Please explore those package in and the offering in detail to work with the above.Plus one has care about below findings:

How to find all existing namespace in GNU/Linux?

If you execute as root,you get the list of attached namespaces of the init process using PID=1.

In order to find other namespaces with attached processes in the system, we use these entries of the PID=1 as a reference. Any process or thread in the system, which has not the same namespace ID as PID=1 is not belonging to the DEFAULT namespace.

Additionally, you find the namespaces created by “ip netns add ” by default in /var/run/netns/ .

Okay, credit has to be given where it’s due……

Rami Rosen was kind enough to provide lots of information about those and most importantly share with public.Thanks Rami!  Here is his paper about it.

Check out this wonderful guide about it at LWN. Equally well written blog about it on opencloudblog and  here .

How docker use namespace,specifically about mount namespace.

Justin Weissig written a wonderful article about cgroups.

A must view place is kernel documentation about cgroups.

Ginny Henningsen and Lenz Grimmer written a magnificent blog at Oracle site.

Hope this will give you heads up.

Cheers!

Implementing Qemu-Kvm on Slackware-13.37

In this article I will show you how you can integrate qemu-kvm into the Slackware OS and utilise it to get other OS up.So, fasten you seat belt for the ride..it might be little bumpy..but we will take it…

Step 1: Get the required source from this site

So, I went ahead and get the required source mentioned in the above mentioned site.

Step 2: Untar it

bhaskar@Slackware_19:26:23_Wed Jun 06:~/Downloads> tar -xvzf qemu-kvm\(1\).tar.gz
qemu-kvm/
qemu-kvm/slack-desc
qemu-kvm/patches/
qemu-kvm/patches/deprecate-time-drift-fix.patch
qemu-kvm/patches/fixup_udev_rules.patch
qemu-kvm/README
qemu-kvm/qemu-kvm.info
qemu-kvm/qemu-kvm.SlackBuild

Step 3: Put the actual source into the previously inflated dir..the execution script look for it in that dir

bhaskar@Slackware_19:26:58_Wed Jun 06:~/Downloads> mv -v qemu-kvm-1.0.1.tar.gz ~/Downloads/qemu-kvm/
`qemu-kvm-1.0.1.tar.gz' -> `/home/bhaskar/Downloads/qemu-kvm/qemu-kvm-1.0.1.tar.gz'

Step 4:Get into the Step 2 inflated dir and execute this script qemu-kvm.SlackBuild

bhaskar@Slackware_19:38:23_Wed Jun 06:~/Downloads/qemu-kvm> sudo ./qemu-kvm.SlackBuild
....
....
....
usr/share/qemu/pxe-eepro100.rom
usr/share/qemu/vgabios-cirrus.bin
usr/share/qemu/linuxboot.bin
usr/share/qemu/vgabios.bin
usr/share/qemu/openbios-sparc32
usr/bin/
usr/bin/qemu-nbd
usr/bin/kvm_stat
usr/bin/qemu-img
usr/bin/qemu-kvm
usr/bin/qemu-io
usr/bin/qemu-ga
etc/
etc/qemu/
etc/qemu/target-x86_64.conf

Slackware package /tmp/qemu-kvm-1.0.1-i486-1_SBo.tgz created.

Step 5: Now get that source implemented into the system by below methods

root@Slackware:/tmp# installpkg qemu-kvm-1.0.1-i486-1_SBo.tgz
Verifying package qemu-kvm-1.0.1-i486-1_SBo.tgz.
Installing package qemu-kvm-1.0.1-i486-1_SBo.tgz:
PACKAGE DESCRIPTION:
# qemu-kvm (Stable branch - KVM requires QEMU)
#
# KVM (Kernel-based Virtual Machine) is a full virtualization solution
# for Linux on x86 hardware containing virtualization extensions
# (Intel VT or AMD-V).
#
# KVM is divided into the KVM-KMOD package (kernel modules) and the
# QEMU-KVM package (slightly modified QEMU) which are both available
# as separate Slackbuilds.
#
Package qemu-kvm-1.0.1-i486-1_SBo.tgz installed.

Step 6: Now time to test it out!

bhaskar@Slackware_19:44:08_Wed Jun 06:~> sudo /sbin/modprobe kvm
bhaskar@Slackware_19:44:21_Wed Jun 06:~> sudo /sbin/modprobe kvm_intel
bhaskar@Slackware_19:44:25_Wed Jun 06:~> whereis lsmod
lsmod: /bin/lsmod /sbin/lsmod /usr/man/man8/lsmod.8.gz /usr/share/man/man8/lsmod.8.gz /usr/X11/man/man8/lsmod.8.gz
bhaskar@Slackware_19:44:32_Wed Jun 06:~> sudo /bin/lsmod | grep kvm
kvm_intel 41712 0
kvm 283908 1 kvm_intel

Step 7: Run against a ISO file of OS

bhaskar@Slackware_20:08:41_Wed Jun 06:~/Downloads> /usr/bin/qemu-kvm -enable-kvm -cdrom /home/bhaskar/Downloads/BT5-GNOME-32.iso

and the outcome is below:

Hope this will help.

Cheers!
Bhaskar

Measuring and monitoring system performances through sysstat

>Being an administrator of a corporation to manage production box is an daunting task.One has to be very much aware what is going on into the box/servers by looking into it through some tools.One important package I am talking about is called “sysstats” ,which has so many important tool to disclose all the information needed by an administrator.

I do not issue any guarantee that this will work for you.

So this article I am using Arch Linux . As it doesn’t come with base installation so I have to get it(sysstat) separately.

bhaskar@bhaskar-laptop_07:05:26_Tue Aug 31:~> sudo pacman -S sysstat
warning: sysstat-9.0.6.1-1 is up to date — reinstalling
resolving dependencies…
looking for inter-conflicts…

Targets (1): sysstat-9.0.6.1-1

Total Download Size: 0.00 MB
Total Installed Size: 1.14 MB

Proceed with installation? [Y/n]

here I said N or no ,because I have already installed it long time back.You see that below:

bhaskar@bhaskar-laptop_07:08:31_Tue Aug 31:~> sudo pacman -Qi sysstat
Name : sysstat
Version : 9.0.6.1-1
URL : http://pagesperso-orange.fr/sebastien.godard/
Licenses : GPL
Groups : None
Provides : None
Depends On : glibc
Optional Deps : tk: to use isag
gnuplot: to use isag
Required By : None
Conflicts With : None
Replaces : None
Installed Size : 1168.00 K
Packager : Sergej Pupykin
Architecture : i686
Build Date : Mon 01 Mar 2010 03:51:14 AM IST
Install Date : Tue 02 Mar 2010 10:10:31 PM IST
Install Reason : Explicitly installed
Install Script : No
Description : A collection of performance monitoring tools

Here are the files installed by the package in the system..

bhaskar@bhaskar-laptop_07:10:35_Tue Aug 31:~> sudo pacman -Ql sysstat
sysstat /etc/
sysstat /etc/cron.daily/
sysstat /etc/cron.daily/sysstat
sysstat /etc/cron.hourly/
sysstat /etc/cron.hourly/sysstat
sysstat /etc/rc.d/
sysstat /etc/rc.d/sysstat
sysstat /etc/sysconfig/
sysstat /etc/sysconfig/sysstat
sysstat /etc/sysconfig/sysstat.ioconf
sysstat /etc/sysstat/
sysstat /etc/sysstat/sysstat
sysstat /usr/
sysstat /usr/bin/
sysstat /usr/bin/iostat
sysstat /usr/bin/isag
sysstat /usr/bin/mpstat
sysstat /usr/bin/pidstat
sysstat /usr/bin/sadf
sysstat /usr/bin/sar
sysstat /usr/lib/
sysstat /usr/lib/sa/
sysstat /usr/lib/sa/sa1
sysstat /usr/lib/sa/sa2
sysstat /usr/lib/sa/sadc
sysstat /usr/share/
sysstat /usr/share/doc/
sysstat /usr/share/doc/sysstat-9.0.6.1/
sysstat /usr/share/doc/sysstat-9.0.6.1/CHANGES
sysstat /usr/share/doc/sysstat-9.0.6.1/COPYING
sysstat /usr/share/doc/sysstat-9.0.6.1/CREDITS
sysstat /usr/share/doc/sysstat-9.0.6.1/FAQ
sysstat /usr/share/doc/sysstat-9.0.6.1/README
sysstat /usr/share/doc/sysstat-9.0.6.1/sysstat-9.0.6.1.lsm
sysstat /usr/share/locale/
sysstat /usr/share/locale/af/
sysstat /usr/share/locale/af/LC_MESSAGES/
sysstat /usr/share/locale/af/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/da/
sysstat /usr/share/locale/da/LC_MESSAGES/
sysstat /usr/share/locale/da/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/de/
sysstat /usr/share/locale/de/LC_MESSAGES/
sysstat /usr/share/locale/de/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/es/
sysstat /usr/share/locale/es/LC_MESSAGES/
sysstat /usr/share/locale/es/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/fi/
sysstat /usr/share/locale/fi/LC_MESSAGES/
sysstat /usr/share/locale/fi/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/fr/
sysstat /usr/share/locale/fr/LC_MESSAGES/
sysstat /usr/share/locale/fr/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/id/
sysstat /usr/share/locale/id/LC_MESSAGES/
sysstat /usr/share/locale/id/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/it/
sysstat /usr/share/locale/it/LC_MESSAGES/
sysstat /usr/share/locale/it/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/ja/
sysstat /usr/share/locale/ja/LC_MESSAGES/
sysstat /usr/share/locale/ja/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/ky/
sysstat /usr/share/locale/ky/LC_MESSAGES/
sysstat /usr/share/locale/ky/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/lv/
sysstat /usr/share/locale/lv/LC_MESSAGES/
sysstat /usr/share/locale/lv/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/mt/
sysstat /usr/share/locale/mt/LC_MESSAGES/
sysstat /usr/share/locale/mt/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/nb/
sysstat /usr/share/locale/nb/LC_MESSAGES/
sysstat /usr/share/locale/nb/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/nl/
sysstat /usr/share/locale/nl/LC_MESSAGES/
sysstat /usr/share/locale/nl/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/nn/
sysstat /usr/share/locale/nn/LC_MESSAGES/
sysstat /usr/share/locale/nn/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/pl/
sysstat /usr/share/locale/pl/LC_MESSAGES/
sysstat /usr/share/locale/pl/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/pt/
sysstat /usr/share/locale/pt/LC_MESSAGES/
sysstat /usr/share/locale/pt/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/pt_BR/
sysstat /usr/share/locale/pt_BR/LC_MESSAGES/
sysstat /usr/share/locale/pt_BR/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/ro/
sysstat /usr/share/locale/ro/LC_MESSAGES/
sysstat /usr/share/locale/ro/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/ru/
sysstat /usr/share/locale/ru/LC_MESSAGES/
sysstat /usr/share/locale/ru/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/sk/
sysstat /usr/share/locale/sk/LC_MESSAGES/
sysstat /usr/share/locale/sk/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/sv/
sysstat /usr/share/locale/sv/LC_MESSAGES/
sysstat /usr/share/locale/sv/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/vi/
sysstat /usr/share/locale/vi/LC_MESSAGES/
sysstat /usr/share/locale/vi/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/zh_CN/
sysstat /usr/share/locale/zh_CN/LC_MESSAGES/
sysstat /usr/share/locale/zh_CN/LC_MESSAGES/sysstat.mo
sysstat /usr/share/locale/zh_TW/
sysstat /usr/share/locale/zh_TW/LC_MESSAGES/
sysstat /usr/share/locale/zh_TW/LC_MESSAGES/sysstat.mo
sysstat /usr/share/man/
sysstat /usr/share/man/man1/
sysstat /usr/share/man/man1/iostat.1.gz
sysstat /usr/share/man/man1/isag.1.gz
sysstat /usr/share/man/man1/mpstat.1.gz
sysstat /usr/share/man/man1/pidstat.1.gz
sysstat /usr/share/man/man1/sadf.1.gz
sysstat /usr/share/man/man1/sar.1.gz
sysstat /usr/share/man/man8/
sysstat /usr/share/man/man8/sa1.8.gz
sysstat /usr/share/man/man8/sa2.8.gz
sysstat /usr/share/man/man8/sadc.8.gz
sysstat /var/
sysstat /var/log/
sysstat /var/log/sa/

Now it puts a crontab entry to run daily on the installed system..although you can control it according your choice..

bhaskar@bhaskar-laptop_07:13:35_Tue Aug 31:/etc/cron.daily> cat sysstat
#!/bin/sh
# Generate a daily summary of process accounting. Since this will probably
# get kicked off in the morning, it would probably be better to run against
# the previous days data.
/usr/lib/sa/sa2 -A &

This package come with so many binary and all of them are very useful tool. I will explain all of them one by one.First tool is callled sar..and it will output like this..

bhaskar@bhaskar-laptop_07:15:59_Tue Aug 31:~> sudo sar
Password:
Linux 2.6.34-ARCH (bhaskar-laptop) 08/31/2010 _i686_ (2 CPU)

06:27:36 AM LINUX RESTART

06:28:02 AM CPU %user %nice %system %iowait %steal %idle
06:38:02 AM all 8.57 0.00 1.80 6.59 0.00 83.04
06:48:02 AM all 22.57 0.00 5.11 5.40 0.00 66.92
06:58:02 AM all 16.56 0.00 5.58 3.81 0.00 74.05
07:08:02 AM all 7.46 0.00 2.79 4.52 0.00 85.23
Average: all 13.79 0.00 3.82 5.08 0.00 77.31

Now bit of explanation is required for the fields it shows which I enumerated below:

Sar is system activity reporter.

%user and %nice refer to your software programs, such as MySQL or Apache.
%system refers to the kernel’s internal workings.
%iowait is time spent waiting for Input/Output, such as a disk read or write. Finally, since the kernel accounts for 100% of the runnable time it can schedule, any unused time goes into %idle.

It come along with another two binary relates sar is called sa1 and sa2.What does this fellows do to sar??

The sa1 script logs sar output into sysstat’s binary log file format, and sa2 reports it back in human readable format.Clear!

And the reports it provide kept in a dir called /var/log/sa and file with date attached to it…

bhaskar@bhaskar-laptop_07:25:28_Tue Aug 31:/var/log/sa> ls
sa23 sa24 sa25 sa30 sa31 sar24 sar30

“-W” this flag to sar shows the swap related activity on the system

bhaskar@bhaskar-laptop_07:31:09_Tue Aug 31:~> sudo sar -W
Password:
Linux 2.6.34-ARCH (bhaskar-laptop) 08/31/2010 _i686_ (2 CPU)

06:27:36 AM LINUX RESTART

06:28:02 AM pswpin/s pswpout/s
06:38:02 AM 0.00 0.00
06:48:02 AM 0.00 0.00
06:58:02 AM 0.03 1.67
07:08:02 AM 0.01 3.20
07:18:02 AM 0.13 4.02
07:28:01 AM 0.12 0.36
Average: 0.05 1.54

-r” option to sar show memory related thig from the system:

bhaskar@bhaskar-laptop_07:37:50_Tue Aug 31:~> sudo sar -r
Linux 2.6.34-ARCH (bhaskar-laptop) 08/31/2010 _i686_ (2 CPU)

06:27:36 AM LINUX RESTART

06:28:02 AM kbmemfree kbmemused %memused kbbuffers kbcached kbcommit %commit
06:38:02 AM 204468 815896 79.96 31784 399596 1412880 43.21
06:48:02 AM 62120 958244 93.91 61984 407388 1566932 47.93
06:58:02 AM 40344 980020 96.05 93368 348428 1622948 49.64
07:08:02 AM 27240 993124 97.33 126952 312652 1576108 48.21
07:18:02 AM 72528 947836 92.89 96988 334604 1454800 44.50
07:28:01 AM 58732 961632 94.24 95268 344540 1486996 45.48
Average: 77572 942792 92.40 84391 357868 1520111 46.49

-b” option shows some paging statistics :

bhaskar@bhaskar-laptop_07:41:19_Tue Aug 31:~> sudo sar -b
Linux 2.6.34-ARCH (bhaskar-laptop) 08/31/2010 _i686_ (2 CPU)

06:27:36 AM LINUX RESTART

06:28:02 AM tps rtps wtps bread/s bwrtn/s
06:38:02 AM 25.49 19.80 5.69 951.22 108.95
06:48:02 AM 35.10 20.35 14.76 259.20 337.45
06:58:02 AM 24.73 16.87 7.86 159.71 230.64
07:08:02 AM 53.55 42.64 10.91 356.85 273.27
07:18:02 AM 61.84 53.96 7.88 477.19 293.56
07:28:01 AM 5.12 1.15 3.96 49.08 74.69
07:38:01 AM 5.75 2.34 3.41 90.68 61.61
Average: 30.23 22.45 7.78 334.87 197.18

Anyway you can fuse your terminal reports into the excel sheet to manage thing as the origianl page is shown the way how to do it.Kndly visit the origianl pacakge author page to see the options.

Ok now lets talk about another binary come with package called “pidstat” What it does??

pidstat command is used to monitor processes and threads currently being managed by the Linux kernel. It can also monitor the children of those processes and threads.

on my system it shows the thing going underneath:

bhaskar@bhaskar-laptop_07:41:22_Tue Aug 31:~> sudo pidstat -d 2
Password:
Linux 2.6.34-ARCH (bhaskar-laptop) 08/31/2010 _i686_ (2 CPU)

07:46:56 AM PID kB_rd/s kB_wr/s kB_ccwr/s Command
07:46:58 AM 990 0.00 11.82 0.00 kjournald
07:46:58 AM 3948 0.00 1.97 1.97 plugin-containe

07:46:58 AM PID kB_rd/s kB_wr/s kB_ccwr/s Command

07:47:00 AM PID kB_rd/s kB_wr/s kB_ccwr/s Command
07:47:02 AM 990 0.00 6.00 0.00 kjournald
07:47:02 AM 3948 0.00 2.00 2.00 plugin-containe

07:47:02 AM PID kB_rd/s kB_wr/s kB_ccwr/s Command
07:47:04 AM 3835 0.00 2.00 2.00 firefox

07:47:04 AM PID kB_rd/s kB_wr/s kB_ccwr/s Command

07:47:06 AM PID kB_rd/s kB_wr/s kB_ccwr/s Command
07:47:08 AM 990 0.00 8.00 0.00 kjournald
07:47:08 AM 3948 0.00 2.00 2.00 plugin-containe

07:47:08 AM PID kB_rd/s kB_wr/s kB_ccwr/s Command

07:47:10 AM PID kB_rd/s kB_wr/s kB_ccwr/s Command
07:47:12 AM 990 0.00 12.00 0.00 kjournald
07:47:12 AM 3948 0.00 2.00 2.00 plugin-containe

-d” option provide I/O statistics.

Now get the memory utilisation stat through “-r” flag of this binary.

bhaskar@bhaskar-laptop_07:50:18_Tue Aug 31:~> sudo pidstat -r
Linux 2.6.34-ARCH (bhaskar-laptop) 08/31/2010 _i686_ (2 CPU)

07:51:41 AM PID minflt/s majflt/s VSZ RSS %MEM Command
07:51:41 AM 1 0.45 0.00 1752 620 0.06 init
07:51:41 AM 1023 0.54 0.00 2148 948 0.09 udevd
07:51:41 AM 2772 0.02 0.00 5080 428 0.04 syslog-ng
07:51:41 AM 2773 0.09 0.00 5396 1620 0.16 syslog-ng
07:51:41 AM 2804 0.03 0.00 3420 700 0.07 ntpd
07:51:41 AM 2805 0.25 0.00 8232 3848 0.38 named
07:51:41 AM 2824 0.04 0.00 2372 760 0.07 xinetd
07:51:41 AM 2834 0.23 0.00 18672 8492 0.83 httpd
07:51:41 AM 2874 0.05 0.00 18724 6760 0.66 httpd
07:51:41 AM 2875 0.15 0.00 18688 7660 0.75 httpd
07:51:41 AM 2876 0.15 0.00 18688 7660 0.75 httpd
07:51:41 AM 2877 0.14 0.00 18824 7844 0.77 httpd
07:51:41 AM 2878 0.15 0.00 18688 7660 0.75 httpd
07:51:41 AM 2879 0.15 0.00 18688 7660 0.75 httpd
07:51:41 AM 2917 0.13 0.00 8468 1888 0.19 master
07:51:41 AM 2931 0.12 0.00 8540 1760 0.17 pickup
07:51:41 AM 2932 0.12 0.00 8592 1776 0.17 qmgr
07:51:41 AM 2936 0.04 0.00 1800 628 0.06 crond
07:51:41 AM 2946 0.16 0.00 2788 1216 0.12 dbus-daemon
07:51:41 AM 2954 0.60 0.00 15052 3608 0.35 hald
07:51:41 AM 2955 0.19 0.00 3516 1172 0.11 hald-runner
07:51:41 AM 2984 0.08 0.00 3580 992 0.10 hald-addon-inpu
07:51:41 AM 2986 0.08 0.00 3580 988 0.10 hald-addon-rfki
07:51:41 AM 2987 0.08 0.00 3580 984 0.10 hald-addon-leds
07:51:41 AM 2996 0.07 0.00 3576 992 0.10 hald-addon-gene
07:51:41 AM 2998 0.08 0.00 3580 1000 0.10 hald-addon-stor
07:51:41 AM 3008 0.08 0.00 3244 1012 0.10 hald-addon-acpi
07:51:41 AM 3023 0.03 0.00 6216 688 0.07 rpcbind
07:51:41 AM 3027 0.02 0.00 3148 308 0.03 famd
07:51:41 AM 3036 0.02 0.00 1960 356 0.03 gpm
07:51:41 AM 3044 0.24 0.00 13912 2152 0.21 gdm-binary
07:51:41 AM 3060 3.17 0.04 143100 19616 1.92 dropbox
07:51:41 AM 3072 0.04 0.00 1752 536 0.05 agetty
07:51:41 AM 3073 0.04 0.00 1752 540 0.05 agetty
07:51:41 AM 3074 0.04 0.00 1752 540 0.05 agetty
07:51:41 AM 3075 0.04 0.00 1752 536 0.05 agetty
07:51:41 AM 3076 0.04 0.00 1752 532 0.05 agetty
07:51:41 AM 3077 0.04 0.00 1752 536 0.05 agetty
07:51:41 AM 3132 0.25 0.00 17028 2804 0.27 gdm-simple-slav
07:51:41 AM 3155 162.21 0.01 82076 35784 3.51 Xorg
07:51:41 AM 3194 0.28 0.00 18224 2236 0.22 console-kit-dae
07:51:41 AM 3195 0.03 0.00 3528 644 0.06 ntpd
07:51:41 AM 3272 0.03 0.00 3172 332 0.03 dbus-launch
07:51:41 AM 3277 0.24 0.00 5448 2540 0.25 upowerd
07:51:41 AM 3331 0.42 0.00 17664 5400 0.53 polkit-gnome-au
07:51:41 AM 3335 0.25 0.00 5640 2672 0.26 polkitd
07:51:41 AM 3336 0.16 0.00 14888 2064 0.20 gdm-session-wor
07:51:41 AM 3349 0.11 0.00 22176 1432 0.14 gnome-keyring-d
07:51:41 AM 3367 0.73 0.00 25064 5380 0.53 gnome-session
07:51:41 AM 3385 0.03 0.00 3172 332 0.03 dbus-launch
07:51:41 AM 3386 0.09 0.00 2616 1116 0.11 dbus-daemon
07:51:41 AM 3388 0.02 0.00 3540 224 0.02 ssh-agent
07:51:41 AM 3391 0.18 0.00 6776 2580 0.25 gconfd-2
07:51:41 AM 3396 0.69 0.01 22052 7000 0.69 gnome-settings-
07:51:41 AM 3401 0.13 0.00 6352 1708 0.17 gvfsd
07:51:41 AM 3404 0.79 0.00 55332 12088 1.18 metacity
07:51:41 AM 3405 0.90 0.01 42768 11040 1.08 gnome-panel
07:51:41 AM 3407 0.21 0.00 7932 2764 0.27 gvfs-gdu-volume
07:51:41 AM 3409 0.25 0.00 13512 2556 0.25 udisks-daemon
07:51:41 AM 3410 0.03 0.00 5000 512 0.05 udisks-daemon
07:51:41 AM 3425 0.11 0.00 38324 1492 0.15 gvfs-fuse-daemo
07:51:41 AM 3429 1.24 0.02 53156 8800 0.86 nautilus
07:51:41 AM 3431 0.25 0.00 41896 2352 0.23 bonobo-activati
07:51:41 AM 3442 27.99 0.00 20928 6888 0.68 multiload-apple
07:51:41 AM 3445 0.44 0.01 21036 7000 0.69 battstat-applet
07:51:41 AM 3446 0.67 0.00 50716 11744 1.15 gweather-applet
07:51:41 AM 3448 0.74 0.01 41420 11764 1.15 clock-applet
07:51:41 AM 3450 0.70 0.00 41736 11532 1.13 wnck-applet
07:51:41 AM 3451 0.42 0.00 20500 6644 0.65 notification-ar
07:51:41 AM 3452 0.29 0.00 16120 4172 0.41 polkit-gnome-au
07:51:41 AM 3454 0.35 0.00 17840 5308 0.52 gdu-notificatio
07:51:41 AM 3480 0.08 0.00 17236 1460 0.14 gnome-screensav
07:51:41 AM 3502 0.17 0.00 6856 2396 0.23 gvfsd-trash
07:51:41 AM 3509 0.18 0.00 4828 1888 0.19 system-tools-ba
07:51:41 AM 3516 0.13 0.00 6484 1740 0.17 gvfsd-burn
07:51:41 AM 3522 0.76 0.00 12724 10152 0.99 SystemToolsBack
07:51:41 AM 3528 0.76 0.01 47896 12500 1.23 gnome-terminal
07:51:41 AM 3529 0.05 0.00 1796 580 0.06 gnome-pty-helpe
07:51:41 AM 3531 0.15 0.00 4924 1884 0.18 bash
07:51:41 AM 3538 0.07 0.00 4412 844 0.08 screen
07:51:41 AM 3539 0.13 0.00 4676 1372 0.13 screen
07:51:41 AM 3540 0.16 0.00 4924 1892 0.19 bash
07:51:41 AM 3546 0.14 0.00 4000 900 0.09 su
07:51:41 AM 3547 0.20 0.00 4900 1876 0.18 bash
07:51:41 AM 3577 0.04 0.00 2144 844 0.08 udevd
07:51:41 AM 3578 0.03 0.00 2144 864 0.08 udevd
07:51:41 AM 3611 0.16 0.00 4924 1872 0.18 bash
07:51:41 AM 3617 0.26 0.01 4884 1796 0.18 bash
07:51:41 AM 3628 0.16 0.00 4924 1876 0.18 bash
07:51:41 AM 3635 0.21 0.01 5136 1164 0.11 bash
07:51:41 AM 3655 0.21 0.00 4924 1920 0.19 bash
07:51:41 AM 3674 0.14 0.00 4000 904 0.09 su
07:51:41 AM 3675 0.16 0.00 4900 1868 0.18 bash
07:51:41 AM 3684 0.27 0.01 5552 2740 0.27 bash
07:51:41 AM 3701 1.87 0.00 4924 1956 0.19 bash
07:51:41 AM 3708 0.13 0.00 4604 1372 0.13 thunderbird
07:51:41 AM 3721 0.10 0.00 4736 1420 0.14 run-mozilla.sh
07:51:41 AM 3725 8.07 0.08 272920 81716 8.01 thunderbird-bin
07:51:41 AM 3835 234.27 0.12 749812 283212 27.76 firefox
07:51:41 AM 3848 0.01 0.00 4608 448 0.04 firefox_cpu_lim
07:51:41 AM 3849 9.11 0.00 1916 588 0.06 cpulimit
07:51:41 AM 3948 9.40 0.03 112288 36312 3.56 plugin-containe
07:51:41 AM 3956 0.13 0.00 18688 7656 0.75 httpd
07:51:41 AM 3965 0.70 0.00 41128 10936 1.07 notification-da
07:51:41 AM 5130 0.13 0.00 1780 636 0.06 sadc
07:51:41 AM 5859 0.19 0.00 3656 812 0.08 pidstat

Now lets talk about two very important tool which will provide different way to view things. Those are called “sadc” and “sadf“.I will cover one after another below.

SADC:
It is system activity and data collector daemon.Even w can use it manually too!.Sadc command intened to run behind the sar command.Actually it will write the binary format of the statistics it collect day by day and put into a dir i.e /var/log/sadd,where dd stands for the particular day.As the man page said it can only provide local activity,means runs on the same host it installed.

I am putting here few example stright out of the manual page for clear understanding.Here we go:

/usr/lib/sa/sadc 1 10 /tmp/datafile
Write 10 records of one second intervals to the /tmp/datafile binary file.

/usr/lib/sa/sadc -C Backup_Start /tmp/datafile
Insert the comment Backup_Start into the file /tmp/datafile.

So move onto the next tool called sadf.

SADF:
This tool actually dispaly the collected data by sar in different format.Which is wonderful..because you can fuse your data to various places to get lot many information.It will essentially provide XML,CVS format data .

once again I am putting example stright out of the manual page for easy understanding.Here we go:

sadf -d /var/log/sa/sa21 — -r -n DEV
Extract memory, swap space and network statistics from system activity file ‘sa21’, and display them in a format that can be ingested by a
database.

sadf -p -P 1
Extract CPU statistics for processor 1 (the second processor) from current daily data file, and display them in a format that can easily be
handled by a pattern processing command.

Hope this will help.

Cheers!
Bhaskar

How to properly run fsck on (/) root or other partitions including LVM

>As it is an important issue to deal with low level thing in the server archtecture. Being an GNU/Linux administrator/NOC/Ops one has to have the clear cut understanding what they are doing.Because handling the production box require lot of common sense and in depth knowlegde about the platform/OS.

So without much ado lets play with it or let me show you the simple tricks.

I do not issue any guarantee that this will work for you.

So the first question come into the mind why the hell you need to check the filesystem?? Specially the root(/) part of it…sound pretty dull and boring…huh..please don’t ignore this.You know ignorance is a sin…so do not commit it.

Now filesystem can be corrupted in various ways..few common ways are :

1) Not properly shutdown the server(although most of the cases journaling will do the healing)

2) Sudden power cut left your system down with lot of processing going on

3)Somebody has done something special(bad sense) to corrupt the data on that particular partition.

It is a bad idea and not recommended to run fsck(yes,this is the inbuilt tool you need to use)the mounted partition or drive.So don’t do that.

Now, running fsck on other partition like /home,/var,/usr …

First and foremost thing to be done is get into a single user mode..how do you do that?

ok once you type init 1 at the terminal prompt you will be taken to the singe user mode.From there simply unmount the partions as show below:

root@bhaskar-laptop_08:16:36_Mon Aug 16:/home/bhaskar # init 1 —> this will bring to the single user mode

root@bhaskar-laptop_08:16:36_Mon Aug 16:/home/bhaskar # umount /dev/sda2 —> assuming this partion hold the /home section.

Now run the fsck:


root@bhaskar-laptop_08:18:02_Mon Aug 16:/home/bhaskar # fsck -yfv /dev/sda2

Ok..let me explain the flags or switch I passed with the fsck .

y——> it will try to detect and fix any filesystem related corruption without manual intervention.

f———–> this will force check even the system check says it’s clean.

v——–> It will provide you the verbose explanation what that comming going through on the terminal screen.

Now a major problem in our hand. That we find out that root(/)partition of the filesystem gor corrupted due to some reasons.So we need to fix that issue to get back the system as soon as possible on the track.

For this kind of problem..it significant that on a mounted system you just cannot run fsck…as I said earlier..becauase it will corrupt the data on it.So we need a installation cd/dvd for our rescue. The first cd/dvd will do the job for us or get a systemrescuecd to do that.

Once you boot with one of those cd/dvd and put the below text at the command prompt it presents:

#linux rescue nomount

Now once you fire that one you are on the prompt so you can begin work on that.First we need to do is fire a mknod command.Now ask me why need to do that???

Because we had passed the option nomount in the last section so it will not parse any file system or it will not initialize any filesystem or create any device to operate on.If you try to run fsck now it will fail.

So to run correctly the fsck to on a filesystem we need to create device file for that.For that we need to run mknod.But to use mknod we need to know the Major number and Minor number of the device.Lets get those number…wait before that I need to tell you few thing about what Major number and Minor number of a device and how it signifies.

What is Major Number and Minor number??

Traditionally, the major number identifies the driver associated with the device. For example, /dev/null and /dev/zero are both managed by driver 1, whereas virtual consoles and serial terminals are managed by driver 4; similarly, both vcs1 and vcsa1 devices are managed by driver 7. Modern Linux kernels allow multiple drivers to share major numbers, but most devices that you will see are still organized on the one-major-one-driver principle.

The minor number is used by the kernel to determine exactly which device is being referred to. Depending on how your driver is written, you can either get a direct pointer to your device from the kernel, or you can use the minor number yourself as an index into a local array of devices. Either way, the kernel itself knows almost nothing about minor numbers beyond the fact that they refer to devices implemented by your driver.

So it’s clear?? right.lets move on we need to find out the major number and minor number of the device to run mknod:

root@bhaskar-laptop_08:42:30_Mon Aug 16:/home/bhaskar # ls -al /dev/sda
brw-rw—- 1 root disk 8, 0 Aug 16 07:15 /dev/sda

See it will look like this…as 4the and 5th column holds the major number and minor number.Now create the device file:

#mknod /dev/sda b 8 0

It will create the device file.Once it’s done you are safe to run fsck on that particular partition holding your root(/) filesystem.

#fsck -yfv /dev/YourRootPartition(sda,hda,….)

Now lets have some fun with LVM.

We need few tools to manipulate that kind of partition which will provide the lvm package within the os or in come inbuilt with other rescue cd.

We need to find out physical disk,volume group and logical partition ..where we are going to run fsck..right?

pvscan :Physical scanning of particular disk

root@bhaskar-laptop_08:44:06_Mon Aug 16:/home/bhaskar # pvscan
PV /dev/sda8 VG bhaskarlaptop lvm2 [46.15 GiB / 21.15 GiB free]
Total: 1 [46.15 GiB] / in use: 1 [46.15 GiB] / in no VG: 0 [0 ]

vgscan :Volume group scanning

root@bhaskar-laptop_08:50:24_Mon Aug 16:/home/bhaskar # vgscan
Reading all physical volumes. This may take a while…
Found volume group “bhaskarlaptop” using metadata type lvm2

lvscan :Logical volume scanning

root@bhaskar-laptop_08:52:00_Mon Aug 16:/home/bhaskar # lvscan
ACTIVE ‘/dev/bhaskarlaptop/data’ [25.00 GiB] inherit

Now it is not activates then you need to activate the specific logical volume like this:

#lvchange -ay “yourLogicalVolume”

The final step:

Run the fsck on logical volume:

#fsck -yfv /YourLogicalVolume

Hope this will help.

Cheers!
Bhaskar

Patching the kernel: step by step approch

Patching a kernel refers to upgrading to the latest ‘n greatest by small increments.

Rather than downloading a 25 meg source, it is possible, indeed desirable from your point of view, to simply apply the changes in source code that occur between revisions. These changes can be as little as half a megabyte. A considerable saving in download time.

First and foremost the kernel source you upgrade must be ‘pristine’. It means that at some time previous, you have obtained a pristine kernel source from www.kernel.org or one of it’s mirrors. Redhat distribution source code is NOT pristine (nor is any other distro). You must work from pristine source, or, have the ability to reverse patch what ever changes a distributor made. If this is the case for you, bite the bullet, download a pristine kernel, and use these steps for ever more.

“pristine source” is exactly that. Unmodified source code. It does not apply to the compiled binaries or any extraneous additions that may be present in the directory. Thus, you can safely compile pristine source, create and boot the kernel image derived from it, and regardless of all the now extra bits ‘in there’ , it is still, pristine source. This means you can conveniently port your current kernel configuration into the new kernel, without problems. It is not, “source code”.

Now be warned. One slip, one typo on your part, can devastate the source you have. Read every step carefully.

The examples used assume pristine kernel source 2.6.31 located in
/usr/src/linux-2.6.31
and the symlink
/usr/src/linux pointing to it.

One: Obtain the patch.

The patch you require is one more than your current pristine kernel.

download patch-2.6.32.bz2 from www.kernel.org

place this patch file into /usr/src

repeat this step for each patch above 2.6.32

Two: Prepare a new linux folder.

Type the following

cd (space) /usr/src

cp (space) -r (space) linux-2.6.31 (space) linux-2.6.32

rm (space) linux

ln (space) -s (space) linux-2.6.32 (space) linux

Three: dry run

bzcat (space) patch-2.6.32.bz2 (space) | (space) patch (space) -p0 (space) –dry-run (space) | (space) more

What this command does is unpack the compressed patch file and automatically apply it to the “linux” directory. the –dry-run is test mode, it won’t damage the source if there’s an error. The verb “more” allows you to check thru the processing looking for a FAIL message. A pristine source will NEVER fail No ifs, no buts. If you get FAILS, you dont have a pristine source, simple as that.

Alternatively, you can type the following
bzcat (space) patch-2.6.32.bz2 (space) | (space) patch (space) -p0 (space) –dry-run (space) > (space) dump

You can then edit the “dump” file to your heart’s content, looking for fail messages.

Four: the Full Monty.

bzcat (space) patch-2.6.32.bz2 (space) | (space) patch (space) -p0

Five: iterative

You are now ready to complle kernel 2.6.32

You do so in the normal manner (see kernel compile step by step on this site)

If however you have a series of patches (say up to 2.6.99) simply iterate thru steps two to four before compiling. Remember that the criteria is to change the symbolic link, thus, the second iteration would be

cp (space) -r (space) linux-2.6.32 (space) linux-2.6.33

rm (space) linux

ln (space) -s (space) linux-2.6.33 (space) linux

and as each patch succeeds

rm linux-2.6.32

Naturally, in the examples above, you would NEVER

rm linux-2.6.31

2.6.31 (in this example) is your lifeline. You can always revert and start over if things went seriously awol.

Six: Revert a patch

To back a patch out, simply add the -R (reverse) switch:

bzcat patch-2.6.xx | patch -p0 -R

Hope this will help.

Bhaskar Chowdhury

Compiling custom kernel for different GNU/Linux distributions

Compiling kernel is not for the faint heart’s toy. One have to be ready for the pitfall they face when things are not working as they expected from a preconceived notion in their mind.

But having said that I am not trying you to get scared of it or keep you away from to get the best out of your own GNU/Linux distro as per your liking.

In this article I will step you through the process that how can build your own kernel step by step and installed it ..later use it .

I have pick up three distribution for this purpose; the peoples choice comes first as Ubuntu. Then a bit mid way distribution for geek and normal people ;called openSUSE. And finally the my favorite and source based one called Gentoo.

Now a very important point :why would anyone want to compile a kernel??(I have had the experience to hear from newbie administrator and GNU/Linux enthusitst that they want to compile the kernel; because they want to show the world that they know GNU/Linux more then anybody else) ,which is an absolute bogus and rubbish idea …only expect from those who jump from different stream or just want to be highlighted by saying ” I am a Linux guy”.

Compiling kernel should be necessary if and only if the below thing one wants:

  • The stock kernel doesn’t provide the feature that they want.
  • You should know what you are trying to do with the kernel.
  • If you are an avid kernel developer looking inside the kernel offering.
  • If you want fix some kernel related problem by enabling a debug feature in the kernel.
  • Some specific hardware feature want to activate so the underlying hardware react properly.
  • you should have the capability or knowledge iff something goes wrong after compilation of the kernel can bring back the system in previous pristine mode to function it properly.


Compiling kernel in Ubuntu way( Intrepid, Jaunty, and Karmic)
:

Step 1:

Get the kernel source from the http://www.kernel.org .Whatever the version you want to compile;stable version would be a better choice.

Step 2:
open a terminal and fire the below command

sudo apt-get install fakeroot kernel-wedge build-essential makedumpfile kernel-package

Step 3:

The linux-kernel-devel does not exists in intrepid,jaunty and newer version.For that reason to compile the kernel also need to run:

sudo apt-get build-dep linux

Step 4:

You might get the kernel source in ubuntu way like this:( for Hardy,intrepid Ibex,Jaunty)
sudo apt-get build-dep --no-install-recommends --only-source linux

For Kermic Koala:

sudo apt-get build-dep --no-install-recommends linux-image-$(uname -r)
apt-get source linux-image-$(uname -r)

Step 5:

Now you have to modify the source config file of the downloaded kernel..so lets find the that file
Ubuntu store this file /debian/config/ARCH or for newer release it is in debian.master/config/ARCH
You can get a snapshot of that particular dir like this

ls -l debian/config/i386/

total 108
-rw-r--r-- 1 root src 73962 2007-08-13 01:29 config
-rw-r--r-- 1 root root 1369 2007-08-13 01:29 config.386
-rw-r--r-- 1 root root 1330 2007-08-13 01:29 config.generic
-rw-r--r-- 1 root root 1395 2007-08-13 01:29 config.server
-rw-r--r-- 1 root root 1756 2007-08-13 01:29 config.server-bigiron
-rw-r--r-- 1 root root 8 2007-08-13 01:25 lowlatency
-rw-r--r-- 1 root root 194 2007-08-13 01:25 vars.386

If you don't find the file then search in /boot section of tree.


Step 6:

Now change the config file according to your choice ...once done then please do the following
debian/rules updateconfigs

yes that is a command you have to fire once you are done with the config file.That command reside in debian/scripts/misc


Step 7:

Now you have run the below command in the source dir of the downloaded kernel:
You have to take the current configuration file as the basis of the new one. So doing so..

cp /boot/config-`uname -r` ./.config


Step 8:


make menuconfig

It will open up an tui window full of options to choose from.Once you finish the your selective session with that

dialog window( you have manuvaour to with TAB key to move and spacebar to select).
Then go to bottom of that window and select " Load an alternate configuration file" opention and enter
Then press "ok" to save the config file.

Step 9:

Once done the previous steps ..so you have your own custom config file for the kernel. Now time to build the kernel
Do it in the terminal:

$ make-kpkg clean


$ fakeroot make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers


Now here you need bit of explanation of the "--append-to-version" thing..which can be selected from the

previous step when the window came select it from "general section" (top of the window option) and
it should start with a "-" minus signto separate form the kernel version number.
Now please help yourself to get a cup of coffee and relax..it will take some to compile the kernel to build .deb file for your system.

Step 10:

After the sucessfull build you can find the .deb file in /usr/src
there should be two file ;one for linux-image and another for linux-header..install both of them
dpkg -i linux-image-2.6.18.1-custom_2.6.18.1-custom-10.00.Custom_i386.deb
dpkg -i linux-headers-2.6.18.1-custom_2.6.18.1-custom-10.00.Custom_i386.deb

Step 11:

You have to put an entry in the grub(the bootloader) conf file to get it booted.
You can find more detailed description of it here : http://howtoforge.com/kernel_compilation_ubuntu_p2 and here: https://help.ubuntu.com/community/Kernel/Compile

Compiling the kernel openSUSE way:


Step 1:

Get the kernel source from the www.kernel.org ; whatever the version you want to compile;stable version would be a better choice.

Step 2:

Now get the required package for kernel build
yast -i ncurses-devel
This package will help to get the "make menuconfig" dialog to appear in terminal.

Step 3:

Now you need to get some backup and modify the few tool to get kernel compile properly.Otherwise it
won't allow us to install the kernel rpm in the system.
cp /usr/lib/rpm/find-provides.ksyms /usr/lib/rpm/find-provides.ksyms_orig
cp /usr/lib/rpm/find-requires.ksyms /usr/lib/rpm/find-requires.ksyms_orig
cp /usr/lib/rpm/find-supplements.ksyms /usr/lib/rpm/find-supplements.ksyms_orig
Then we open each of these scripts and replace kernel-*) is_kernel_package=1 ;; with kernel*) is_kernel_package=1 ;;:

Step 4:

Now go to the kernel source dir(where you unpack the kernel source tree) make a symlink to the "linux"
dir with the unpacked kernel source tree.
ln -s linux-2.6.18.2 linux

Step 5:

make mrproper
cp /boot/config-`uname -r` ./.config

step 6:

make menuconfig

Step 7:

Select "Load an alternate configuration file" and save by pressing ok.

Step 8:

It is important to have different version for your custom kernel ..for that you need to the "general setup" option of and select the second entry started as default.
You must start with a "-" with your choice of name and save it when promted.

Step 9:

Now build the rpm for the system:
make rpm
Please be patience ..it will take some time to compile the rpm( mostly about the choice you made)

Step 10:

You can view the source rpms here :
ls -la /usr/src/packages/SRPMS/

Step 11:

For the actual kernel rpm look in here:
ls -al /usr/src/packages/RPMS/i386

Step 12:

Get into the above dir and install the kernel;
rpm -ivh new-customized-kernel.rpm

Step 13:

Now create the initrd image to boot the system for the new kernel. For that
mkinitrd

Step 14:

Now configure the boot loader grub to boot new kernel.
For that edit the /boot/grub/menu.lst and put a stanza like below;
title new-customized-kernel
root (hd0,0) ----> depend where you load the boot loader
kernel path_to_the_kernel_img_file(usually /boot/
initrd path_to_the_initrd_img_file (usually in /boot
Save it and reboot and enjoy the new kernel.

Compiling the kernel in Gentoo way:


Step 1:

You can get he kernel source two ways in Gentoo. First as normal to get the .bzip from the kernel.org
Second is the gentoo way
sudo emerge -av gentoo-sources

Step 2:

Go to the /usr/src/ dir ,where the new kernel reside and make a link to the linux dir with the new
kernel unpacked dir.
ln -s linux-new-source linux

Step 3:

Then as usual
make menuconfig
select the options you need.You can stright way copy the .config file from the previous kernel source tree to the new one.
cp -v old-kernel-dir/.config new-kernel-dir/

Step -4:

You can compile kernel in two different way in Gentoo.
First is the tradition way and elaborate way ;like in above menthod (make menuconfig;make;make module_install, make install) or
Gentoo provide an easy way to hide the scrolling kernle compilation msg on the screen by using a tool called "genkernel",which essentially does the same thing.
For using the genkernel method ..you need to install it first like this:
sudo emerge -av genkernel
once install ... you are ready to use it.

Step 5:

Go to the specified kernel source dir and fire:
genkernel # without any argument
or
genkernel --save-config --install all

Now a bot of explanation of second command: the option "--save-config" saves a kenerl config file in

/etc/kenerl/kernel-version.config ,which you can use later and view.
Next option "--install" instruct the genkernel to install the kernel in the system .
Then option "all"...which define all the steps require to compile the kernel i.e make ,make module_install
make bzImage install make initrd or ramfs images
All will be done in the backgroud..no scrolling out put on the terminal.If you are really curious about the ongoing thing
You can have a look at the /var/log/genkernel.log file for the compilation process.
It will create less noise but it will take long .

Hope this guide will help.

Enlisting kernel modules by Name,Description and Depends

I was wondering how to get a glimpse of all kernel module at once with specific information I need.
I know how to use modinfo ,so thought to implement within a small AWK script which will fetch me the required info.

So just wrote a one liner for that like this:

awk ‘{print $1}’ “/proc/modules” | xargs modinfo | awk /^(filename|desc|depends)/’

That’s all I have done.I put it in a file and give it a execution permission.Once you run it you get the info like below,which is very useful:

bhaskar@Bhaskar-laptop_10:02:34_Mon Feb 01:~/bin> sudo list_module
filename: /lib/modules/2.6.31.8-0.1-default/kernel/fs/ext4/ext4.ko
description: Fourth Extended Filesystem
depends: jbd2,crc16
filename: /lib/modules/2.6.31.8-0.1-default/kernel/fs/jbd2/jbd2.ko
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/lib/crc16.ko
description: CRC16 calculations
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/net/ppp_deflate.ko
depends: zlib_deflate,ppp_generic
filename: /lib/modules/2.6.31.8-0.1-default/kernel/lib/zlib_deflate/zlib_deflate.ko
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/net/bsd_comp.ko
depends: ppp_generic
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/net/ppp_async.ko
depends: ppp_generic,crc-ccitt
filename: /lib/modules/2.6.31.8-0.1-default/kernel/lib/crc-ccitt.ko
description: CRC-CCITT calculations
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/net/ppp_generic.ko
depends: slhc
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/net/slhc.ko
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/usb/serial/usbserial.ko
description: USB Serial Driver core
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/net/packet/af_packet.ko
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/net/bluetooth/rfcomm/rfcomm.ko
description: Bluetooth RFCOMM ver 1.11
depends: bluetooth,l2cap
filename: /lib/modules/2.6.31.8-0.1-default/updates/vboxnetadp.ko
description: VirtualBox Network Adapter Driver
depends:
filename: /lib/modules/2.6.31.8-0.1-default/updates/vboxnetflt.ko
description: VirtualBox Network Filter Driver
depends: vboxdrv
filename: /lib/modules/2.6.31.8-0.1-default/updates/vboxdrv.ko
description: VirtualBox Support Driver
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/gpu/drm/i915/i915.ko
description: Intel Graphics
depends: drm,i2c-core,video,i2c-algo-bit
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/gpu/drm/drm.ko
description: DRM shared core routines
depends: i2c-core
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/i2c/algos/i2c-algo-bit.ko
description: I2C-Bus bit-banging algorithm
depends: i2c-core
filename: /lib/modules/2.6.31.8-0.1-default/kernel/net/bluetooth/sco.ko
description: Bluetooth SCO ver 0.6
depends: bluetooth
filename: /lib/modules/2.6.31.8-0.1-default/kernel/net/bridge/bridge.ko
depends: stp,llc
filename: /lib/modules/2.6.31.8-0.1-default/kernel/net/802/stp.ko
depends: llc
filename: /lib/modules/2.6.31.8-0.1-default/kernel/net/llc/llc.ko
description: LLC IEEE 802.2 core support
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/net/bluetooth/bnep/bnep.ko
description: Bluetooth BNEP ver 1.3
depends: bluetooth,l2cap
filename: /lib/modules/2.6.31.8-0.1-default/kernel/sound/core/oss/snd-pcm-oss.ko
description: PCM OSS emulation for ALSA.
depends: snd-pcm,snd,snd-mixer-oss
filename: /lib/modules/2.6.31.8-0.1-default/kernel/sound/core/oss/snd-mixer-oss.ko
description: Mixer OSS emulation for ALSA.
depends: snd
filename: /lib/modules/2.6.31.8-0.1-default/kernel/sound/core/seq/snd-seq.ko
description: Advanced Linux Sound Architecture sequencer.
depends: snd,snd-seq-device,snd-timer
filename: /lib/modules/2.6.31.8-0.1-default/kernel/net/bluetooth/l2cap.ko
description: Bluetooth L2CAP ver 2.13
depends: bluetooth
filename: /lib/modules/2.6.31.8-0.1-default/kernel/sound/core/seq/snd-seq-device.ko
description: ALSA sequencer device management
depends: snd
filename: /lib/modules/2.6.31.8-0.1-default/kernel/fs/binfmt_misc.ko
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/net/ipv6/ipv6.ko
description: IPv6 protocol stack for Linux
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/cpufreq/cpufreq_conservative.ko
description: ‘cpufreq_conservative’ – A dynamic cpufreq governor for Low Latency Frequency Transition capable processors optimised for use in a battery environment
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/cpufreq/cpufreq_userspace.ko
description: CPUfreq policy governor ‘userspace’
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/cpufreq/cpufreq_powersave.ko
description: CPUfreq policy governor ‘powersave’
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.ko
description: ACPI Processor P-States Driver
depends: processor
filename: /lib/modules/2.6.31.8-0.1-default/kernel/arch/x86/kernel/cpu/cpufreq/speedstep-lib.ko
description: Library for Intel SpeedStep 1 or 2 cpufreq drivers.
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/fs/fuse/fuse.ko
description: Filesystem in Userspace
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/block/loop.ko
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/md/dm-mod.ko
description: device-mapper driver
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/crypto/arc4.ko
description: ARC4 Cipher Algorithm
depends: crypto_algapi
filename: /lib/modules/2.6.31.8-0.1-default/kernel/crypto/ecb.ko
description: ECB block cipher algorithm
depends: crypto_algapi,crypto_blkcipher
filename: /lib/modules/2.6.31.8-0.1-default/kernel/crypto/cryptomgr.ko
description: Crypto Algorithm Manager
depends: crypto_hash,crypto_algapi,crypto_blkcipher,aead,pcompress
filename: /lib/modules/2.6.31.8-0.1-default/kernel/crypto/aead.ko
description: Authenticated Encryption with Associated Data (AEAD)
depends: crypto_algapi
filename: /lib/modules/2.6.31.8-0.1-default/kernel/crypto/pcompress.ko
description: Partial (de)compression type
depends: crypto_algapi
filename: /lib/modules/2.6.31.8-0.1-default/kernel/crypto/crypto_blkcipher.ko
description: Generic block chaining cipher type
depends: crypto_algapi
filename: /lib/modules/2.6.31.8-0.1-default/kernel/crypto/crypto_hash.ko
description: Generic cryptographic hash type
description: Asynchronous cryptographic hash type
description: Synchronous cryptographic hash type
depends: crypto_algapi
filename: /lib/modules/2.6.31.8-0.1-default/kernel/sound/pci/hda/snd-hda-codec-analog.ko
description: Analog Devices HD-audio codec
depends: snd-hda-codec,snd
filename: /lib/modules/2.6.31.8-0.1-default/kernel/crypto/crypto_algapi.ko
description: Cryptographic algorithms API
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/net/wireless/b43/b43.ko
description: Broadcom B43 wireless driver
depends: pcmcia,mac80211,ssb,led-class,cfg80211,pcmcia_core
filename: /lib/modules/2.6.31.8-0.1-default/kernel/net/mac80211/mac80211.ko
description: IEEE 802.11 subsystem
depends: cfg80211
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/media/video/uvc/uvcvideo.ko
description: USB Video Class driver
depends: videodev,v4l1-compat
filename: /lib/modules/2.6.31.8-0.1-default/kernel/net/wireless/cfg80211.ko
description: wireless configuration support
depends: rfkill
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/leds/led-class.ko
description: LED Class Interface
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/media/video/videodev.ko
description: Device registrar for Video4Linux drivers v2
depends: i2c-core,v4l1-compat
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/media/video/v4l1-compat.ko
description: v4l(1) compatibility layer for v4l2 drivers.
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/sound/pci/hda/snd-hda-intel.ko
description: Intel HDA driver
depends: snd-pcm,snd,snd-page-alloc,snd-hda-codec
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/scsi/sr_mod.ko
description: SCSI cdrom (sr) driver
depends: cdrom
filename: /lib/modules/2.6.31.8-0.1-default/kernel/sound/pci/hda/snd-hda-codec.ko
description: HDA codec core
depends: snd-pcm,snd,snd-hwdep
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/scsi/sg.ko
description: SCSI generic (sg) driver
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/sound/core/snd-hwdep.ko
description: Hardware dependent layer
depends: snd
filename: /lib/modules/2.6.31.8-0.1-default/kernel/sound/core/snd-pcm.ko
description: Midlevel PCM code for ALSA.
depends: snd,snd-page-alloc,snd-timer
filename: /lib/modules/2.6.31.8-0.1-default/kernel/sound/core/snd-timer.ko
description: ALSA timer interface
depends: snd
filename: /lib/modules/2.6.31.8-0.1-default/kernel/sound/core/snd.ko
description: Advanced Linux Sound Architecture driver for soundcards.
description: Jack detection support for ALSA
depends: soundcore
filename: /lib/modules/2.6.31.8-0.1-default/kernel/sound/soundcore.ko
description: Core sound module
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/cdrom/cdrom.ko
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/i2c/i2c-core.ko
description: I2C-Bus main module
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/input/joydev.ko
description: Joystick device interfaces
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/ssb/ssb.ko
description: Sonics Silicon Backplane driver
depends: pcmcia_core,pcmcia
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/pcmcia/pcmcia.ko
description: PCMCIA Driver Services
depends: pcmcia_core
filename: /lib/modules/2.6.31.8-0.1-default/kernel/sound/core/snd-page-alloc.ko
description: Memory allocator for ALSA system.
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/watchdog/iTCO_wdt.ko
description: Intel TCO WatchDog Timer Driver
depends: iTCO_vendor_support
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/watchdog/iTCO_vendor_support.ko
description: Intel TCO Vendor Specific WatchDog Timer Driver Support
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/input/serio/serio_raw.ko
description: Raw serio driver
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/input/misc/pcspkr.ko
description: PC Speaker beeper driver
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/acpi/container.ko
description: ACPI container driver
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/acpi/video.ko
description: ACPI Video Driver
depends: thermal_sys,output
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/net/tg3.ko
description: Broadcom Tigon3 ethernet driver
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/bluetooth/btusb.ko
description: Generic Bluetooth USB driver ver 0.5
depends: bluetooth
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/pcmcia/pcmcia_core.ko
description: Linux Kernel Card Services
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/net/bluetooth/bluetooth.ko
description: Bluetooth Core ver 2.15
depends: rfkill
filename: /lib/modules/2.6.31.8-0.1-default/kernel/net/rfkill/rfkill.ko
description: RF switch support
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/video/output.ko
description: Display Output Switcher Lowlevel Control Abstraction
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/acpi/ac.ko
description: ACPI AC Adapter Driver
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/char/agp/intel-agp.ko
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/acpi/battery.ko
description: ACPI Battery Driver
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/platform/x86/wmi.ko
description: ACPI-WMI Mapping Driver
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/acpi/button.ko
description: ACPI Button Driver
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/ata/ata_generic.ko
description: low-level driver for generic ATA
depends: libata
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/usb/host/uhci-hcd.ko
description: USB Universal Host Controller Interface driver
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/rtc/rtc-cmos.ko
description: Driver for PC-style ‘CMOS’ RTCs
depends: rtc-core
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/rtc/rtc-core.ko
description: RTC class support
depends: rtc-lib
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/rtc/rtc-lib.ko
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/ata/ata_piix.ko
description: SCSI low-level driver for Intel PIIX/ICH ATA controllers
depends: libata
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/usb/host/ehci-hcd.ko
description: USB 2.0 ‘Enhanced’ Host Controller (EHCI) Driver
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/firmware/edd.ko
description: sysfs interface to BIOS EDD information
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/ata/ahci.ko
description: AHCI SATA low-level driver
depends: libata
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/ata/libata.ko
description: Library module for ATA devices
depends:
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/acpi/fan.ko
description: ACPI Fan Driver
depends: thermal_sys
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/acpi/thermal.ko
description: ACPI Thermal Zone Driver
depends: thermal_sys
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/acpi/processor.ko
description: ACPI Processor Driver
depends: thermal_sys
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/thermal/thermal_sys.ko
description: Generic thermal management sysfs support
depends: hwmon
filename: /lib/modules/2.6.31.8-0.1-default/kernel/drivers/hwmon/hwmon.ko
description: hardware monitoring sysfs/class support
depends:

Hope this will help 🙂


Bhaskar Chowdhury
Google Talk: unixbhaskar Skype: unixbhaskar Y! messenger: unixbhaskar
DiggLinkedinWordpressTwitterTechnoratiStumbleuponReddit

Linux kernel design patterns – part 2 [LWN.net]

This is a part two of the last article related to GNU/Linux design patterns.

Linux kernel design patterns – part 2 [LWN.net]

Bhaskar Chowdhury
Chat Google Talk: unixbhaskar Skype: unixbhaskar Y! messenger: unixbhaskar
Contact Me StumbleuponFacebookDiggTwitterBloggerRedditTechnoratiWordpress

Linux Kernel Design Patterns – Part 1 [LWN.net]

Wonderful article to explain the design goal of the GNU/Linux.

Linux Kernel Design Patterns – Part 1 [LWN.net]

Bhaskar Chowdhury
Chat Google Talk: unixbhaskar Skype: unixbhaskar Y! messenger: unixbhaskar
Contact Me StumbleuponFacebookDiggTwitterBloggerRedditTechnoratiWordpress