Murtaza Kanchwala Murtaza Kanchwala - 6 months ago 26
Linux Question

Root Partition not of the size of EBS

I created one OEL 6.6 Ec2 on AWS in one of the Region.

And assigned

Root Partition 25GB (When first seen it was hinting 15G)
And other EBS for other purpose


When I did
lsblk
on it I found that

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 25G 0 disk
└─xvda1 202:1 0 15G 0 part /


While I created one of the Amazon's preferred AMI like : Amazon Linux Image or Centos provided Community AMI's I found :

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 25G 0 disk
└─xvda1 202:1 0 25G 0 part /


Can anyone please explain me what is wrong here. Are these Logical partitioning done by the AMI vendor's at the time of creation or is something wrong with my configurations on AWS itself? How can I overcome this as I need that AMI only?

Answer

Yes, Amazon Linux contains a customized version of cloud-init, an open source application built by Canonical that is used to bootstrap Linux images in a cloud computing environment, such as Amazon EC2.

Cloud-init tools can detect if the root file system (/) size differs from the partition size and utilize the appropriate filesystem expansion tool (e.g. resize2fs for ext4) to match the partition size.

From Amazon Linux AMI 2014.03 Release Notes:

Cloud-Init has been updated to the 0.7 series, adding a number of useful features. One example is dracut-modules-growroot, which automatically resizes your root filesystem on boot.

Suggested solution (by @Murtaza Kanchwala):

You need to install that following module via these steps :

wget ftp://195.220.108.108/linux/epel/6/x86_64/cloud-utils-growpart-0.27-10.el6.x86_64.rpm
wget ftp://rpmfind.net/linux/epel/6/x86_64/dracut-modules-growroot-0.20-2.el6.noarch.rpm
rpm -ivh cloud-utils-growpart-0.27-10.el6.x86_64.rpm
rpm -ivh dracut-modules-growroot-0.20-2.el6.noarch.rpm
rpm -qa kernel | sed 's/^kernel-//'  | xargs -I {} dracut -f /boot/initramfs-{}.img {}
growpart /dev/xvda 1
init 6 or Restart using Amazon's own console