How to resize the Root Disk on a running EBS Boot EC2 Instance
Environment
-
Red Hat Enterprise Linux (RHEL) 6.x
-
Amazon EC2
Issue
- How to resize the Root Disk on a running EBS Boot EC2 Instance
Resolution
In the following example, we have a RHEL 6.2 EC2 running instance with 6GB root disk size. This is being extended to 15GB as per the requirement.
-
Check the Root Disk size of EC2 Instance and verify the size.
[root@domU-12-31-39-0A-20-51 ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.2 (Santiago) [root@domU-12-31-39-0A-20-51 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/xvde1 5.7G 1.9G 3.7G 35% / none 3.7G 0 3.7G 0% /dev/shm
-
Login to AWS Console using your AWS sign up credentials. Now select the running instance under INSTANCES >> Instances and stop it.
-
After stopping the instance, go to ELASTIC BLOCK STORE >> Volumes. Identify the EBS volume for the instance and click option "Detach Volume" to detach it from the current instance.
-
On the same page click "Create Snapshot" to create Snapshot of the detached volume.
- Go to ELASTIC BLOCK STORE >>Snapshots, select the created snapshot, choose the option "Create Volume", specify the required size of 15GB here and create it .
- Go back to ELASTIC BLOCK STORE >> Volumes where you will have the new Volume created, choose the new Volume and click on "Attach Volume", here you choose the instance and specify the Device to /dev/sda1 which is the boot EBS to be attached.
- Go back to INSTANCES page and start the instance. Note that you will have a new public IP address/hostname. (If you were using an elastic IP address, re-assign it to the instance.)
-
Connect the instance using ssh and resize the root file system to show up the new EBS volume.
[root@domU-12-31-39-10-32-11 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/xvde1 5.7G 1.9G 3.7G 35% / none 3.7G 0 3.7G 0% /dev/shm [root@domU-12-31-39-10-32-11 ~]# resize2fs /dev/xvde1 resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/xvde1 is mounted on /; on-line resizing required old desc_blocks = 1, new_desc_blocks = 1 Performing an on-line resize of /dev/xvde1 to 3932160 (4k) blocks. The filesystem on /dev/xvde1 is now 3932160 blocks long. [root@domU-12-31-39-10-32-11 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/xvde1 15G 1.9G 13G 13% / none 3.7G 0 3.7G 0% /dev/shm [root@domU-12-31-39-10-32-11 ~]#
Note: You can delete the old volume, but it is recommended to keep the snapshot for a while.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments