Battery info button on HP elitebook 6930p

Keymap for laptop keyboard is fun especially there are lots of default actions attached to it. One particular key, FnF8, which has tiny battery icon is not mapped to any action. It has a keycode of 137 on HP elitebook 6930p. I decided to bind the keycode to call up kpowersave information dialog since I am using KDE4 as desktop manager. But how to call up only kpowersave information dialog? Running command “kpowersave” will only trigger another instance of kpowersave.

I tried to use qdbus but could not find suitable dbus object to display kpowersave information dialog. Nevertheless qdbus is quit handy when come to change power profile of kpowersave.

qdbus is a no go for this purpose. I had to look for something else. Luckily, it did not take much of my time searching. “dcop” is it! dcop kpowersave KPowersaveIface showDetailedDialog will display kpowersave information dialog. Awesome!

I edited keytouch keyboard with these lines.

<key>
<name>battery</name>
<scancode>137</scancode>
<keycode>PROG2</keycode>
<default-action>dcop kpowersave KPowersaveIface showDetailedDialog</default-action>
</key>

Reactivated keytouch, the nifty application to map your multimedia keyboard. This is the result of pressing FnF8.

Nice eh?

September 16th, 2009, posted by Kevin Foo (chfl4gs_)

FreeBSD : zapping file system error

My box crashed many times last week until its file system had inconsistency issue. In another words, it is corrupted. Even manual fsck won’t help fixing the issue. The problem appeared to be a directory had its “.” file missing!! Whenever I tried to remove the directory, “rm” with force option or “rmdir” utilities just complained about “bad file descriptor” and did nothing! Shit happened… Log is showing the error.

Aug 22 13:20:11 zeus fsck: /dev/label/usr: SETTING DIRTY FLAG IN READ_ONLY MODE
Aug 22 13:20:11 zeus fsck:
Aug 22 13:20:11 zeus fsck: /dev/label/usr: UNEXPECTED SOFT UPDATE INCONSISTENCY; RUN fsck MANUALLY.
Aug 14 03:15:18 zeus fsck: /dev/label/usr: 551052 files, 6960462 used, 14873313 free (244305 frags,
1828626 blocks, 1.1% fragmentation)

The solution is rather simple. Just use a handy utility, clri(8), to clear the corrupted inode. Reboot the box into single user mode and run fsck_ufs -y /dev/label/usr. fsck(8) will provide you the inode number which is corrupted.

Its usage is simple
clri special_device inode_number

In my case (i have geom_label. Thus, you are seeing /dev/label/usr here.):-
clri /dev/label/usr 5111832

Exit single user mode, login as usual and run “rm” or “rmdir” to remove the directory. Voila! A word of advice, messing around with inode is the least thing that you want to do. In any case, BACK UP YOUR STUFF BEFORE YOU ATTEMPT ANYTHING. YOU ARE WARNED!

August 25th, 2009, posted by Kevin Foo (chfl4gs_)

looks like me, sounds like me, but it ain’t me!

Just came across this picture today on Exabytes site.

Who do you think is this? :)

PS : geek00l said that person in the picture is not him!!! :)

August 21st, 2009, posted by Kevin Foo (chfl4gs_)

No internet filter? Are you sure?


themalaysianinsider.com ran a flip-flop story on Malaysian Internet censorship. “N” dude has firmly denied a plan to police the Internet citing technical obstacles and strong public displeasure over it. But “R” chap confirmed a possible “green dam” review and the government only intended to block access to pornographic sites. An obvious lack of communication within the ministers and government departments? Now let me show you what the “TM” dudes are doing.

dig @202.188.0.133 gutteruncensored.com ANY

; <<>> DiG 9.4.3-P2 <<>> @202.188.0.133 gutteruncensored.com ANY
; (1 server found)
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15423
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;gutteruncensored.com. IN ANY

;; ANSWER SECTION:
gutteruncensored.com. 3600 IN SOA ns1.blocked. blocked.tm.net.my. 1 900 600 86400 3600
gutteruncensored.com. 3600 IN NS ns1.blocked.
gutteruncensored.com. 3600 IN A 127.0.0.1

;; Query time: 27 msec
;; SERVER: 202.188.0.133#53(202.188.0.133)
;; WHEN: Sun Aug 9 15:15:01 2009
;; MSG SIZE rcvd: 132

Brilliant… filter via fake DNS records. Some of the gutteruncensor.com readers from Malaysia might have noticed this a week ago. Probably, the “TM” dudes decided, “Since MCMC is sleeping, screw both “N” and “R” dudes. Let them say what they wanted. I’m going ahead with my filtering Kung fu.” :)

August 9th, 2009, posted by Kevin Foo (chfl4gs_)

Quick note on Xen P2V migration


I had migrated some of the old machines at work to Xen hypervisor VM. The procedure is rather straight forward and with many options. In this post, I used simple dd command to migrate physical machine to a flat file image on Xen server.

DD IN ACTION

debian-HP370:~/ # dd if=/dev/cciss/c0d0 | ssh me@xenserver dd of=/home/xen/img/debian-HP370.img

This will take a long time depending on your disk size/network speed. So leave it there and go on with other stuff. After a couple of hours, you have the image transferred to Xen server.

TAILORING TO VM ENVIRONMENT

As the physical machine has smart array raid and VM has choices of disk options: IDE, SATA, physical partition under the VM guest, I mounted the image and edit /etc/fstab to reflect disk on VM. Mounting an image file with many partitions is simple. Firstly, offset value of the partition is required. This can be obtained via fdisk command.

xenserver:/home/xen/img # fdisk -lu debian-HP370.img
You must set cylinders.
You can do this from the extra functions menu.

Disk debian-HP370.img: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x111f5759

Device Boot Start End Blocks Id System
debian-HP370.imgp1 * 63 102269789 51134863+ 83 Linux
debian-HP370.imgp2 102269790 106655534 2192872+ 5 Extended
debian-HP370.imgp5 102269853 106655534 2192841 82 Linux swap / Solaris

The offset value in this example is 63 * 512 = 32256

Note : 63 is the Start sector of the partition that I wanted to mount.

xenserver:/home/xen/img # mount -o loop,offset=32256 debian-HP370.img /mnt/stuff

Next, you can just vi /mnt/stuff/etc/fstab, to suit your Xen VM configurations. We are almost done.

CREATING NEW VM

Creating a new VM is rather easy. You need a configuration file for VM guest. Please refer to example and wiki for complete parameters. Just run xm new <configure file> i.e. xm new debian-vmconfig or else use vm-install and be prompted with bunch of questions for configuration parameters. Sample HVM configuration file for my VM:-

name=”Linux-debian-HP370″
memory=1024
maxmem=2048
vcpus=2
on_poweroff=”destroy”
on_reboot=”restart”
on_crash=”destroy”
localtime=0
keymap=”en-us”

builder=”hvm”
extid=0
device_model=”/usr/lib/xen/bin/qemu-dm”
kernel=”/usr/lib/xen/boot/hvmloader”
boot=”c”
disk=[ 'file:/home/xen/img/debian-HP370.img,sda,w', ]
vif=[ 'mac=00:16:3e:51:16:ee,bridge=br0,model=e1000', ]

stdvga=0
vnc=1
vncunused=1
apic=1
acpi=1
pae=1

serial=”pty”

START THE MACHINE, LITERALLY

At this point of time, you should turn off the physical machine to avoid IP address clash. There is one last step to go which is the editing grub on VM. You could just fire up the new guest VM with xm start Linux-debian-HP370 && xm console Linux-debian-HP370 and hit “e” at GRUB menu to edit kernel parameter for root disk. Lastly, modify /boot/grub/menu.lst to reflect your root partition. Remember to run update-grub after finished editing.

OPTIONAL

Since my xen is a headless box, I have to go extra mile to get into the console by ssh tunnel.

ssh me@xenserver -L 5900:127.0.0.1:5900

Connect vnc to localhost will give you the new shinny VM console.

July 24th, 2009, posted by Kevin Foo (chfl4gs_)

FreeBSD : simple lagg usage


The link aggregation and link failover interface, lagg(4) device, first appeared in FreeBSD 6.3. It as the name suggested allows aggregation of multiple network interfaces as one virtual lagg(4) interface for the purpose of providing fault-tolerance and high-speed links. The driver currently supports the aggregation protocols such as failover, fec, lacp, loadbalance, roundrobin, and none by detecting child interface link state.

This is useful in large enterprise environment. Nonetheless, you can use it to set up roaming between wired and wireless network. The lagg(4) manpage provides simple example. However, it states that

WPA security does not currently work correctly with a wireless interface added to the lagg port.

Well, it is easy to overcome the issue by use of wpa_supplicant(8). Just set up /etc/wpa_supplicant.conf as normal. Please refer to wpa_supplicant.conf manpage for detailed setup. Here is my example.

/etc/wpa_supplicant.conf :-

ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel
ap_scan=1
network={
       ssid="MY_WPA_WIFI"
       scan_ssid=1
       key_mgmt=WPA-PSK
       psk="verysecretpassword"
}

/etc/rc.conf :-

ifconfig_nfe0="DHCP"
ifconfig_ndis0="WPA DHCP"
cloned_interfaces="lagg0"
ifconfig_lagg0="laggproto failover laggport ndis0 laggport nfe0 DHCP"

Relevant ifconfig output :-

ndis0: flags=8843 metric 0 mtu 1500
        ether 00:1a:73:73:92:34
        media: IEEE 802.11 Wireless Ethernet autoselect
        status: associated
        ssid "MY_WPA_WIFI" channel 1 (2412 Mhz 11b)
        authmode OPEN privacy OFF bmiss 7 scanvalid 60 roaming MANUAL
        bintval 0
        lagg: laggdev lagg0
nfe0: flags=8843 metric 0 mtu 1500
        options=8
        ether 00:1a:73:73:92:34
        media: Ethernet autoselect (none)
        status: no carrier
        lagg: laggdev lagg0
lagg0: flags=8843 metric 0 mtu 1500
        ether 00:1a:73:73:92:34
        inet 192.168.1.5 netmask 0xffffff00 broadcast 192.168.1.255
        media: Ethernet autoselect
        status: active
        laggproto failover
        laggport: nfe0 flags=0<>
        laggport: ndis0 flags=5
tun0: flags=8010 metric 0 mtu 1500

It is that easy. Your laptop will auto roam between wired and wireless connection.

July 12th, 2009, posted by Kevin Foo (chfl4gs_)

NetBSD 5.0


NetBSD 5.0 released and I have downloaded iso for i386 and amd64 arch. If you are staying in Malaysia, you can leech from my site. :)

http://ms.shit.la/netbsd/i386cd-5.0.iso
http://ms.shit.la/netbsd/i386cd-5.0.iso.MD5
http://ms.shit.la/netbsd/i386cd-5.0.iso.SHA1

http://ms.shit.la/netbsd/amd64cd-5.0.iso
http://ms.shit.la/netbsd/amd64cd-5.0.iso.MD5
http://ms.shit.la/netbsd/amd64cd-5.0.iso.SHA1

April 30th, 2009, posted by Kevin Foo (chfl4gs_)

FreeRapid downloader

Quite often, most of us download files from file-hosting sites like Rapidshare, Megaupload, Ziddu, kewlshare, Badongo and etc. You are probably annoyed and sick of restriction, time wait, captcha enforced by these service providers. To avoid all those and have a hassle free download, you could probably subscribe to their service. Here is another alternative. Let this shinny little piece of java software manages it for you. Take a peek at FreeRapid downloader.

There are currently 79 file hosting sites supported and it works on Windows, Mac, Linux, BSD and other Unix-variants. Sweet!!!! Just what I needed. For FreeBSD, you need diablo-jdk (I have tested with diablo-jdk-1.6.0.07.02_4). Just download the package, unzip and run frd.sh. If you jre is not defined in $PATH environment, you have to edit frd.sh to have for example

PATH=/usr/local/diablo-jdk1.6.0/jre/bin:$PATH

Screenshot

A list of sites that are currently supported (not a complete listing)
* Rapidshare.com (+ premium)
* MegaUpload.com
* Megarotic.com and Sexuploader.com
* NetLoad.in
* MediaFire.com
* FileFactory.com
* Filebase.to
* Uploaded.to
* DepositFiles.com
* Share-online.biz
* Egoshare.com
* Easy-share.com
* Letibit.net
* XtraUpload.de
* Shareator.com
* Kewlshare.com
* SaveFile.com
* Ziddu.com
* 4shared.com
* Load.to
* UploadBox.com
* UGotFile.com new
* NetGull.com new
* Plunder.com new
* FileUpload.net new
* WebShare.net
* FileSend.net
* 2Shared.com
* Uploading.com
* Yourfiles.biz
* Ultrashare.net
* SendSpace.com
* Wiiupload.com
* Badongo.com new
* Hotfile.com new
* WikiUpload.com new
* DataUp.de new
* Rapidshare.de
* Uppit.com
* FileFlyer.com
* BitRoad.net
* Jandown.com
* iFile.it
* Iskladka.cz
* HellShare.com (+full)
* QuickShare.cz
* Uloz.to
* Sdilej.cz new
* Uloz.cz
* Share-rapid.com
* Nahraj.cz
* FlyShare.cz
* Edisk.cz
* Bagruj.cz
* LeteckaPosta.cz
* CZShare.com free (+profi)
* Subory.sk
* Upnito.sk
* CobraShare.sk
* Ulozisko.sk
* Stream.cz (video)
* O2MusicStream.cz (video) new
* YouTube.com (video)new
* Usercash.com (crypter)
* Tinyurl.com (crypter)
* Linkbucks.com (crypter)
* RSMonkey.com (crypter)new
* Radikal.ru (crypter)
* Paid4share.com (crypter) new

April 30th, 2009, posted by Kevin Foo (chfl4gs_)

FreeBSD : web cluster – Frontend nginx, backend apache with SSL


Previously, I posted write-up on glusterfs on FreeBSD clusters. Here the installment on round-robin web proxy part. In my configuration, nginx is running as front-end and apache is the back-end. Both boxes have same configuration on nginx and apache. Nginx SSL cert and key should be the same as well (with same common name i.e. www.yourdomain.com).

APACHE
I will skip most of the apache installation part as it is too common and easy to set up. The basic requirement for apache is to run with SSL on port 8443. Please take note that mod_rpaf is required for apache to capture the real IP address of the visitors. Install it from /usr/ports/www/mod_rpaf2. Then add these lines to your httpd.conf.


LoadModule rpaf_module       libexec/apache22/mod_rpaf.so

<IfModule rpaf_module>
RPAFEnable On
RPAFsethostname On
RPAFproxy_ips 192.168.100.82 192.168.100.84
</IfModule>

Note:
IP address for node 1 = 192.168.100.82
IP address for node 2 = 192.168.100.84

NGINX (engine X)
Installation of nginx is fairly simple under FreeBSD as the ports is complete (no messy manual patching and stuff). Just run the installation with this command. But take note that you need these two options: HTTP_SSL_MODULE and HTTP_UPSTREAM_FAIR. Yes, you need them.

cd /usr/ports/www/nginx && make install

The configuration file, nginx.conf, is relatively easy to understand if you are fimilar with lighttpd or apache mod_proxy. The following is an example of nginx config file. Remember, use with care because YMMV.

user  www;
worker_processes  4;

events {
    worker_connections  4096;
}                            

http {
    include       /usr/local/etc/nginx/mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  5;
    gzip  on;
    upstream backend_servers {
        fair;
        server 192.168.100.82:8443;
        server 192.168.100.84:8443;
    }                                                 

    server {
        listen   80 default;
        server_name  _;
        server_name_in_redirect  off;
        access_log /var/log/nginx-access.log;
        error_log /var/log/nginx-error.log;
        location / {
                proxy_pass https://backend_servers;
                proxy_set_header   Host             $host;
                proxy_set_header   X-Real-IP        $remote_addr;
                proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
                proxy_connect_timeout      5;
                proxy_send_timeout         5;
                proxy_read_timeout         5;
        }
    }                                                                              

    server {
        listen       443 default;
        server_name  _;
        server_name_in_redirect  off;
        access_log /var/log/nginx-ssl-access.log;
        error_log /var/log/nginx-ssl-error.log;
        ssl                  on;
        ssl_certificate      /etc/ssl/certs/nginx-cert.pem;
        ssl_certificate_key  /etc/ssl/keys/nginx-key.pem;
        ssl_session_timeout  5m;

        ssl_protocols  SSLv2 SSLv3 TLSv1;
        ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
        ssl_prefer_server_ciphers   on;

        location / {
                proxy_pass https://backend_servers;
                proxy_set_header   Host             $host;
                proxy_set_header   X-Real-IP        $remote_addr;
                proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
                proxy_connect_timeout      5;
                proxy_send_timeout         5;
                proxy_read_timeout         5;
        }
    }
}

Vhost is managed by apache httpd. Thus these lines are needed in nginx.conf.

server_name  _;
server_name_in_redirect  off;

For SSL cert and key generation, please refer to previous post, glusterfs on FreeBSD. That’s it.

April 22nd, 2009, posted by Kevin Foo (chfl4gs_)

FreeBSD : nginx with php-cgi on unix socket

UPDATE : Check out recent committed /usr/ports/www/spawn-fcgi/, it comes with a better spawn-fcgi rc.d script. Please use the script from the post. However, the spawn-fcgi.sh provided does not have option to run via unix socket. I have submitted the patch.

Few days ago, I posted a write-up, FreeBSD : php-cgi spawn-fcgi rc.d script for nginx, on running php-cgi on port 8888. But how do I run it via unix socket? It is trivial with spawn-fcgi rc.d script. Just add the flags to /etc/rc.conf

spawnfcgi_flags="-s /tmp/php-fastcgi.socket -u www -g www -f /usr/local/bin/php-cgi"

Next, replace the line

fastcgi_pass 127.0.0.1:8888;

with this

fastcgi_pass unix:/tmp/php-fastcgi.socket;

Lastly restart both php-cgi and nginx:

/usr/local/etc/rc.d/spawnfcgi restart && /usr/local/etc/rc.d/nginx restart

That’s all. You have your php-cgi on unix socket.

April 17th, 2009, posted by Kevin Foo (chfl4gs_)