jump to navigation

Apache Reverse Proxy to VirtualHost- Centos 25 October 2010

Posted by Maulvi Bakar in : Linux , add a comment

This is a classic ones. I first encountered this, apply it and forgotten about it.

Always – always – always remember to specify into “/etc/httpd/conf/httpd.conf” the option below –

NameVirtualHost *:80

Then, create the individual “VirtualHost” entries either within the httpd.conf or as separate entries in “/etc/httpd/conf.d/”

ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /www/docs/dummy-host.example.com
ProxyPass / http://x.x.x.x:8080
ProxyPassReverse / http://x.x.x.x:8080
ServerName dummy-host.example.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common


Centos Public Mirror – http://centos.maulvi.net 15 October 2009

Posted by Maulvi Bakar in : Linux,Society,System , 1 comment so far

To the world..

I present the Centos Public Mirror hosted on http://centos.maulvi.net

Basically, I’ve been installing and re-installing centos over and over and over..  Also, at any one time, I have a bunch of centos boxes running both physically and virtually.  This prompts me to run my own centos mirror.  It’s twofold – it saves time and make it easier for me to simply grab any packages.

Then I had a revelation – after leeching from the community, it’s time to give back something… This mirror is one small way I could do to give back and with a big THANK YOU to the wonderful centos linux community.


Creating a new Linux RAID1 device and extending an existing LVM Volume onto it. RHEL/Centos 5 13 June 2009

Posted by Maulvi Bakar in : Linux,System , add a comment

I’m seriously into server consolidation and virtualization.  I’m going to eliminate my other VMWare server and just concentrate on one.

First order of the day is to upgrade the RAM and Available HDD space. Upgrading the RAM is simple enough, just add/replace the modules.

Expanding the available space is another matter.  This is actually an extension of my previous posting – New HDD, enlarging Red Hat/Centos ext3/lvm partition, but there’s another factor in the equation, RAID1 (Mirroring) devices.

The existing root partition resides in an LVM partition which in turn resides in a RAID1 (Mirroring) Multi-Disk (MD) partition which is based on a twin 400GB HDD configuration.

I’ve acquired a pair of 500GB HDDs. Now to extend the existing LVM ontothe newly acquired disks in a RAID1 configuration.

Step 1 is to create Software RAID partitions on the said disks –
# fdisk /dev/sdc
# fdisk /dev/sdd

Create a new ‘sdc1’ and ‘sdd1’ partitions using type FD, which is Linux RAID Autodetect.

Next, we need to create the Multi-Disk Volume –
# mdadm --create /dev/md2 --level=1 --raid-devices=2 /dev/sdc1 /dev/sdd1
Since I already have ‘md0’ for my ‘/boot’ and ‘md1’ is the existing volume with the existing LVM that was the intended target for expansion, thus naturally I’m using ‘md2’.

Basically, I am creating ‘md2’ device in RAID1 configuration using 2 devices namely ‘/dev/sdc1’ and ‘/dev/sdd1’.

You can monitor the status of your RAID devices using ‘/proc/mdstat’ –
# cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sdd1[1] sdc1[0]
487331648 blocks [2/2] [UU]
[>....................] resync = 1.9% (9622656/487331648) finish=90.0min speed=88417K/sec

The steps here onwards are basically the same as previously mentioned here, the only difference is the ‘/dev/md2’ device is the target.

To start, we need to create a Physical Volume within the newly created ‘/dev/md2’ RAID device.
# pvcreate /dev/md2

After that we will extend the existing volume ‘VolGroup00? onto the newly created physical volume.
# vgextend VolGroup00 /dev/md2

Once done, the next step is to extend the Logical Volume within the volume group to use the free space newly made available when you extend the volume group previously.
# lvextend /dev/VolGroup00/LogVol00 /dev/md2
Here is the difference where I did not specify the space size to extend as the default will be to use all available spaces.

And finally, we’ll enlarge the ext3 partition to make use of the newly available free space in the logical volume.
# resize2fs /dev/VolGroup00/LogVol00


Changing user’s file ownership across the board 25 December 2008

Posted by Maulvi Bakar in : Linux,Unix,Work , add a comment

The guys from the promised database lands had their systems acting funny.  After investigation, they found out that, their files was having the wrong group ownership.

There’s a total of 70,000 files involved.  Promised lands or not, manually changing 70,000 files (and folders) is not a good prospect.  Well, I could go through the individual sub-folders but I would need to work from the last in-depth sub-folders and work my way out.  Even that does not guarantee accuracy, since there might be sub-folders with multiple owners which I’m not suppose to touch.  When that happen, then I have to go through it manually looking at each files and folders individually – not good.

There has to be a short-cut.

I know I can locate all the files that needs to be changed it’s ownership by using the following commands –
find ./ -user someuser -group wronggroup -print

It’ll list all the relevant files and sub-folders. At first, maybe I’ll output it into a file, all the results. Manipulate the file into an executable. Append each lines with a “chgrp correctgroup” and have something like – “chgrp correctgroup ./to/the/path/of/the/file”.

I am smart, hey! 😉

Let’s prove that I can be smarter  😛

Vanity and pride are different things, though the words are often used synonymously. A person may be proud without being vain. Pride relates more to our opinion of ourselves; vanity, to what we would have others think of us.

Jane Austen

No, I’m just trying to figure out the best way of doing things.

“xargs -t <commands>”

xargs is a command of Unix and most Unix-like operating systems. It is useful when one wants to pass a large number of arguments to a command. Arbitrarily long lists of parameters can't be passed to a command, so xargs will break the list of arguments into sublists small enough to be acceptable.

xargs - build and execute command lines from standard input

The “-t” is for the verbose option. It’ll spew out the output of the commands being executed.

Basically, every time the output of the earlier “find”, it’ll append the extra commands specified and have it executed. Voila, no need to make a separate executable. My solution is thus –

find ./ -user someuser -group wronggroup -print | xargs -t chgrp correctgroup

Happy 4th Anniversary to myself  😉

Merry Christmas everyone!


Linux sparse file in /var/log/lastlog using RHEL3 19 November 2008

Posted by Maulvi Bakar in : Linux,Work , add a comment

The guys in the promised backup lands had their heads scratching.  Their backups seems to bloat an extra 1.2TB in size!  The culprit seems to be the


Lastlog is sparse file which contains unallocated blocks or “empty space” and it does not actually take up filesystem space.  Simple test like thus will have a very straightforward results –

$ du -H /var/log/lastlog
156kB   /var/log/lastlog

Furthermore, “lastlog” is a file that almost never grow anyway. A common issue apparently.

Usually it is suggested that either the file be excluded from the backup excercise or, if policy-wise not possible, then the backup application to be configured to handle the specific sparse file, in this case “lastlog”.

Sparse files can confuse some backup software. Usually tools like GNU tar requires the use of the -S parameter to fix it. If you are using some other software, consult the backup software’s manuals for options on how to deal with sparse files.


RHEL4 U5 Install, Boots Up with “GRUB” error on screen. 29 October 2008

Posted by Maulvi Bakar in : Linux,Work , 1 comment so far

This one is a funny error. After finishing the installation, the system reboots and ‘poof’ on screen only displays “GRUB”.

My suspicion is that, GRUB somehow or rather did not install properly onto MBR. Considering previously that the system comes only with a single harddisk. Later on, after fixing a second harddisk, the OS was re-installed with RAID1. Maybe that’s the cause as the old GRUB was not properly overwritten.

Basically, I re-insert the installation CD and boot up into rescue mode.
linux rescue

Upon boot up, mount the filesystem thus –
# chroot /mnt/sysimage

Use grub the regenerate the grub stuff on both hdds thus –
# grub

On the grub command line, select the 1st harddisk
grub> root (hd0,0)

Initialize grub onto the 1st harddisk
grub> setup (hd0)

Do the same for the 2nd harddisk
grub> root (hd1,0)
grub> setup (hd1)

Exit the grub menu –
grub> exit

Reboot the system and your grub should behave normally now..


Time Travelling in VMware Server for Linux (Guest & Host) 6 August 2008

Posted by Maulvi Bakar in : Home,Linux,Work , 2 comments

I run two VMware host machines at home. This is where I do most of my ‘Training’. Well, most of my knowledge on Linux are self-learned anyway. This is where I do my R&D.

Simply, theory is good. But how do you know whether the theory is practical? What potential pitfalls when you deploy a solution? Especially Free (Libre) and Open Source Solutions? Not to say FLOSS solutions are no good, but in a commercial environment, when paying customers are willing to pay good money to transfer their operational risks to you, you better be sure of the solution that you’re proposing.

FLOSS solutions backed by commercial vendors – eg. Red Hat, is a safe bet. You can propose it to customers and as a fall back, there’s always Red Hat. Problem starts with FLOSS solutions that specifically states – ‘No warranty/guarantee of any kind’ 😛

Not to say they’re no good, mind you. That’s where you as a FLOSS Service Provider comes in. To provide the kind of warranty/guarantee that the customer wants for such FLOSS solutions. The other advantage of FLOSS, if the customer’s not happy with a FLOSS vendor, being FLOSS, you can always go to another vendor. That forces FLOSS vendors to always provide the best service.

Anyway, I’m rambling and digressing –

My guest OSes keep travelling faster than my host OS, sometimes as fast as 2 seconds every 10 seconds. Need to tune the VMware server host a bit –

file – /etc/vmware/config

host.cpukHz = 3400000
hostinfo.noTSC = TRUE
tools.syncTime = TRUE

The first line is to specify the maximum CPU clock rate the system may run.
Second line is to specify that the cpu is not running at a constant clock rate (speedstep, cpufreq or power management is active when idle) and the timestamp counter is inaccurate an to use it as the least.
The last line sets the default to use vmware-tools timesync function.

Well, I hope this is a permanent solution.


Linux NFS Server, AIX NFS Client 31 July 2008

Posted by Maulvi Bakar in : Linux,Unix,Work , 3 comments


We have a Linux NFS machine to extend the AIX Server’s chronic acute harddisk space shortage syndrome. Somehow, AIX Client could not mount the shared NFS folder from the Linux Server.

Apparently, AIX uses high ports to establish the connectivity to NFS Server. Linux NFS Server requires low ports (below 1024). So, you have to force AIX to use those reserved ports to establish the connection.

nfso -o nfs_use_reserved_ports=1

Then, the normal ‘mount’ should work from AIX after the medicine 😛


Apache Redirection – http to https 24 March 2008

Posted by Maulvi Bakar in : Linux,Work , add a comment

Many times have you encountered situation where you want to automatically redirect a page from one site to another. Simple problem of having a http://example.com/Some/Url/resource and http://www.example.com/Some/Url/resource to a https://www.example.com/Some/Url/resource

Actually, it is as simple as a single line in the http.conf file like thus –

Redirect permanent / https://www.example.com/

Therefore, anything that you put there will be redirected to the other site preserving the same resource url locations. It was so simple that I got disgusted! Darn!

New HDD, enlarging Red Hat/Centos ext3/lvm partition 16 December 2007

Posted by Maulvi Bakar in : Home,Linux,System , 3 comments


Suddenly, I’ve run out of space on one of my servers at home. Solution, add a new harddisk, extend existing partition onto the new harddisk.. Simple right? Right…

Firstly, fix the new harddisk onto the machine. Fdisk it like thus –

# fdisk /dev/sdb

Create a new ‘sdb1’ partition using type 8e, which is Linux LVM.

Next, we need to create a Physical Volume within the newly created sdb1 partition.

# pvcreate /dev/sdb1

After that we will extend the existing volume ‘VolGroup00’ onto the newly created physical volume.

# vgextend VolGroup00 /dev/sdb1

Once done, the next step is to extend the Logical Volume within the volume group to use the free space newly made available when you extend the volume group previously.

# lvextend -L 40G /dev/VolGroup00/LogVol00

And finally, we’ll enlarge the ext3 partition to make use of the newly available free space in the logical volume.

# resize2fs /dev/VolGroup00/LogVol00


Typo error since fixed as advised! Thank you!