Knowledge Base

Mounting A Hard Drive In Linux

This post details the processes required to mount a new hard drive in a Linux server. eSecureData.com clients may use this process when they request additional hard drives to be added to their servers, or they may simply put in a support ticket for our techs to do it.

To view attached drives to see which ones need mounting use the following command:

# fdisk -l

You should receive something like this:

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225200 bytes

Device Boot Start End Blocks ID System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 60801 488279610 8e Linux

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225200 bytes

Device Boot Start End Blocks ID System
/dev/sdb1 * 1 13 104391 83 Linux
/dev/sdb2 14 60801 488279610 8e Linux

You would then type the following command:

# mount -t auto /dev/sdb2 /mnt (where /dev/sdb2 = the device with the data needing recover and /mnt = the location you’re mounting it to)

For logical Volumes this has to be done differently.

Your fdisk -l would return something like the following:

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225200 bytes

Device Boot Start End Blocks ID System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 60801 488279610 8e Linux LVM (notice the LVM addition)

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225200 bytes

Device Boot Start End Blocks ID System
/dev/sdb1 * 1 13 104391 83 Linux
/dev/sdb2 14 60801 488279610 8e Linux LVM (notice the LVM addition)

This is most likely the case if you’ve just had to install a new OS and attached the second drive for data recovery.

If both hard drives have an LVM, you should check the LVM groups with the following command:

# pvscan
This would return something similar to the following:

PV /dev/sdb2 VG VolGroup00 lvm2 [465.66 GB / 0 free]
PV /dev/sda2 VG VolGroup00 lvm2 [465.66 GB / 0 free]
Total: 2 [931.31 GB] / in use: 2 [ 931.31 GB] / in no VG: 0 [0 ]

If both hard drives have the same Volume Group, you will need to rename one of them with the following commands:

# lvm vgscan –mknodes
# lvm vgchange -ay
# lvm lvscan
# lvm vgrename VolGroup00 VolGroup01
# lvm lvscan

Once renamed a reboot is required. After the reboot an lvscan should show both VolGroup00 and VolGroup01. You would then need to mount the logical volume rather then the hard drive partition.

# vgscan –mknodes
# vgchange -ay
# lvscan

That will detect and activate all available logical volumes. Then you mount them something like this:

# mount /dev/VolGroup01/LogVol00 /mnt

To see all additional hard drive options, please see our pricing pages for Premium Dedicated Servers or Value Dedicated Servers.

Mounting/Mapping a drive from Linux to Windows

If you’ve got a share on a Windows server and want to use it from a Linux server, here’s how to do it.

mount -t cifs //ip-of-the-windows-server/share-name-of-the-windows-server -o username=user,password=password /mountpoint

Example:

mount -t cifs //192.168.1.2/c$ -o username=administrator,password=adminpassword /media/windowsserver/

Adding Bandwidth Graphs To Your Website

Here’s a PHP script I wrote that lets you put our bandwidth graphs on your own website.   To make it work, just get your GraphID by right-clicking the graphs in my.esecuredata.com.   You can then change the top values in this script, save it as somefile.php on your web server, and it should give you a nice page that refreshes every five minutes. I haven’t included <html> or <body> tags as I’m assuming you’ll want to edit as needed to make it fit nicely into your site.  
<?php
//First, set up the script.  Change these values.
$ServerName  = "some server";
$GraphID          = "1109";
//Set the graph server.  This shouldn’t change.
$GraphServer = "cacticlients.esecuredata.com";
//Start with a table
echo "<table align=\"center\" width=\"90%\" style=\"border-collapse: collapse; border: 1px solid #C0C0C0; font-size: 8pt; font-family: verdana;\"
cellspacing=0 cellpadding=3 bgcolor=\"#DDDDDD\">";
//Blue header row
echo "<tr><td style=\"color: #FFFFFF; background-color: #000080;\">";
echo "Bandwidth Report for $ServerName";
echo "</td></tr>";
//A message row
echo "<tr><td style=\"color: #FFFFFF; background-color: #565656;\">";
echo "Inbound (green) is traffic sent from this server to the Internet.<br>";
echo "Outbound (blue) is traffic received by this server from the Internet.";
echo "</td></tr>";
//Now the graphs
$Gr1="https://$GraphServer/cacti/graph_image.php?action=view&local_graph_id=$GraphID&rra_id=1";
$Gr2="https://$GraphServer/cacti/graph_image.php?action=view&local_graph_id=$GraphID&rra_id=2";
$Gr3="https://$GraphServer/cacti/graph_image.php?action=view&local_graph_id=$GraphID&rra_id=3";
$Gr4="https://$GraphServer/cacti/graph_image.php?action=view&local_graph_id=$GraphID&rra_id=4";
echo "<tr><td align=\"center\"><br>$ServerName – Daily (5 Minute Average)";
echo "<br><img name=\"image1\" src=\"$Gr1\"></td></tr>";
echo "<tr><td align=\"center\"><br>$ServerName – Weekly (30 Minute Average)";
echo "<br><img name=\"image2\" src=\"$Gr2\"></td></tr>";
echo "<tr><td align=\"center\"><br>$ServerName – Monthly (2 Hour Average)";
echo "<br><img name=\"image3\" src=\"$Gr3\"></td></tr>";
echo "<tr><td align=\"center\"><br>$ServerName – Yearly (1 Day Average)";
echo "<br><img name=\"image4\" src=\"$Gr4\"></td></tr>";
//Close the table
echo "</table>";
//Now a script to refresh.  Don’t refresh more than once every five minutes.
//It’s pointless to as the images only refresh that often.
$SC  = "\n\n<script LANGUAGE=\"JavaScript\">\n";
$SC .= "setInterval(\"";
$SC .= "var now = new Date();";
$SC .= "document.images.image1.src=’$Gr1&tsi=’ + now.getTime();";
$SC .= "document.images.image2.src=’$Gr2&tsi=’ + now.getTime();";
$SC .= "document.images.image3.src=’$Gr3&tsi=’ + now.getTime();";
$SC .= "document.images.image4.src=’$Gr4&tsi=’ + now.getTime();";
$SC .= "\", 30000);\n";
$SC .= "</script>\n\n";
echo $SC;
?>

Installing LAMP on Linux

LAMP = Linux, Apache, PHP, MySQL

Using Yum:

yum -y install httpd php mysql-server mysql

service httpd start

service mysqld start

Using Aptitude (apt-get):

apt-get install apache2 php5-mysql libapache2-mod-php5 mysql-server

Grep for files containing text

In Linux, to find files containing some text, type this at the root directory of your search path:

grep -lir “the text you are looking for” *

-l limits the output to filenames
-i ignores case
-r recurses

Public DNS Servers

All eSecureData.com clients may use our DNS servers from within our network for outbound recursive lookups. It is always a good practice to have several DNS servers in your rotation in the event that one server is ever down. Here are a list of public DNS servers that you may wish to use for outbound recursive lookups, either in addition to or instead of eSecureData.com DNS servers.

Google’s Public DNS Servers (very fast)

8.8.8.8
8.8.4.4

OpenDNS Public DNS Servers

64.127.100.12
216.38.128.2
69.111.95.106

Can’t Navigate to Microsoft Site on Windows Server

The Problem
In some versions of Windows, servers fail to navigate to the Microsoft site for either browsing or updates.

The Diagnosis
It turns out this is usually due to the DNS Client failing to properly cache the Microsoft site’s DNS information.

The Solution
DNS Client is a service that caches Domain Name System (DNS) names for the computer it’s enabled on. If disabled, it simply means the system will go upstream to resolve DNS names rather than use the cache.
Disabling this service usually results in the server being able to properly access the Microsoft site.

You can enable or disable this service by going to:

Start – Control Panel – Administrative Tools – Services


Installing proFTPd on CentOS

Many people ask us how to install the popular proFTPd package on Centos. The rpm binaries are nicely available on Fedora, but if you type yum install proftpd, a default Centos install will return you “No package proftpd available.”    Well, the good people at karan.org have packaged up Centos rpm binaries and made them available to the public.   We don’t vouch for them, and remember, if you follow these steps,  you do so at your own risk.

In any SSH window, type the following (you can actually copy and paste in Putty):

cd /etc/yum.repos.d/
wget http://centos.karan.org/kbsingh-CentOS-Extras.repo
rpm –import http://centos.karan.org/RPM-GPG-KEY-karan.org.txt
nano /etc/yum.repos.d/kbsingh-CentOS-Extras.repo
Set enabled=1 in both sections.  At this point, you can yum install proftpd and all should go smoothly.   Remember to set enabled back to 0 after you’re done, just to clean up.