Thursday, January 22, 2009

How to setup a https server with apache

Setting up an https server in Apache is easier by watching video. Don't you agree? :)

Saturday, January 10, 2009

Linux 2.6.28's five best features

Created Jan 9 2009 - 3:29pm

While you were likely to be opening up Christmas presents, Linus Torvalds was giving Linux users around the world a special present: the release of the next major Linux kernel: Linux 2.6.28 [1].

We had some time to tinker with this latest and greatest Linux, and it's my kind of Christmas present: solid improvements to my favorite operating system. Here are the five features that I think most of us will appreciate the most as we move into the New Year.


1) Ext4

The next step up in Linux file systems, has finally arrived. Ext4 [2] improves, well, everything about hard drive storage. It gives you larger file-system and file sizes, faster I/O, better journaling, and it can defragment your drive on the fly.

In particular, its delayed allocation functionality greatly improves hard disk write performance. This won't help your PC hard drive that much, but if you're running a database server, you'll see significant improvements. How fast is 'significant?' In my informal tests with MySQL 5.0, I saw write-speed boosts of approximately 30% on a 400GB database. Try it yourself on your servers, you'll be impressed. In addition, since Ext4 can handle up to 1024 petabytes per volume. I expect Ext4 and Sun's ZFS are going to be fighting it out for top server file-system for the next ten-years.


2) GEM Memory Manager for Graphics

Linux is finally getting decent support from the major graphic vendors, like ATI [3] and NVIDIA [4]. That's great, if you have a high-end graphics card with its own memory and processor. But, say you're like the rest of us without much money and you're using the graphics that are built into your motherboard? Linux will run fine on your PC, but your graphics won't be that fast. Until now.

With Linux 2.6.28, GEM (Graphics Execution Manager [5]) Linux finally includes a graphics memory manager. This will matter your graphics memory whether it's on a dedicated card or part of your main memory. By providing a central, common memory manager, GEM enables even ordinary graphics, like the popular and cheap Intel 915 chipset, to run 50% faster [6]. That's a performance boost that anyone can see.

GEM is still very much a work in progress. At this time, only the 915 is fully supported. Other graphic chip developers though are already hard at work getting their drivers to work with GEM. This graphics memory manager will not only make their lives easier, it will also deliver much faster performance for both low-end and top-of-the-line desktop users. In short, GEM may not be much now, but it's going to be a win-win for everyone by this summer.


3) Disk Shock Protection

Ever drop a laptop? I have. So far, I've been lucky and I have smacked a hard drive silly. Laptop vendors know they can't count on everyone being lucky so they've been incorporating drop protection into their notebooks and netbooks.

This works by moving the hard drive read/write heads away from the disk if the laptop detects that it's moving quickly and is likely to be slamming on the floor in a few milliseconds. Until now, though, Linux didn't know a thing about this kind of protection. So, you could end up with Linux trying to get the drive heads to write while the drive firmware was trying to move the out of the way before laptop and concrete had a sudden, violent meeting. Now, Linux will work with most of these fumble-finger proof hard drives. Speaking for klutzes everywhere, I'd like to say thank-you.


4) Staging Drivers

Did you ever want to use a device for Linux where there was 'some' support for it, but it wasn't good enough to be in the main kernel? If you use a lot of new hardware, you've probably been there. As Jake Edge reports [7], "There has been an ongoing struggle between those who want to see drivers get included as quickly as possible versus those who want to see them approach or attain normal kernel quality levels first." He's got that right.

Greg Kroah-Hartman, who has been leading Linux hackers' efforts to create drivers [8], created the -staging tree for these, not quite ready for prime-time drivers. You don't have to use them, but they're available there if you need them. For example, I wanted access to USB/IP. This driver enables you to USB devices over a TCP/IP network. I'm using it to access printers that are attached to a Belkin Network USB Hub [9]. Is it perfect? No. But it does let me get to those printers so that's a win in my book.


5) Network improvements

The 2.6.28 kernel includes new support for UWB (Ultra Wide Band), Wireless USB, UWB-IP, and Nokia's mobile phone Phonet Network Protocol. That's all well and good, but unless you're one of the few who work with UWB or Phonet, I'm not sure how important that will be. I do think Wireless USB will end up being a big deal. That said, what I think is easily the neatest improvement in 2.6.28's improved networking is that it now supports the minstrel Wi-Fi rate control [10].

Chances are you haven't heard about minstrel. Once you have it on your Wi-Fi equipped computer though you'll wonder how you ever lived without it. Minstrel keeps a constant watch on which Wi-Fi AP (access points) in your area are delivering the fastest possible performance and automatically hook you up with it. With minstrel, you're pretty much guaranteed to always get the best Wi-Fi connection that's available. I like this. I like this a lot. Frankly, based on what I've been seeing while using it with my Linux-powered ThinkPad R61, I'd upgrade to 2.6.28 for this feature alone.

So, my advice to you, is that it any of this sounds good, you can either upgrade your PC to Linux 2.6.28 manually, which is what I did, or you can start encouraging your favorite Linux distribution group to move to 2.6.28 sooner rather than later. You'll be pleased you did.



Source URL:
http://blogs.computerworld.com/linux_2_6_28s_five_best_features

Links:
[1] http://lkml.org/lkml/2008/12/24/105
[2] http://ext4.wiki.kernel.org/index.php/Main_Page
[3] http://practical-tech.com/infrastructure/amd-partners-with-novell-to-open-source-ati-graphic-drivers
[4] http://www.nvidia.com/object/unix.html
[5] http://lwn.net/Articles/283793
[6] http://lwn.net/Articles/283798
[7] http://lwn.net/Articles/301192
[8] http://practical-tech.com/infrastructure/linux-hackers-offer-to-create-device-drivers-for-free
[9] http://www.belkin.com/networkusbhub
[10] http://wireless.kernel.org/en/developers/Documentation/mac80211/RateControl/minstrel

Sunday, December 21, 2008

How to connect to the internet using Celcom Broadband Modem

Luckily, I got my hand on my friend's Celcom Broadband USB HSDPA Modem. The model is E220. Fortunately on Mandriva, you don't need to type a command. It's all in the comfort of GUI.

below is the step-by-step process:

1. Open MCC (Mandriva Control Center) and then select Network & Internet (left frame) and then open Setup a new network interface.


2. Select GPRS/Edge/3G and click Next button.


3. The device should be shown and selected here. If not, you have to check whether Linux detected it using lsusb command. In many cases, this shouldn't be a problem for Linux detecting a USB device. Then click the Next button.


4. It will ask you for PIN number. One problem here. You have to enable PIN Protection for your card by going into MS Windows and use the software provided by TM to enable the PIN Protection. It is disabled by default. If it is disabled, you will get error after this even the PIN number is correct. After enable the PIN Protection, you can boot back into Linux and enter the PIN number as in the pic below. Then click Next.


5. This dialog opens and you can just click Next.


6. Select the option as below and then click Next.


7. For dialog as below, just leave all fields blank. Click Next.


8. Finish. A window will appear telling you that the settings has been configured successfully. Click Finish button to close it.

9. You can see the /var/log/messages on what's been going on and important info like IP address, APN, netmask, gateway and handshakes during the connection process.

Example log:
Dec 21 23:50:42 localhost ifup-ppp: pppd started for ppp0 on /dev/ttyUSB0 at 115200
Dec 21 23:50:42 localhost pppd[2605]: pppd 2.4.4 started by root, uid 0
Dec 21 23:50:49 localhost pppd[2605]: Serial connection established.
Dec 21 23:50:49 localhost pppd[2605]: Using interface ppp0
Dec 21 23:50:49 localhost pppd[2605]: Connect: ppp0 <--> /dev/ttyUSB0
Dec 21 23:50:53 localhost pppd[2605]: Could not determine remote IP address: defaulting to 10.64.64.64
Dec 21 23:50:53 localhost pppd[2605]: local IP address 10.58.182.246
Dec 21 23:50:53 localhost pppd[2605]: remote IP address 10.64.64.64
Dec 21 23:50:53 localhost pppd[2605]: primary DNS address 202. 188.0.133
Dec 21 23:50:53 localhost pppd[2605]: secondary DNS address 202.188.1.5

That's all there is to it. Good luck guys!

Friday, December 12, 2008

Queuegraph - a RRDtool frontend for Postfix queue-statistics

queuegraph is a very simple mail statistics RRDtool frontend for Postfix that produces daily, weekly, monthly and yearly graphs of Postfix's active, deferred, incoming and bounce queues.The postfix's queue is usually in /var/spool/postfix. queuegraph is created by Ralf Hildebrandt and based on mailgraph by David Schweikert. Below is the dirs in my system:

# ls /var/spool/postfix/
active/ corrupt/ deferred/ etc/ flush/ incoming/ maildrop/ postgrey/ public/ tmp/ var/
bounce/ defer/ dev/ extern/ hold/ lib64/ pid/ private/ saved/ trace/
#

In connection with qshape it can be used to find out if your server is having performance issues:
  • a large deferred queue indicates delivery problems
  • a large active queue points to slow destinations (e.g. a content_filter)
You can download queuegraph here.

Before you download it, pls check the requirements:
  • rrdtools (Mandriva users: urpmi rrdtool)
  • librrds-perl (Mandriva users: urpmi perl-rrdtool)
After finish downloading it, extract it: tar xzvf queuegraph.tar.gz
List down the extracted files: ls -l (see below)

# ls
queuegraph.cgi* queuegraph-rrd.sh* README
#

Create a cronjob that runs queuegraph-rrd.sh every minute -- this populates the *.rrd database:

* * * * * /usr/local/bin/queuegraph-rrd.sh

Note: On Mandriva, i created a dir under /etc named cron.minutes and copied file queuegraph-rrd.sh into it: cp queuegraph-rrd.sh /etc/cron/minutes

And then I edited crontab by adding this line:
* * * * * root nice -19 run-parts --report /etc/cron.minutes

Then I copied queuegraph.cgi into the cgi-bin directory of my webserver: cp queuegraph.cgi /var/www/cgi-bin/ or where your webserver's cgi directory is (consult your distro manual.) Then chmoded it to 755 so that my webserver can run it: chmod 755 queuegraph.cgi

To see the statistics created by queuegraph, point your web browser to http://yourwebseraddress/cgi-bin/queuegraph.cgi

This is the graph for my postfix queue (without the Month and Year graph):


That's all there is to it.

Wednesday, November 19, 2008

sdparm: a utility for SCSI device

You may have heard of hdparm - a utility for getting info and changing certain parameters for IDE-type hard disk. It can't be used for SCSI hard disk though. So is there any similar utility for scsi hard disk? Yes there's one utility called with almost the same name: sdparm.

You may think that it has the same or at least similar to hdparm. No it is not. Well let's see what we can do with it below.

How to install it?
Ubuntu/Debian: apt-get install sdparm
Mandriva: urpmi sdparm
Redhat: yum install sdparm

A few examples:
list common mode parameters of a disk
sdparm /dev/sda

Sample output:
/dev/sda: COMPAQ BF03697B5A HPB2
Read write error recovery mode page:
AWRE 1 [cha: y, def: 1, sav: 1]
ARRE 1 [cha: y, def: 1, sav: 1]
PER 1 [cha: y, def: 1, sav: 1]
Caching (SBC) mode page:
WCE 0 [cha: y, def: 1, sav: 0]
RCD 0 [cha: y, def: 0, sav: 0]
Control mode page:
SWP 0 [cha: y, def: 0, sav: 0]
Informational exceptions control mode page:
EWASC 1 [cha: y, def: 1, sav: 1]
DEXCPT 0 [cha: y, def: 0, sav: 0]
MRIE 4 [cha: y, def: 4, sav: 4]


To list the designators within the device identification VPD page of a disk
sdparm --inquiry /dev/sda

Sample output:
/dev/sda: COMPAQ BF03697B5A HPB2
Device identification VPD page:
Addressed logical unit:
id_type: EUI-64 based, code_set: Binary
[0x0010b9fd080c1129]
id_type: T10 vendor identification, code_set: ASCII
vendor id: COMPAQ
vendor specific: E20C9MKK


To see all parameters for the caching mode page
sdparm --page=ca /dev/sdc

Sample output:
/dev/sda: COMPAQ BF03697B5A HPB2
Caching (SBC) mode page:
IC 0 [cha: y, def: 0, sav: 0]
ABPF 0 [cha: n, def: 0, sav: 0]
CAP 0 [cha: n, def: 0, sav: 0]
DISC 0 [cha: n, def: 0, sav: 0]
SIZE 0 [cha: y, def: 0, sav: 0]
WCE 0 [cha: y, def: 1, sav: 0]
MF 0 [cha: y, def: 0, sav: 0]
RCD 0 [cha: y, def: 0, sav: 0]
DRRP 0 [cha: y, def: 0, sav: 0]
WRP 0 [cha: y, def: 0, sav: 0]
DPTL 512 [cha: y, def:512, sav:512]
MIPF 256 [cha: y, def:256, sav:256]
MAPF 512 [cha: y, def:512, sav:512]
MAPFC 512 [cha: y, def:512, sav:512]
FSW 0 [cha: n, def: 0, sav: 0]
LBCSS 0 [cha: y, def: 0, sav: 0]
DRA 1 [cha: y, def: 1, sav: 1]
NV_DIS 0 [cha: n, def: 0, sav: 0]
NCS 226 [cha: y, def:226, sav:226]
CSS 0 [cha: y, def: 0, sav: 0]

To set the "Writeback Cache Enable" bit in the current values page
# sdparm --set=WCE /dev/sda

Sample output:
/dev/sda: COMPAQ BF03697B5A HPB2

References:
Cyberciti.biz
sdparm manpage

Monday, November 3, 2008

NAT and ip forwarding

NAT (be it SNAT or DNAT) relies on ip forwarding. You enable it, they are effective. I forgot to think about it last time ( I think 3 months ago) I setup Linux as a router. This is because server distros, enable it by default. Some distros however do not and most of them distros targeted for desktop/home users (pls check all popular distros to confirm). To enable it, you have to run this 2 commands:

sysctl -w net.ipv4.ip_forward=1
sysctl -p /etc/sysctl.conf

Of course you have to root to run those.

The first command is to write 1 in /proc/sys/net/ipv4/ip_forward. It is equivalent to this command:

echo 1 > /proc/net/ipv4/ip_forward

The second command is to apply all changes in file /etc/sysctl.conf.

Whatever you set in sysctl.conf will be applied every system restart. So that's important if you want to enable it permanently as in the case of a router. First command doesn't do that. You have to edit sysctl.conf to make it permanent because it will be read every system restart. Edit the file with your favorite text editor (i personally use joe) and make sure it contains this line:

net.ipv4.ip_forward = 1

This is just a quick solution for this topic. It doesn't cover everything you should know about sysctl.conf and ip forwarding. You can just google to find more info about them.

Tuesday, October 28, 2008

FOSS.my 2008



What is FOSS.my?

(excerpt from the website)
FOSS.my 2008 is Malaysia’s premier Free and Open Source Software (FOSS) event. Whilst this is our first go at it, we aim for this to be an annual event bringing together professionals and enthusiasts from Malaysia, Singapore, Asia and the rest of the world for a two day grassroots driven FOSS conference.

FOSS.my is different from other events in that we focus only on FOSS and that this conference is purely non-commercial. There will be no marketing/sales talks by vendors (we are very strict on this!) so all that is presented is FOSS goodness! Instead, vendors will be encouraged to speak on the FOSS technical aspects of their projects/tools. This approach works better as it benefits all through knowledge sharing within the community.


When?
It will be held on 8 and 9 Nov 2008


Where? ( Map )
APIIT TPM Campus
Lot 6, Technology Park Malaysia (TPM)
Bukit Jalil, 57000 Kuala Lumpur
Malaysia.


What are the agenda?
Go here: http://foss.my/schedule/ for more info.


What should I do?
Register here: http://foss.my/register/

Nvidia new hotplug feature on Linux

 If you use nvidia driver for your GPU, you probably wonder why in some config, you can't hotplug your second monitor. You need to reboo...