How to decrease size the EBS root volume of the RHEL instance in AWS?

0

Created an RHEL instance with an root EBS volume of 200GB. Currently it uses only 10% of the available volume. How to decrease the size of the EBS volume in AWS?

I followed the below mentioned steps to decrease the root volume size.

1.Stopped the instance

2.Dettached the root volume from the instance

3.Attached the root volume to an another instance which is running

4.Created a new volume with the required size. (Lets say 50GB)

5.Attached the new volume to the running instance

6.Copied all the data from the old volume to the new volume

7.Detached the new volume and attached to the stopped instance.

8.Created the AMI for the old instance.

9.Relaunched the instance from the AMI The instance is showing starting and after some time it is automatically shutting down.

PFB the executed commands

sudo mkdir /new /old    create new directories
sudo mkfs.ext4 /dev/xvdf    create new filesystem on new volume
sudo mount -t ext4 /dev/xvdf /new   mount it to this directory
sudo e2label /dev/xvdf uec-rootfs   needs an e2label for linux to recognize it, use sudo e2label /dev/sda1 on an active instant to see what it should be
sudo mount -t ext4 /dev/xvdg /old   mount old vol to directory for copying
sudo cp -p /old /new    didn’t really do anything.. Skipped a bunch
sudo rsync -ax /old /new    took a while
sudo mv /new/old/* /new/
sudo umount /new    unmount vols
sudo umount /old

Kindly help to resolve the issue.

Nithin K Anil

Posted 2016-09-13T08:16:08.457

Reputation: 101

Decrease is far, far more difficult to explain than increase. – Michael - sqlbot – 2016-09-13T13:28:38.723

@Michael-sqlbot Thats why i asked this question here :P – Nithin K Anil – 2016-09-13T13:29:59.887

Can you not just snapshot the volume, create a new volume with your desired size based on that snapshot? – Tim – 2016-10-03T19:25:55.447

@Tim From snapshot you can increase the size but you cannot decrease the size – Nithin K Anil – 2016-12-10T14:05:09.183

No answers