web analytics

Hetzner server with > 2TB disk

Recently I ordered a Hetzner server for one of our clients. The server had two 3TB disks. Hetzner provides a command line installation of the desired OS once we login to their server. As such, I logged in to the server and installed Centos6 by executing “installimage” option as suggested by Hetzner.

After installing OS and rebooting the server, I noticed that the 3T disk is not showing full space.

[root@abc ~]#df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        99G  2.5G   91G   3% /
tmpfs           463M     0  463M   0% /dev/shm
/dev/sda2       976M  126M  800M  14% /boot

/dev/sda4   2.3T     123M   2.2T  1% /home

If the disk size is greater than 2T you cannot use normal fdisk to create partition...

Read More

Fatal error: Class ‘Net_SMTP’ not found in /usr/local/lib/php/Mail/smtp.php on line 349″

I was trying to setup a php script to send mail with SMTP Authentication. The script was ready, but when executed in a browser, it displayed the following error.

Fatal error: Class ‘Net_SMTP’ not found in /usr/local/lib/php/Mail/smtp.php on line 349″

The problem appears because the php pear package Net_SMTP is not present in the server. You can install it in two way.

  1. Install the Mail package with –alldeps which will install all required dependencies like Net_SMTP

pear install –alldeps Mail

If Mail is already installed, and if it refuses to get installed then you can force the installation as follows.

pear install –alldeps -f Mail

2.  If Mail is already installed, then you can install the Net_SMTP option alone as follows.

pear install Net_SMTP

After that, execute the script again and...

Read More

Linux Booting Process

You turn on a linux machine, a splash screen appears for a few seconds and then in a small delay you are greeted with a login page. You login and then starts working. Ever wondered what happens behind the scenes, when you turn on the machine? How does the machine boots? Continue reading.

The linux booting process happens in 6 stages.


When you power on the machine, CPU asks ROM what to do. ROM has a JUMP instruction which commands CPU to check the BIOS. BIOS stands for Basic Input/Output system. BIOS is the first thing that is loaded, and its main role is to check the hardware and performs integrity checks. Its main role is to identify the boot device as defined in the CMOS...

Read More

Class ‘horde_Hooks’ not found

After recent cpanel update, I started getting the following error while accessing horde webmail.

A fatal error has occurred

Class ‘horde_Hooks’ not found

Details have been logged for the administrator.

This problem is expected to be fixed before cPanel 11.51 becomes 11.52 and is published to CURRENT, but it is still occurring in the 11.51 build that is in EDGE right now. The temporary fix for that problem is as follows.

Run the below commands.

[root@abc ~]# find /usr/local/cpanel/base/horde -name ‘hooks.php’ -not -wholename ‘*/imp/*’

[root@abc ~]# find /usr/local/cpanel/3rdparty/php/54/lib/php/Horde/Core -name ‘hooks.php’ -not -wholename ‘*/imp/*’

Now, move or remove any files that are listed by the above find commands...

Read More

df showing wrong result

My mysql server suddenly started showing my disk space usage as almost full.

[root@abc /]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3       550G  508G   14G  98% /
tmpfs            32G     0   32G   0% /dev/shm
/dev/sda1       2.0G  173M  1.8G   9% /tmp

But when I issued a disk usage check on / , it returned the usage to be very little.

[root@abc /]# du -sch
47G     .
47G     total

I was sure there is something wrong. Hence, I checked for deleted files. You can use either of the following commands.

[root@abc /]# lsof +L1

mysqld    23193     mysql    5u   REG    8,1          184     0       13 /tmp/ibrUf6yr (deleted)
mysqld    23193     mysql    6u   REG    8,1            0     ...

Read More

Enabling detailed debug log in imap

Sometimes your might need to check for detailed logging in email. One of my friends was  developing an email application and he wanted to check what was happening behind the screen when he received an email, moves it to another folder, deletes it etc.

Hence, we decided to enable detailed logging in imap. It was a cpanel server and we used the option imapdebug. Always keep a backup of the file you edit.

root@abc# cp -pv /usr/lib/courier-imap/etc/imapd /usr/lib/courier-imap/etc/imapd.bak.$(date +%F)

root@abc# vi /usr/lib/courier-imap/etc/imapd

Now uncomment the following line.


Now touch a file named  imaplog.txt at the root of the account where you want to enable logging. Restart the courier service. Suppose I need to enable logging for greproot@abc.com.


Read More

(28)No space left on device: mod_rewrite: Parent could not create RewriteLock file

Noticed this error in a cpanel server while starting apache. Apache refused to start with the following error.

(28)No space left on device: mod_rewrite: Parent could not create RewriteLock file

Seeing the error, the first thing that I checked was the disk space in the server but it looked fine.

root@abc [~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg0-root   16G  1.2G   14G   8% /
/dev/mapper/vg0-home  249G  124G  113G  53% /home
/dev/mapper/vg0-var    23G  7.0G   15G  33% /var
/dev/mapper/vg0-usr    23G  7.6G   14G  36% /usr
/dev/mapper/vg0-tmp   9.5G  151M  8.9G   2% /tmp
/dev/sda1             7.4G  184M  6.9G   3% /boot
tmpfs                 7.9G     0  7...

Read More

PHP Warning: mysql_connect(): No such file or directory

I was getting the following error while trying out a basic mysql connection script.

PHP Warning: mysql_connect(): No such file or directory

The script I used was as follows.

$mysql_hostname = “localhost”;
$mysql_user = “root”;
$mysql_password = “abc123”;
$mysql_database = “testdb”;

$link = mysql_connect($mysql_hostname, $mysql_user, $mysql_password);
if (!$link) {
die(‘Could not connect: ‘ . mysql_error());
echo ‘Connected successfully’;

Executing the script returned the following error.

root@abc:/var/www/html/scripts# php test.php
PHP Warning:  mysql_connect(): No such file or directory in /var/www/html/scripts/test.php on line 7
PHP Warning:  mysql_select_db() expects parameter 2 to be resource, boolean given in /var/www/html/...

Read More

Fatal error: Uncaught exception ‘MongoCursorException’ with message ‘localhost:27017: not authorized for query on admin.system.namespaces’ – Moadmin error after enabling authentication in mongodb

If you enabled authentication for mongodb, then moadmin will fail to show the databases. This is because moadmin is  not authenticated to list the databases. You might get the following error.

Fatal error: Uncaught exception ‘MongoCursorException’ with message ‘localhost:27017: not authorized for query on admin.system.namespaces’

I am considering a scenario where I enabled authentication as said in the link here. In that case open your moadmin.php file and make the following change, so that it authenticates itself.

You need to edit MONGO_CONNECTION parameter.

root@abc:~# vi /home/abc/public_html/moadmin.php

#define(‘MONGO_CONNECTION’, ”);        // Comment out the old connection parameter
define(‘MONGO_CONNECTION’, ‘mongodb://admin:admin@127.0.0...

Read More

Authentication in mongodb

Mysql databases allow username and password. Similarly if you require to keep authentication for your mongodb database as well, please do the following. Suppose, I have a database named abc, and I need to create a user named abc with password abc123.

First, create an admin user.

root@abc:~# mongo
MongoDB shell version: 2.4.10
connecting to: test
> use admin
> db.addUser("admin", "admin")

> use abc                   (Switch to the database abc)

> db.addUser("abc", "abc123")

Quit the mongoshell and stop mongo

root@abc:~# /etc/init.d/mongodb stop

root@abc:~# vi /etc/mongodb.conf    and make the following change

auth = true

root@abc:~#/etc/init.d/mongodb start

Now we need to test if authentication works...

Read More