Posts Tagged ‘Hosting’

7 November, 2013 — Hosting

How to Extended a Linux Logical Volume

I recently upgraded the disk space on one of my Linux VPS servers and once the upgrade was done the space was still not added to the server… after a search around on the internet I found that I needed to Extend the Logical Volume of the VPS to add the extra 40GB of HDD space.

Below is a step by step guide of how to do this. Extending your LV should not delete any data however I can’t be held responsible if this does happen. However removing space from your LV will result in data loss. This guide is only extending the LV so you shouldn’t run into any trouble.

Please comment below if you have any questions regarding this!

Show Me How!

First, check the drives on the server with fdisk -l:

# fdisk -l
Disk /dev/hda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
  Device Boot      Start        End      Blocks  Id  System
/dev/hda1  *          1          33      265041  83  Linux
/dev/hda2              34        164    1052257+  82  Linux swap / Solaris
/dev/hda3            165        5221    40620352+  8e  Linux LVM
Disk /dev/sda: 85.8 GB, 85899345920 bytes
16 heads, 63 sectors/track, 166440 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
  Device Boot      Start        End      Blocks  Id  System
/dev/sda1              1      83220    41942272+  8e  Linux LVM
We will first add the extra 40GB from the system drive (hda). Start to modify the partition table with fdisk, specifying the drive “hda”
# fdisk /dev/hda
The number of cylinders for this disk is set to 10443.
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):
 At this prompt, you can type “p” to display the current partitioning:
Command (m for help): p
Disk /dev/hda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
  Device Boot      Start        End      Blocks  Id  System
/dev/hda1  *          1          33      265041  83  Linux
/dev/hda2              34        164    1052257+  82  Linux swap / Solaris
/dev/hda3            165        5221    40620352+  8e  Linux LVM
Command (m for help):
We want to add another partition so type “n” then “p” and specify partition “4” as 1, 2 and 3 are used. The next two prompts can be left blank to use the default.
Command (m for help): n
Command action
  e  extended
  p  primary partition (1-4)
p
Selected partition 4
First cylinder (5222-10443, default 5222):
Using default value 5222
Last cylinder or +size or +sizeM or +sizeK (5222-10443, default 10443):
Using default value 10443
Command (m for help):
Now, we change the partition we created to LVM. Type “t” at the prompt, specify partition 4 and then put in the code “8e” to set it to Linux LVM.
Command (m for help): t
Partition number (1-4): 4
Hex code (type L to list codes): 8e
Changed system type of partition 4 to 8e (Linux LVM)
Command (m for help):
Type “p” to make sure the partition is there and set to Linux LVM.
Command (m for help): p
Disk /dev/hda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
  Device Boot      Start        End      Blocks  Id  System
/dev/hda1  *          1          33      265041  83  Linux
/dev/hda2              34        164    1052257+  82  Linux swap / Solaris
/dev/hda3            165        5221    40620352+  8e  Linux LVM
/dev/hda4            5222      10443    41945715  8e  Linux LVM
Command (m for help):
Type “w” at the prompt to write the changes. This may give you a notice that you need to reboot. If this is the case, simply type “reboot” at the command line.
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
# reboot
Broadcast message from root (pts/0) (Thu Oct 31 13:47:39 2013):
The system is going down for reboot NOW!
When the server has come back up, log back in and at the command prompt, check the Physical Volume by typing “pvdisplay”
# pvdisplay
  — Physical volume —
  PV Name              /dev/hda3
  VG Name              VolGroup00
  PV Size              38.74 GB / not usable 20.31 MB
  Allocatable          yes (but full)
  PE Size (KByte)      32768
  Total PE              1239
  Free PE              0
  Allocated PE          1239
  PV UUID              OEY2Ya-0SCL-t8M6-n3yR-lWs7-Kr1z-8UraBM
  — Physical volume —
  PV Name              /dev/sda1
  VG Name              VolGroup00
  PV Size              40.00 GB / not usable 31.25 MB
  Allocatable          yes (but full)
  PE Size (KByte)      32768
  Total PE              1279
  Free PE              0
  Allocated PE          1279
  PV UUID              lXOcRG-1TLW-rpHj-Xzwb-3W9o-49jV-MLMf8N
We now want to add the new partition with pvcreate and specifying the new partition:
# pvcreate /dev/hda4
  Writing physical volume data to disk “/dev/hda4”
  Physical volume “/dev/hda4” successfully created
We can confirm this is added with pvdisplay.
# pvdisplay
  — Physical volume —
  PV Name              /dev/hda3
  VG Name              VolGroup00
  PV Size              38.74 GB / not usable 20.31 MB
  Allocatable          yes (but full)
  PE Size (KByte)      32768
  Total PE              1239
  Free PE              0
  Allocated PE          1239
  PV UUID              OEY2Ya-0SCL-t8M6-n3yR-lWs7-Kr1z-8UraBM
  — Physical volume —
  PV Name              /dev/sda1
  VG Name              VolGroup00
  PV Size              40.00 GB / not usable 31.25 MB
  Allocatable          yes (but full)
  PE Size (KByte)      32768
  Total PE              1279
  Free PE              0
  Allocated PE          1279
  PV UUID              lXOcRG-1TLW-rpHj-Xzwb-3W9o-49jV-MLMf8N
  “/dev/hda4” is a new physical volume of “40.00 GB”
  — NEW Physical volume —
  PV Name              /dev/hda4
  VG Name
  PV Size              40.00 GB
  Allocatable          NO
  PE Size (KByte)      0
  Total PE              0
  Free PE              0
  Allocated PE          0
  PV UUID              rHvm5B-MA1d-shpx-3dxp-QCoq-Xhhl-x8KWax
You can view the current volume group with “vgdisplay” to get the VG name
# vgdisplay
  — Volume group —
  VG Name              VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  6
  VG Access            read/write
  VG Status            resizable
  MAX LV                0
  Cur LV                1
  Open LV              1
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size              78.69 GB
  PE Size              32.00 MB
  Total PE              3798
  Alloc PE / Size      3798 / 78.69 GB
  Free  PE / Size      0 / 0
  VG UUID              H7RyAi-ZTUo-hH0t-nnGi-IBRN-qeMl-umrblW
Extend the Volume Group to include the new partition
# vgextend VolGroup00 /dev/hda4
  Volume group “VolGroup00” successfully extended
Next, we want to check the Logical Volume with lvdisplay. (Note that I had gone back and added the other partition before continuing here),
# lvdisplay
  — Logical volume —
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                sorbDy-tdpk-dqdp-YAfe-OSrs-zDHS-PUvG4K
  LV Write Access        read/write
  LV Status              available
  # open                1
  LV Size                118.69 GB
  Current LE            3798
  Segments              3
  Allocation            inherit
  Read ahead sectors    auto
  – currently set to    256
  Block device          253:0
Take note of the “LV Name” and then we can extend the logical volume using “lvextend”. We can specify the size however by using 100%FREE, it will use all available space.
# lvextend -l +100%FREE /dev/VolGroup00/LogVol00
  Extending logical volume LogVol00 to 158.69 GB
  Logical volume LogVol00 successfully resized
Finally, we resize to the file system so the space is usable with “resize2fs” which can take a few minutes to complete
# resize2fs /dev/VolGroup00/LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 41598976 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 41598976 blocks long.
You can confirm the space is usable by running “df -h” again.
# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      154G  69G  78G  47% /
/dev/hda1            251M  86M  153M  36% /boot
tmpfs                500M    0  500M  0% /dev/shm
/usr/tmpDSK          549M  21M  500M  4% /tmp
The extra space is now usable on your server.
Comment below if you have any questions regarding this!
.
Server Rack
3 June, 2013 — Hosting, Tech

How To Transfer / Migrate cPanel Accounts With No Downtime

Before The Move

Before we even think about moving accounts we need to think about a few other things that need sorting first.

Purchasing A New Server

First things first, if you haven’t already you need to have your new server set-up, have cPanel installed, installed your Firewall and then leave it… just leave it for 4-5 days. This is so you can make sure a. the server is stable and b. the new companies network is stable. The last thing you need is to move all your accounts over and find out the new network is rubbish and your server crashes every five minuets.

Update DNS TTL (Time to Live)

This step has to be done 48-72 hours prior to migration. Changing the TTL (Time To Live) from 14400 (4 hours) to 300 (5 minutes) means that as soon as we make a change to a DNS zone, it will take affect everywhere within 5 minutes as opposed to 4 hours.

To do so you need to run the following commands in your SSH console.

mkdir -p /backup/named-baka ; cp /var/named/*.db /backup/named-baka
perl -pi -e 's/\$TTL 300/\$TTL 14400/g' /var/named/*.db

Once you have done this its just a waiting game… Leave it for a while just to make sure its populated though out the world (24 hours).

Migration Day

Once a day has gone by its d-day… The day of migration. First we need to stop all services on the old server other than Apache and MySQL (to avoid loosing any emails or files people upload) You can do this by running the following commands in SSH

/etc/init.d/cpanel stop
/etc/init.d/exim stop
/etc/init.d/pure-ftpd stop;/scripts/ckillall -9 pure-ftpd;/scripts/ckillall -9 pure-authd
/etc/init.d/proftpd stop

Let The Copying Begin

After that login to WHM on the new server as root then do the following steps:

  1. Click on “Copy Multiple Accounts/Packages From Another Server” (under Transfers)
  2. Fill out the old server data
  3. Select the accounts to transfer
  4. Start the transfer process (this can take some time)

Update DNS

Once the transfer has finished make sure everything is copied across ok and nothing is missing, if you run into any trouble comment below and I will try to help. Once you are happy everything is there SSH into the old server and run the following commands:

mkdir -p /backup/named-bak ; cp /var/named/*.db /backup/named-bak
sed -i 's/[OLD_SERVER_IP]/[NEW_SERVER_IP]/g' *.db
/etc/init.d/named restart

The above commands first make a backup of your DNS databases for each account. Then goes through all of the accounts and updates the DNS records from the old IP to the new IP forcing the DNS servers to send all traffic to the new server! (note this can take anything from 15 – 60 minuets to take effect).

For sites not on a shared IP you will need to edit these DNS records separately to reflect the new IP. Well Done! – All the websites are functioning on the new server, now transfer your Nameservers! Don’t forget to give it 48 hours for the DNS to settle down. DNS can be a pain and take longer to update than other peoples DNS its all different. Once you have waited 48 hours you can shutdown your old server and cancel your account with that host you couldn’t wait to leave!

Resellers?

Note: If you have resellers, we have to copy all the files in /var/cpanel that reference resellers and anything ending in .accts to the new server.

Photo By: Getbutterfly

31 May, 2013 — Blogging, WordPress

Brute Force Attack – The Result

Email Account

I’m sure you may well know, unless you’ve been living under a rock recently? There has been a large botnet attacking WordPress websites all around the world in the way of a Brute Force Attack.

Last weekend my email account went mad, with emails from the plugin Limit Login Attempts about 3-5 emails every minuet, for 48 hours. Unfortunately I was away from home with practically no internet access so was unable to try to stop the attack. From the emails they were targeting 3 different usernames admin, administrator and support. I was pretty sure my server would hold out while the attack was happening and it did. The attack stopped late Sunday night.

My Incoming Emails

My Incoming Emails

When I got home, I opened up my email client and the emails began to download… all 29,861 of them, I guess thats the only downside of Limit Login Attempts… but at least it raised my attention to something that could have been a lot worse.

20 April, 2013 — Development, Tech, WordPress

WordPress Management Service

WordPress powers 17.6% of the world’s websites? If your website is powered by WordPress then this is the post for you!

What it’s all about?

Something has gone wrong...WordPress is used not only for personal bloggers but is increasingly been used by large companies to power their website. Whatever you use WordPress for your website is probably something that is close to you, but what happens if your website one day disappears? You don’t have a backup or the backup you do have is 2 weeks old!

This is where I am looking to help you! I have decided to offer a service to you where I will manage your website all for £9.99 per month!

I know what your thinking now… what will I get for £9.99 well here goes…

What you get for £9.99 / month

  • Daily Offsite Backups of your WordPress website
  • Updates of WordPress, Themes, and Plugins.
  • Monthly Website Security Audits
  • Monthly Website Optimisation
  • Uptime Monitor
  • Monthly Reports

Find out more about my Management services here.

Easy Apache Error
15 April, 2013 — Hosting

!! Failed to install CPAN Perl module(s) Crypt::PasswdMD5 !! – Easy Apache

cPanel 11.36 is shipped with perl 5.14.3. that might make some problems for your cpan. Some of you might face an error while trying to run easyapache which says:

!! Failed to install CPAN Perl module(s) Crypt::PasswdMD5 !!

Well to fix this issue just run following command to install Crypt::PasswdMD5

# /usr/local/cpanel/bin/cpanm -n Digest::SHA1 Crypt::PasswdMD5

Once you have run the above code in SSH try Easy Apache again.

That didn’t work…

If the above code didn’t work run the following in SSH

# cpan
# install Digest::SHA1 Crypt::PasswdMD5
# exit

After running this try Easy Apache in WHM again and eveything should be working just fine!