Formatting a second drive on RHEL Linux

Here is a quick little how-to for formatting a second drive on RHEL4 Linux. A great deal of credit goes to http://www.eth0.us/mount on this.

This how-to is based on my machine which has two 80GB scsi drives which we can see by doing the following:

#cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: FUJITSU Model: MAW3073NP     Rev: 5803
  Type:  Direct-Access             ANSI SCSI revision: 03
Host: scsi0 Channel: 00 Id: 01 Lun: 00
  Vendor: SEAGATE Model: ST373207LW     Rev: D702
  Type:  Direct-Access             ANSI SCSI revision: 03

WARNING: Be very careful as the smallest mistake can lead to a complete loss of ALL information on your machine!

Now let’s get going!

The first thing we will do is run fdisk which is used to format a disk. I first run it with the -l (elle) flag to see what partitions my drives currently have:

[root@server var]# fdisk -l

Disk /dev/sda: 73.4 GB, 73407820800 bytes
255 heads, 63 sectors/track, 8924 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot     Start       End     Blocks   Id System
/dev/sda1   *        1       13     104391   83 Linux
/dev/sda2         14       268   2048287+  82 Linux swap
/dev/sda3         269       399   1052257+  83 Linux
/dev/sda4         400     8924   68477062+  5 Extended
/dev/sda5         400     8924   68477031   83 Linux

Disk /dev/sdb: 73.4 GB, 73407820800 bytes
255 heads, 63 sectors/track, 8924 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot     Start       End     Blocks   Id System
/dev/sdb1   *        1       13     104391   83 Linux
/dev/sdb2         14       268   2048287+  82 Linux swap
/dev/sdb3         269       399   1052257+  83 Linux
/dev/sdb4         400     8924   68477062+  5 Extended
/dev/sdb5         400     8924   68477031   83 Linux

As you can see above I can see the two SCSI drives and they both have partitions. This is because at some point in the past I ran dd to duplicate my primary disk over to my secondary disk. I want to now get rid of all those partitions on drive B and format drive B with one partition, which I will use to store my backups on.

The following is what did to remove the old paritions and create a new one:

[root@server var]# fdisk /dev/sdb

The number of cylinders for this disk is set to 8924.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
  (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
No free sectors available

Command (m for help): d
Partition number (1-5): 5

Command (m for help): d
Partition number (1-5): 4

Command (m for help): d
Partition number (1-4): 3

Command (m for help): d
Partition number (1-4): 2

Command (m for help): d
Selected partition 1

Command (m for help): d
No partition is defined yet!

Command (m for help): n
Command action
  e   extended
  p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-8924, default 1):  (Here we just hit -ENTER- to accept the default)
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-8924, default 8924): (Here we just hit -ENTER- to accept the default)
Using default value 8924

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Now when we run fdisk we can see the two drives with different partitions:

[root@server var]# fdisk -l

Disk /dev/sda: 73.4 GB, 73407820800 bytes
255 heads, 63 sectors/track, 8924 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot     Start       End     Blocks   Id System
/dev/sda1   *        1       13     104391   83 Linux
/dev/sda2         14       268   2048287+  82 Linux swap
/dev/sda3         269       399   1052257+  83 Linux
/dev/sda4         400     8924   68477062+  5 Extended
/dev/sda5         400     8924   68477031   83 Linux

Disk /dev/sdb: 73.4 GB, 73407820800 bytes
255 heads, 63 sectors/track, 8924 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot     Start       End     Blocks   Id System
/dev/sdb1           1     8924   71681998+  83 Linux

Now we need to format partition sdb1 so that Linux can use it. We will use ext3 in this case:

[root@server var]# mkfs.ext3 /dev/sdb1
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
8962048 inodes, 17920499 blocks
896024 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=20971520
547 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
      32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
      4096000, 7962624, 11239424

Writing inode tables: done                  
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

The only thing left to do is create a mount point for the drive and add one line to our fstab. I like to put all my drives in a root folder called /mnt. So let’s create mnt and meaningful place within mount which I like to name after the drive, so in this case sdb. For future reference we can now easily keep track of which drive is which.

[root@server5 var]# mkdir /mnt
[root@server5 var]# cd mnt
[root@server5 var]# mkdir /sdb

Now we can add the line to fstab so the system know what to mount and where. Note that your fstab will vary considerably. The line I enter is ‘/dev/sdb1 /mnt/sdb ext3 defaults 1 1’ without the quotes:

[root@server mnt]# pico -w /etc/fstab

# This file is edited by fstab-sync - see ‘man fstab-sync’ for details
/dev/sda5 /    ext3   usrquota,grpquota 1 1
/dev/sda1 /boot   ext3   defaults 1 2
/dev/sda3 /tmp   ext3   defaults,noexec 1 0
none     /dev/pts devpts gid=5,mode=620 0 0
none     /proc   proc   defaults 0 0
none     /dev/shm tmpfs defaults 0 0
/dev/sda2 swap   swap   defaults 0 0
/dev/hdc           /media/cdrom         au
to   pamconsole,exec,noauto,managed 0 0
/dev/sdb1 /mnt/sdb ext3 defaults 1 1

Now ew can simply use the mount command to use our drive and check that it is there:

[root@server scsi]# cd /mnt/sdb/
[root@server5 sdb]# ls
lost+found

That’s all there is to it.

Setting up server-status on apache

The more I know how my server is feeling, the better off I am. Using apache’s built in Server Status is just one such tool that will let you see how apache is handling it’s load. The server status will tell you the server load, uptime, requests per second, total workers, available workers, and every connection to your apache server with who is connecting and to what page and on what site they are connecting. All very useful information especially if you are experiencing a problem.

This little tutorial will show you how one might setup their server status.
Little warning before you start, setting up server status can be insecure and give bad people access to critical information if done wrong. I am not liable for any problems that result from you following my tutorial, or any tutorial on this site. You break your server, that is your problem and yours alone.

Here is how I set it up:

First, let’s install a configuration file in /etc/httpd/conf.d. We will call it serverstatus.conf. Be sure it ends in conf or apache won’t see it.


<Location>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from XXX.XXX.XXX.XXX
</Location>

Location
Tells you what to enter in your browser. To be extra safe change it from server-status to something obscure. For this example I am going to use . To see the status you would then enter this into your browser: http://www.yourdomainname.com/st994576BB76.

SetHandler
Tells the server to apply the server status handler to this location

Order Deny,Allow
tells the server to Deny first and then Allow. Deny from all tells the server that first we will deny access to everyone. So no one can access the server status URL.

Allow from XXX.XXX.XXX.XXX
tells the server to allow access only from the IP address XXX.XXX.XXX.XXX. Be sure to change it to your own IP address. If you have a dynamic IP that changes quickly then this won’t work for you. Whatever you do, don’t let the world see your server status. It is insecure to let that info out.

So we now have a secure method to access the server status. Next we will turn on extended status in apache.

The file we are going to edit is /etc/httpd/conf/httpd.conf. First make a backup of that file. If you screw up this file your web server will NOT work anymore. So make sure you have a backup before proceeding.

Using your favourite editor, add this line–ExtendedStatus On–right after the Include conf.d/*.conf line. Mine looks like this after the change:


Include conf.d/*.conf
ExtendedStatus On

Now check that Apache still likes the config file by typing this at the command line:


/etc/init.d/httpd configtest

If the server comes back with ‘Syntax OK’ then you are set to reload apache. If any errors or warnings show up, be sure to fix them right away, and before restarting or reloading apache. If you cannot figure out why you are getting errors or warnings, you can always replace the modified version with the backup you made a few minutes ago.

Assuming all is safe, now you can enter


/etc/init.d/httpd reload

We use reload so it won’t kick anyone off the server and it is just nicer than restart, which kicks everyone off the server and then restarts.

Now you should be able to go to your URL http://www.yourdomainname.com/st994576BB76 and see the stats.

Pretty cool eh? Now you can see why you don’t want just anyone to see your server status.

If you don’t plan on using server status for awhile, be sure to disable it in the config files by turn ExtendedStatus Off in /etc/httpd/httpd.conf and removing the ‘Allow from’ line in the serverstatus.conf file. Or simply remove the serverstatus.conf file altogether.

Come back next week and I will show you how you can get a nice machine readable format of the stats.

Sendmail pipe php script dilemma

Spent a little bit tonight getting sendmail to pipe one address to a php script. My searching for solutions never gave my exact solution so here is what I did to get this working.

The setup: Ensim on RHEL4. Installed PHP script sits on the main servers site which sits in /var/www/html and not on a virtually hosted site. The script is called pipe.php and sits in /var/www/html/order/pipe/pipe.php

Step 1: Add an alias in /etc/alias for my support email. Be sure to rebuild the alias file after by typing newaliases at the command line.
support: “|/usr/bin/php -q /var/www/html/order/pipe/pipe.php”

Step 2: chmod the script so it is executable:

chmod 755 /var/www/html/order/pipe/pipe.php

Step 3: Create a symbolic link in /etc/smrsh so sendmail will know about my script. If you don’t do this then sendmail will spit out the wholly ugly error message Service unavailable, and smrsh: “php” not available for sendmail programs (stat failed).

cd /etc/smrsh
ln -s /usr/bin/php ./php
ln -s /var/www/html/order/pipe/pipe.php ./pipe.php

Now all you need to do is test the functionality of your new script by sending an email to .(JavaScript must be enabled to view this email address).

Note, that if you are installing a script on a virtual site you need to make the above changes in the virtual site files. So instead of adding links in /etc/smrsh you would add them in /home/virtual/siteXX/fst/etc/smrsh and instead of adding the alias in /etc/aliases, you would add them in /home/virtual/siteXX/fst/etc/aliases. Then to rebuild the aliases DB, you need to do this:

/usr/sbin/chroot /home/virtual/siteXX/fst newaliases

That is about all there was to it. The error messages I got back from sendmail took me a bit to figure out.

Billing software for hosting - a winner!

For a few years now I have used Modernbill’s hosting billing and management software for all my hosting. It has not come without a lot of issues and quirks. Problem was, each time I got a quirk I ended up having to pay Modernbill to get the quirk fixed. More often than not the problem wasn’t actually fixed, instead I was just given a work around to keep the software going.

Well, a few days ago I sat down to send out an invoice. That, in theory should take about 10 minutes, including writing in the details and ensuring everything was correct. Then click send and off I go to do my other work.

STOP!

I clicked send and got a Failed message from Modernbill’s cache. Those of you who have used Modernbill probably know what I mean, or so all the forums say. So I checked all my bits and pieces out, they looked good, tried again. No go.

So I started down a path that was 2 hours long. This path is that all too familiar trouble shooting path of searching Google, reading posts, trying things and full circle back to Google. Finally, after my forehead turned black and blue from pounding it on the desk, I sent a trouble ticket into Modernbill.

Their response, “Should take less than an hour, so $75 will cover the fix.”

Two years ago my response to that email would have sent shivers down anyones spine, and I would have resulted in me been told to piss off. But no, I kept my cool and sent back a nice response explaining my situation, and exactly why I was against paying anymore money.

They responded with a nice email that said they understood my dilemma and a win-win solution would be to buy a 6 month support plan, and then they could fix the problem. Yeah, that is sorta of win win, but I lose my money still. Keep in mind that at this point I have now spent close to $300 on a software package that never really did everything it was supposed to. At least I couldn’t get it to do everything it was supposed to.
At this point I am late for a breakfast date with the wife, but still in a fowl mood not worthy of breakfast. Back to Google. This time on a trek to find a replacement program for my online billing needs.

I should interject here that I only use the billing software to handle subscriptions, fast invoice sending that is to be paid by Paypal, and in theory to keep track of my profit margins.

After less than 30 minutes I found a pretty slick looking replacement app. Albeit only for cPanel, and I have Ensim, but as I mentioned two seconds ago, I don’t manage the actual server with this software. Not yet! So I looked at the time, 30 minutes late for breakfast, what’s 30 more minutes.

Within 30 minutes (30 more minutes that is) I downloaded, installed, configured, imported all my Modernbill clients and accounts, tweaked all the accounts, and sent out my invoice that I started out to do almost three hours ago.

Can you say ... WoW! I did. And I still am.

If you have read this far, then you deserve to know what software I am referring to. WHMCompleteSolutions is the place I found my reprieve from billing insanity.  Not only is their interface slick and really fast, but their pre-sale customer support was amazing. They were able to answer everyone of my questions within 30 minutes (there it is again!) and sometimes within 10 minutes. WoW! From the website they say this:

“The complete client management, billing & support system”

WHMCompleteSolution is the complete client management solution for Web Hosts & Dedicated Server Providers looking for Online Automated Recurring Billing, Flexible and Easy to Use Client Management and Integrated Client Support Center including Support Tickets, Knowledgebase, Announcements & Live Server Status.

  • Powerful & Flexible Billing & Client Management System
  • Support Ticketing System with Full Email Piping Support
  • Automated Account Creation, Suspension & Termination
  • Payment Tracking, Accounting Features & Statistical Reports
  • Multi-Language Support
  • 100% Customisable using Templates

It is four days later, and I have purchased my full license, complete with refugee pricing having come from a competitor (you know who so I won’t repeat myself).

Do yourself a favour, if you are looking for a billing package for a small hosting business, check out WHMCompleteSolutions. The 15 day full functioning trial is FREE, so you have nothing to lose but a little time. It might even save your marriage! Speaking of which, the wife did not shoot me as she had other things to do, and we ended up having a great breakfast over Boccacinos in the West Island of Montreal.

DISCLAIMER: I realize that this solution is not for everyone. A lot of people probably get along well with Modernbill and their support staff. This rant is strictly from my point of view is not meant to say that MB sucks.

PS: But I really do like this new solution and really didn’t like having to work with MB.

Server Monitoring and notification by email and SMS

A few weeks ago one of my servers had a melt down. Luckily, I had fairly good backups and survived. A lot was learnt about quality backups, so next time I will be even better prepared.

Running a small hosting business is hard sometimes, and one of the biggest worries I have, and most likely others in the same boat have, are finding out quickly when a problem with a server occurs.

Our co-location facility has a great system that will monitor all our servers, and if a server goes off line, or one of the services goes down like HTTPD, SMTP etc, the co-lo’s monitoring system will know within 60 seconds. We also have the option of having the co-lo be notified of the problem so they can fix the issue as soon as possible.
That is a good start, but I still want to know as soon as possible if there is a problem. What happens if I am out having lunch or in a meeting and a problem occurs? Email is okay, but not always possible depending on where you are.

After a brief search for a service that would monitor my servers reliably and notify me of any problems by email and by SMS, I found a good solution. They are not expensive and come with a ton of features too. Sign up is FREE, and SMS’s cost 20 cents each. Addtional options are of course available for a fee.
If you are in the same boat as me, check out http://www.hyperspin.com/

I am in no way affiliated with hyperspin but really liked what they offer. If anyone has other thoughts on a similar service, please let me know.

Page 17 of 19 pages ‹ First  < 15 16 17 18 19 >