1

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!

Snowy
  • 21
  • 1
  • 4

2 Answers2

1

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
kasperd
  • 30,455
  • 17
  • 76
  • 124
  • Could you elaborate on the commands required for growing the partitions. I've already tried parted, and fdisk to no avail, as the filesystem is mounted and cannot be re-sized without rebooting. Essentially I'm attempting to have the filesystem match the volume size upon boot. – Snowy Mar 24 '15 at 02:49
  • @user1520554 If you resize a mounted partition it won't take effect immediately. It will take effect on next reboot. – kasperd Mar 24 '15 at 07:24
1

So found this in my digging,

Unfortunately, this is a known bug on RHEL/CentOS 6.5 AMIs, however there are two workarounds to extend the file system as you requested:

You can mount the volume to another instance and use parted to expand the partition boundary for the volume that the root FS is on as mentioned at the below link: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/storage_expand_partition.html

You can use the dracut growroot module which will generate a new initramfs and grow the partition to the size of the volume. This can be performed using the following:

  1. Ensure the EPEL repo is enabled, and if not, enable the repo with the following: wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm -i epel-release-6-8.noarch.rpm

  2. Instruct dracut to rebuild the initramfs with the growroot dracut module:

    dracut --force --add growroot /boot/initramfs-$(uname -r).img

  3. Reboot the instance and confirm the partition size has expanded using lsblk and df You were also inquiring on why PV is not supported on the new T2 instance types. This is because PV provides abstraction between the instance and the hardware layer, which prevents CPU credits on T2 instance types from working. In general, HVM is now the more common virtualization technology that we are using due to the new instruction-sets on Intel CPUs that PV does not support.

After going this it does indeed re-size upon boot as I wanted.

Snowy
  • 21
  • 1
  • 4