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 -lDisk /dev/hda: 85.8 GB, 85899345920 bytes255 heads, 63 sectors/track, 10443 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice 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 LVMDisk /dev/sda: 85.8 GB, 85899345920 bytes16 heads, 63 sectors/track, 166440 cylindersUnits = cylinders of 1008 * 512 = 516096 bytesDevice Boot Start End Blocks Id System/dev/sda1 1 83220 41942272+ 8e Linux LVM
# fdisk /dev/hdaThe 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):
Command (m for help): pDisk /dev/hda: 85.8 GB, 85899345920 bytes255 heads, 63 sectors/track, 10443 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice 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 LVMCommand (m for help):
Command (m for help): nCommand actione extendedp primary partition (1-4)pSelected partition 4First cylinder (5222-10443, default 5222):Using default value 5222Last cylinder or +size or +sizeM or +sizeK (5222-10443, default 10443):Using default value 10443Command (m for help):
Command (m for help): tPartition number (1-4): 4Hex code (type L to list codes): 8eChanged system type of partition 4 to 8e (Linux LVM)Command (m for help):
Command (m for help): pDisk /dev/hda: 85.8 GB, 85899345920 bytes255 heads, 63 sectors/track, 10443 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice 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 LVMCommand (m for help):
Command (m for help): wThe 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.# rebootBroadcast message from root (pts/0) (Thu Oct 31 13:47:39 2013):The system is going down for reboot NOW!
# pvdisplay— Physical volume —PV Name /dev/hda3VG Name VolGroup00PV Size 38.74 GB / not usable 20.31 MBAllocatable yes (but full)PE Size (KByte) 32768Total PE 1239Free PE 0Allocated PE 1239PV UUID OEY2Ya-0SCL-t8M6-n3yR-lWs7-Kr1z-8UraBM— Physical volume —PV Name /dev/sda1VG Name VolGroup00PV Size 40.00 GB / not usable 31.25 MBAllocatable yes (but full)PE Size (KByte) 32768Total PE 1279Free PE 0Allocated PE 1279PV UUID lXOcRG-1TLW-rpHj-Xzwb-3W9o-49jV-MLMf8N
# pvcreate /dev/hda4Writing physical volume data to disk “/dev/hda4”Physical volume “/dev/hda4” successfully created
# pvdisplay— Physical volume —PV Name /dev/hda3VG Name VolGroup00PV Size 38.74 GB / not usable 20.31 MBAllocatable yes (but full)PE Size (KByte) 32768Total PE 1239Free PE 0Allocated PE 1239PV UUID OEY2Ya-0SCL-t8M6-n3yR-lWs7-Kr1z-8UraBM— Physical volume —PV Name /dev/sda1VG Name VolGroup00PV Size 40.00 GB / not usable 31.25 MBAllocatable yes (but full)PE Size (KByte) 32768Total PE 1279Free PE 0Allocated PE 1279PV 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/hda4VG NamePV Size 40.00 GBAllocatable NOPE Size (KByte) 0Total PE 0Free PE 0Allocated PE 0PV UUID rHvm5B-MA1d-shpx-3dxp-QCoq-Xhhl-x8KWax
# vgdisplay— Volume group —VG Name VolGroup00System IDFormat lvm2Metadata Areas 3Metadata Sequence No 6VG Access read/writeVG Status resizableMAX LV 0Cur LV 1Open LV 1Max PV 0Cur PV 3Act PV 3VG Size 78.69 GBPE Size 32.00 MBTotal PE 3798Alloc PE / Size 3798 / 78.69 GBFree PE / Size 0 / 0VG UUID H7RyAi-ZTUo-hH0t-nnGi-IBRN-qeMl-umrblW
# vgextend VolGroup00 /dev/hda4Volume group “VolGroup00” successfully extended
# lvdisplay— Logical volume —LV Name /dev/VolGroup00/LogVol00VG Name VolGroup00LV UUID sorbDy-tdpk-dqdp-YAfe-OSrs-zDHS-PUvG4KLV Write Access read/writeLV Status available# open 1LV Size 118.69 GBCurrent LE 3798Segments 3Allocation inheritRead ahead sectors auto– currently set to 256Block device 253:0
# lvextend -l +100%FREE /dev/VolGroup00/LogVol00Extending logical volume LogVol00 to 158.69 GBLogical volume LogVol00 successfully resized
# resize2fs /dev/VolGroup00/LogVol00resize2fs 1.39 (29-May-2006)Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing requiredPerforming an on-line resize of /dev/VolGroup00/LogVol00 to 41598976 (4k) blocks.The filesystem on /dev/VolGroup00/LogVol00 is now 41598976 blocks long.
# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup00-LogVol00154G 69G 78G 47% //dev/hda1 251M 86M 153M 36% /boottmpfs 500M 0 500M 0% /dev/shm/usr/tmpDSK 549M 21M 500M 4% /tmp
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).
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:
- Click on “Copy Multiple Accounts/Packages From Another Server” (under Transfers)
- Fill out the old server data
- Select the accounts to transfer
- Start the transfer process (this can take some time)
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!
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
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.
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.
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?
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.
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
# install Digest::SHA1 Crypt::PasswdMD5
After running this try Easy Apache in WHM again and eveything should be working just fine!