Linux – AWS fails to resize an RHEL64 instance upon launch

amazon-web-serviceslinuxlinux-kernelredhat

I'm using AWS to boot up a RHEL64 instance but the disk is failing to resize to fit the volume I've selected.

Here's the scenario:
I Launch a running instance from the Marketplace AMI ami-517eec6b (which is RedHat's approved RHEL64 image), and select a volume size of say 30GB. The instance launches successfully however the fdisk and df output do not match up.

ie,
df is showing the filesystem reported to only 8GB (the default size)

$ df -h 
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1      5.7G  2.3G  3.4G  41% /
none            1.8G     0  1.8G   0% /dev/shm

fdisk is showing the volume to be the correct 30gb.

$ sudo fdisk -l 

Disk /dev/xvda: 32.2 GB, 32212254720 bytes
4 heads, 32 sectors/track, 491520 cylinders
Units = cylinders of 128 * 512 = 65536 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00072e87
    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1               1       93750     5999984   83  Linux

I thought I could just resize this filesystem (based on comments I've found from other articles), however this doesn't appear to work.

$ sudo resize2fs /dev/xvda1
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 1499996 blocks long.  Nothing to do!

Here's the O/S version

$ uname -a 
Linux ip-10-100-155-254 2.6.32-431.el6.x86_64 #1 SMP Sun Nov 10 22:19:54 EST 2013 x86_64 x86_64 x86_64 GNU/Linux

I'm guessing I can probably attach this to another instance and resize the filesystem however I'm more concerned that the AMI cannot detect the volume presented to it.

I'm thinking this is more than likely the OS kernel not picking up the underlying volume changes, but need some help in proceeding to fix this.

What's going on and how can I correct this upon boot ?

Thanks in advance!

Best Answer

The reason you cannot resize the file system is, that it is already taking up all the space in the partition. Growing the disk didn't change the partition table, so you still have a partition of the same size and free unpartitioned space on the rest of the disk.

The necessary steps are:

  • Grow the virtual disk (you did this already)
  • Grow the partition (this is what you forgot)
  • Reboot (to reload the partition table, only needed if the disk was busy)
  • Grow the file system
Related Topic