|
Categories: AWS

There is a known issue with RHEL 6.6 AMI where even if choose an EBS volume of over 10GB in size you will still end up with 6GB root partition. This issue is described here – https://bugzilla.redhat.com/show_bug.cgi?id=1155742

So how would you extend the root partition if it is running out of space?

Here is a step by step guide on how to extend the root partition on a AWS RHEL 6.6 instance.

First we deploy a new instance using the RHEL 6.6 HVM AMI, we will be changing the EBS volume size to 100GB

Now once the instance is launched, initiate a SSH session using PUTTY

Let’s run the lsblk command to check the volume and partition sizes.

We can see that volume size is 100GB however the partition size has not increased and is still 6GB

Next step is to power this instance OFF.

Under the description on the instance properties click on the Root device and then click on the EBS ID

Now we will detach this volume from this instance, to easily identify this volume make sure you add a tag to it.

We would require another instance which we will be using to extend the partition on the 100GB detached EBS volume.

Attached the EBS volume to this newly launch instance.

On the new instance run lsblk to verify the block devices names.

 

We will first be using parted against the 100GB disk to move the backup GPT table to the end of the disk.

[ec2-user ~]$ sudo parted /dev/xvdf

(parted) print

Fix/Ignore? Fix

 

Next we need to install gdisk to make changes to partition information on the disk

[ec2-user ~]$ sudo yum install gdisk

 

Now run the gdisk against the 100GB disk.

[ec2-user ~]$ sudo gdisk /dev/xvdf

Then use print option to capture disk identifier GUID

Command (? for help) : print

Next run o command to remove the existing partition information

Command (? for help) : o

Proceed? (Y/N) : Y

Type n to create new partition information, use the same first sector, last sector and Hex code from the output of print command.

We need to change the GUID back to the value in the print command, first type x to go into expert command.

Use the g command option to specify the original GUID

Lastly use w to save the new configuration on the disk.

Run the e2fsck command to check the filesystem for any errors.

[ec2-user ~]$ sudo e2fsck –f /dev/xvdf1

And resize2fs to increase the size of the filesystem.

[ec2-user ~]$ sudo resize2fs /dev/xvdf1

Now power OFF the new instance

 

Detach the EBS volume from the new instance.

 

Now reattach the 100GB volume to the original instance.

Power ON the original instance and verify the partition size using lsblk and df commands.

 

 

As you can see that whole of 100GB is now available for use. You can create an image (AMI) from this instance for launching any new instance with a root volume size of 100GB.