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
Below is my Amazon S3 Review for 2013.
What is Amazon S3
S3 stands for Simple Storage Service and is exactly that. S3 is storage that is located in Amazons large data centres across the world, designed to make web-scale computing easier for developers. Amazon S3 provides a simple web services interface that can be used to store and retrieve any amount of data, at any time, from anywhere on the web.
I was sceptical when I first started looking into S3 as I didn’t believe it was as cheap as people said it was. After using it for the past 4 months I know now why people love it! The clue really is in the name “Simple”. The user interface is easy to use and is clean, the pricing again is simple and easy to understand. Keep on reading below, where I will go into more detail about why I love S3.
S3 operates on a basis of paying only for what you use, with separate fees for storage and data requests. The fees break down as follows:
5GB FREE (for the first year), then $0.095/GB per month (100GB = $9.50)
Data Transfer (Upload)
$0.00/GB Yes FREE for the first 1TB of data
Data Transfer (Download)
$0.00/GB Yes FREE for the first 1TB of data
PUT, COPY, POST, or LIST Requests
Find out more about the prices here.
No-one can really argue with these prices, and yet Amazon keeps dropping there prices! Only a few years ago S3 storage was priced at $0.15/GB and people thought that was cheap, now with it at an all time low of $0.095/GB people are wondering just how cheaper it can go.
I know this is an S3 review but I wanted to bring your attention to a similar service as part of Amazons Web Services and almost a brother to S3 – Glacier.
Glacier is one of Amazons other 25 web service products that is designed to be used for large amounts of data you want to archive away and not touch very often. This is known as Cold Storage. This is because the data is stored deep inside Amazon’s servers where you know its safe but unlike S3 you have less of a need to keep dipping into your data. If you suddenly have the need to access your data you can, however it takes anywhere between 3 to 5 hours to retrieve your data from the Glacier servers. Almost think of Glacier like storing something in a freezer for years until that one day when you need it and you have to wait for it to defrost before using it.
Amazons Glacier’s pricing is as little as $0.01 per GB / month!
Its very hard to find something wrong to write about Amazon S3 because its just so easy and simple to use. You know how much your bill will be at the end of each month and you know the bill will be lower than you think it will be (I know I did). I even managed to not pay a penny for 3 of the 4 months I have been using S3.
Give Amazon S3 a go, I think you will be surprised.
If you already use S3 or any other often Amazon’s web services I’d love to hear your experience.
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!