Praveen’s Journal

August 2, 2008

Identifying what is holding up your boot speed in Linux

Filed under: GNU/Linux — Tags: , , , — Praveen Kumar @ 2:48 pm

For a while now, I was not happy with the speed my Debian GNU/Linux booted. It was taking approximately 1:10 minutes to drop me in the GDM prompt. Today, I decided that I will try to probe into what exactly is happening. I have already heard of bootchart a few years ago. However I never had a chance to use it. So, I installed bootchart. I am not going to talk in detail about the installation. It is available in Debian and Ubuntu repositories. If you are using some other distribution, you can either find it in the repository or compile it from the source.

After installation, reboot the system and add 'init=/sbin/bootchartd' to the 'kernel' command line arguments in Grub. This will use bootchartd as init and bootstartd will in turn start the original init. If alternative init environment like init-ng is used, there might be additional arguments needed. Please consult the bootchartd man page for more information. Once the systems boots, the data collected is available in /var/log/bootchart.tgz. Run bootchart to generate bootchart.png from /var/log/bootchart.tgz.

After doing this, I figured out that udevadm is taking almost 30 seconds. I later figured out that the udev rule that tries to rename 'wlan0' to 'eth1' is the culprit (search on Google). Then I commented the 'eth1' line in /etc/udev/rules.d/70-persistent-net.rules, rebooted and did the bootchart thing again. I was happy to see that a portion of around 30 seconds is now removed from my boot time. That’s great!

Before udev fix After udev fix
Bootchart before udev fix Bootchart after udev fix

June 14, 2008

Modifying Control and Caps Lock keys under OpenSolaris and Linux

Filed under: General — Tags: , , , — Praveen Kumar @ 4:07 pm

Since I started using Emacs, I started using the Control key more than I had used it before. That is when I started using my Caps Lock key as Control key. In the beginning, I swapped the Control key and the Caps Lock key. However while doing pair programming on my computer, my colleagues found this setup a bit unfriendly. So, I decided to give up my Caps Lock key and started using Caps Lock as an additional Control key. Under Linux, Gnome has an option to do this using the “Keyboard Preferences” application. However I was not able to find this option in OpenSolaris Gnome. So, I have to take the old xmodmap way of doing this. This works under Linux as well. I hope that this would work on all UNIX variants that uses xmodmap. But I haven’t verified it personally.

To make Caps Lock key as an additional Control key, add the following to .Xmodmap file in your home directory. This configuration is automatically applied when you restart your X (Gnome) session. For the first time, you can manually apply this by running xmodmap ~/.Xmodmap.

!
! Make Caps Lock as an additional Control.
!
remove Lock = Caps_Lock
add Control = Caps_Lock

Please note that ! is the commenting character for xmodmap files.

But if you want to retain the Caps Lock function and swap it back to Control key, add the following to your .Xmodmap file.

!
! Swap Caps Lock and Control.
!
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L

June 5, 2008

Dumping core file from set-UID, set-GID ‘ed processes in Linux

Filed under: General — Tags: , — Praveen Kumar @ 8:08 pm

Lately I was encountering segmentation fault with one of our processes and found that it was not dumping core file even though we asked it by using appropriate ulimit setting. It was set-UIDed root. Then I discovered that the default behavior of set-UID, set-GID processes is not to dump core unless explicitly asked by prctl(2). In order to dump core, the following has to be done.

prctl( PR_SET_DUMPABLE, 1 );

I haven’t dealt a lot with set-UIDed processes. This was a valuable information to be leaned. Here is more information about this option.

       PR_SET_DUMPABLE
              (Since Linux 2.3.20) Set the  state  of  the  flag  determining
              whether  core dumps are produced for this process upon delivery
              of a signal whose default behavior is to produce a  core  dump.
              (Normally  this flag is set for a process by default, but it is
              cleared when a set-user-ID or set-group-ID program is  executed
              and  also  by various system calls that manipulate process UIDs
              and GIDs).  In kernels up to and including 2.6.12, arg2 must be
              either  0 (process is not dumpable) or 1 (process is dumpable).
              Between kernels 2.6.13 and 2.6.17, the value 2 was also permit‐
              ted, which caused any binary which normally would not be dumped
              to be dumped readable by root only; for security reasons,  this
              feature  has  been  removed.   (See  also  the  description  of
              /proc/sys/fs/suid_dumpable in proc(5).)

Powered by WordPress