Sunday, June 3, 2012

Conky Setup With Gmail and MPD cover

Conky is a super lightweight system monitor and status which supports many features. It has been long time since I found a good conky script that satisfies me. So Crawling the net I managed to collect some scripts, combine them, modify them, and finally create some additional ones from scratch.

The Result: 

The Steps: 

1. Download and copy the file from here.
2. Extract the file to your home folder :

      tar xvf qorrow_conky.tar

3. Rename the file _conkyrc to .conkyrc. Also rename the folder _conky to .conky

4. Replace every instance of home directory path in .conkyrc with your home directory.

5. Edit the file replacing your gmail login and password (if you want conky to display your mails)

6. For mpd cover fetching to work properly edit the :
    6.1 Adjust the variables : music_dir= <-- put your mpd music library directory here.
   6.2 coverlovin_script= <-- put the path to the file coverlovin file (recommended   vaule : /home/<your_name>/.conky/

Note 1 : mpc should be installed, cover fetching depends on it.
Note 2 : The file is customized for my laptop resolution, so play with the size and gap values in .conkyrc to adjust it for your machine.

That is it, run the conky : 
conky &

Tuesday, April 24, 2012

Wireless Bridging For KVM

This tutorial aims to establish a wireless bridge between the host wireless interface and the guest Ethernet interface. The guest will behave as standalone machine with dedicated IP address and has full connectivity to the outside world. Even SSH between the host and the guest is available.

Keep in mind that this procedure works only with assigning the guest a static IP address not DHCP but the host can get its IP with static or DHCP.

1. First install parprouted pakcage :
In CentOS :

yum install parprouted

2. Enable IP forwarding in your host:

echo 1 > /proc/sys/net/ipv4/ip_forward

3. Configure the tap interface :

tunctl -t tap0
ip link set tap0 up
ip addr add dev tap0

Important : the ip address of tap interface does not have to be in the same  subnet of your wireless and guest IP addresses. For my case the wireless addresses in the subnet network and tap0 is in network, but the guest IP address MUST be on the same network of the wireless interface.

4. Bridge your wireless LAN interface with the tap interface :

parprouted ra0 tap0

My wireless interface is ra0 so replace with your interface (maybe wlan0)

5. If iptables firewall is active , we MUST add rules for allowing connections through tap0 :

vi /etc/sysconfig/iptables

and add the following :

-A INPUT -i tap0 -j ACCEPT 
-A FORWARD -i tap0 -j ACCEPT 
-A FORWARD -o tap0 -j ACCEPT 

6. Now the bridge is ready. Start your VM :

qemu-kvm -hda test.img -m 512 -net nic -net tap,ifname=tap0,script=no

I faced a little problem with the vnc connection : there was two mouse cursors and that was annoying and the solution is simple; add the option
 -usb -usbdevice tablet to the last qemu-kvm command.

7. Inside the guest VM configure its interface with static IP address and this step depends on the type of your guest operating system. Remember : the same subnet of your wireless inerface. 

Example : wlan0 address : 
                Guest IP address :

Also configure your guest DNS and Default gateway as that of your host.

Saturday, April 7, 2012

Adding Additional Options to DHCP Client on Centos

I struggled to solve this :)
I wanted to add a dns server to /etc/resolv.conf before the name server the client gets from dhcp server.

In Debian based linux the procedure is to add the option to /etc/dhclient.conf or similar then restart the network or bring up the interface, But in Centos / RHEL there is some trick :

You have to create a file named dhclient-<interface_name>.conf in the /etc.

Example :

 To add another dns for the eth0 interface create : /etc/dhclient-eth0.conf
file and add this line to it :
prepend domain-name-servers;

Where is your additional name server

In fact it is more logical as you can have different settings for different interfaces.

Monday, April 2, 2012

Anaconda Headless Rescue Mode

One of the options you can pass to the grub boot entry options is the keyword : telnet

Combined with assigning a static ip address for you machine you can remote rescue in case of troubles.

Then anaconda will wait for your telnet connection

Finally,  from your remote machine you can telnet to the machine :


You are in rescue mode and you can do whatever you like to rescue the system.

Redirecting Bacula Console Command's Output

Working with bconsole , Sometimes the output of certain commands is so long that it scrolls fast and yout terminal history size will not be sufficient to catch all the output. For example : 

*list files jobid=32

The output was 29870 lines .. so either set your terminal history size to 30000 and keep scrolling and sacrificing your RAM or use the redirecting way!

The Redirecting Way:

While on bconsole command :

*@output testfile
*list files jobid=32

where testfile is the name of the output file required.

Now you can easily less or grep yout new file.

Monday, March 26, 2012

Creating Permanent Bridged Network Interface

This is very useful in many cases like if you want to add additional security layer using firewall or if you want to rum KVM virtualizaions with permanent interfaces accessed by the hosts as if the guest is a real machine.

I am using Centos 6.2 64 bit and I am using DHCP for assigning IP addressed and DNS and other configurations

1. Install bridge-utils :yum install bridge-utils
2. Bring down the interfaces eth0 : ifdown eth0
3. Edit the configuration file of the eth0 interface to use the bridge and create a new file for the bridge :

vi /etc/sysconfig/network-scripts/ifcfg-eth0
NAME="System eth0"

The most important line is BRIDGE=br0 where br0 is the name of the bridge device we shall create.

vi /etc/sysconfig/network-scripts/ifcfg-br0


Note the line TYPE=Bridge

4. The most important part that peventing the bridge from functioning properly was the line :  UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 in the ifcfg-eth0 file so I commented it out.

5 .Bring up the interfaces : ifup eth0 ; ifup br0;

6. Configure the iptables firewall to accept connections from the new bridge interface br0 :

 vi /etc/sysconfig/iptables
Add this line : -A INPUT -i br0 -j ACCEPT

7. Restart the iptables and network services

 service network restart
 service iptables restart

That is it !

Saturday, March 24, 2012

Installing ATI proprietary driver on Centos 6.2

ATI proprietary driver provides many features like 3D accelaration and surpasses the open source driver.Below is the steps of installing it.

* All commands issued as root

2.Install the fglrx-x11-drv and kmod-fglrx packages : yum install kmod-fglrx fglrx-x11-drv

3.Generate and initialize the new driver : aticonfig --initial

4.Now you have to reboot the system.

5.If you got a black blank screen you need to append "nomodeset" on the kernel in the grub boot loader entry for Centos.To make this permanent you have to edit the grub configuration files to make a new entry with this new option 
  5.1 Create a new file in /etc/grub.d/XX_anyname where XX is a number which is greater than the greater number of scripts in this directory, for example if you have scripts like 11_kdjk 30_linux 40_custom, create a file 50_mynewEntry

6.Edit the file adding your centos with nomodeset boot option.I copied the existing centos entry generated by the system and pasted it adding the option :

#!/bin/sh -e
echo "Adding My Centos 6.2 with
nomodeset option for fglrx to work ..."
cat << EOF
set root=(hd0,4)
menuentry "Centos 6.2 with nomodeset for proprietart ATI driver" --class gnu-linux --class gnu --class os {
        insmod part_msdos
        insmod ext2
        set root='(hd0,msdos4)'
        search --no-floppy --fs-uuid --set=root f1c65fc9-acfc-4a39-974b-6c6c38cb29f7
        linux /boot/vmlinuz-2.6.32-220.7.1.el6.i686 root=/dev/sda4
        initrd /boot/initramfs-2.6.32-220.7.1.el6.i686.img


7.Run update-grub2 or grub-mkconfig then grub-install /dev/sda
(replace /dev/sda) with your hard drive if necessary)

8.Reboot and select your new entry. That is it !