New server created with 20GB Drive.

# fdisk -l

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00028fed

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          66      524288   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2              66        2611    20446208   8e  Linux LVM

Disk /dev/mapper/centos-swap: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/centos-root: 19.9 GB, 19860029440 bytes
255 heads, 63 sectors/track, 2414 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

# lvs
  LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos -wi-ao---- 18.50g
  swap centos -wi-ao----  1.00g

Check Physical Volumes

# pvs
  PV         VG     Fmt  Attr PSize  PFree
  /dev/xvda2 centos lvm2 a--  19.50g    0

Now I upgrade the cloud server
to
1024 MB RAM, 1 Core, 40 GB Disk

After upgrade…

# fdisk -l

Disk /dev/xvda: 40.8 GB, 40802189312 bytes
255 heads, 63 sectors/track, 4960 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00028fed

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          66      524288   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2              66        2611    20446208   8e  Linux LVM

Disk /dev/mapper/centos-swap: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/centos-root: 19.9 GB, 19860029440 bytes
255 heads, 63 sectors/track, 2414 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

# lvs
  LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos -wi-ao---- 18.50g
  swap centos -wi-ao----  1.00g
# pvs
  PV         VG     Fmt  Attr PSize  PFree
  /dev/xvda2 centos lvm2 a--  19.50g    0

Create a new partition (n). Make it primary (p). The start and end should be the defaults provided by fdisk.

# fdisk /dev/xvda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p

Disk /dev/xvda: 40.8 GB, 40802189312 bytes
255 heads, 63 sectors/track, 4960 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00028fed

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          66      524288   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2              66        2611    20446208   8e  Linux LVM

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (2611-4960, default 2611):
Using default value 2611
Last cylinder, +cylinders or +size{K,M,G} (2611-4960, default 4960):
Using default value 4960

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 or after you run partprobe(8) or kpartx(8)

Reboot the VM so the kernel picks up the partition changes.

# shutdown -r now

Check for the new partition

# fdisk -l

Disk /dev/xvda: 40.8 GB, 40802189312 bytes
255 heads, 63 sectors/track, 4960 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00028fed

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          66      524288   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2              66        2611    20446208   8e  Linux LVM
/dev/xvda3            2611        4960    18869680   83  Linux

Disk /dev/mapper/centos-swap: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/centos-root: 19.9 GB, 19860029440 bytes
255 heads, 63 sectors/track, 2414 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Run “pvcreate /dev/xvda3” to make /dev/xvda3 a LVM partition.

# pvcreate /dev/xvda3
  Physical volume "/dev/xvda3" successfully created

Check for the name

# vgs
  VG     #PV #LV #SN Attr   VSize  VFree
  centos   1   2   0 wz--n- 19.50g    0

Run “vgextend centos /dev/xvda3” to add /dev/xvda3 to the centos volume group.

# vgextend centos /dev/xvda3
  Volume group "centos" successfully extended

Check again…


# lvs
  LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos -wi-ao---- 18.50g
  swap centos -wi-ao----  1.00g

Root “lvresize -r -l +100%FREE centos/root” to resize the / partition.

# lvresize -r -l +100%FREE centos/root
  Size of logical volume centos/root changed from 18.50 GiB (4735 extents) to 36.49 GiB (9341 extents).
  Logical volume root successfully resized
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/centos-root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 3
Performing an on-line resize of /dev/mapper/centos-root to 9565184 (4k) blocks.
The filesystem on /dev/mapper/centos-root is now 9565184 blocks long.

Run “df -H”. You should now see 30+ GB size on the / partition.

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/centos-root
                       36G  928M   34G   3% /
tmpfs                 496M     0  496M   0% /dev/shm
/dev/xvda1            504M   62M  417M  13% /boot

And fdisk again

# fdisk -l

Disk /dev/xvda: 40.8 GB, 40802189312 bytes
255 heads, 63 sectors/track, 4960 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00028fed

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          66      524288   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2              66        2611    20446208   8e  Linux LVM
/dev/xvda3            2611        4960    18869680   83  Linux

Disk /dev/mapper/centos-swap: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/centos-root: 39.2 GB, 39178993664 bytes
255 heads, 63 sectors/track, 4763 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

I have just intalled apache on a fresh CentOS 6.5 installation. I entered the ip address in the browser address bar, and it failed to connect. I then turned off iptables, and refeshed, and this time I could connect.

So clearly iptables is blocking the http (port 80) traffic. So I looked at the iptables rules:

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

It seems confusing as there is a “accept all” rule. I typed this – it explains the devices as well where acept all is on the lo interface. So all eth connections are dropped.:

# iptables -L -v
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
   11   764 ACCEPT     all  --  any    any     anywhere             anywhere            state RELATED,ESTABLISHED 
    0     0 ACCEPT     icmp --  any    any     anywhere             anywhere            
    0     0 ACCEPT     all  --  lo     any     anywhere             anywhere            
    0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere            state NEW tcp dpt:ssh 
    0     0 REJECT     all  --  any    any     anywhere             anywhere            reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 REJECT     all  --  any    any     anywhere             anywhere            reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT 6 packets, 824 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Edit iptables to add the rule:


# nano /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited

Copy the ssh port 22 line and add it right under it, then change the port to 80. This is what it should look like:

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited

Restart iptables

# service iptables save
service iptables restart