Linux > Virtualization

How to extend-resize Linux root partition on AWS EC2

(1/1)

akhilt:
How to extend-resize Linux root partition on AWS EC2

We need to find different approach when we want to extend-resize Linux root partition on AWS EC2. This article will quickly guide us on how we can extend-resize Linux root partition on AWS EC2.

Steps involved in extend-resize Linux root partition on AWS EC2

Here we have already running Linux AMI EC2 instance. The volume size which is attached to Ec2 is 10 GB as below:



As usual, On the Linux end, the same size is reflected for root partition:


--- Code: ---[root@server ~]# df -h

Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda2       10G  1.1G  9.0G  11% /
devtmpfs        477M     0  477M   0% /dev
tmpfs           496M     0  496M   0% /dev/shm
tmpfs           496M   13M  483M   3% /run
tmpfs           496M     0  496M   0% /sys/fs/cgroup
tmpfs           100M     0  100M   0% /run/user/1000
[root@server ~]#
--- End code ---

Now we want to make the size of root volume to 21 Gb instead of 20 Gb. Here are steps to follow to achieve this:

Step1: Stop the respective Ec2 instance

Resizing operation begins with stopping the Ec2 instance. Kindly note below information before stopping the instance:

   1.  Availability zone: ap-south-1a
    2. Instance ID: i-000fd8a4f5afb795f
    3. Root device: /dev/sda1

Step2: Take the snapshot of the respective volume

In our case, we need to take the snapshot of the volume with volume ID “vol-0992c847ad2cb5219” which is acting as root volume our Linux EC2 instance.

    - Go to ELASTIC BLOCK STORE –> Volumes on the left side-pane of AWS console.

       

    - Now on the right-hand side, select the respective volume, in our case “vol-0992c847ad2cb5219” and click on Action drop-down button. Then select create Snapshot option.

       

    - In the next popup enter the appropriate details about snapshot such as name and description and click on Create button.

       

To check the status of the snapshot, go to ELASTIC BLOCK STORE –> Snapshots. Make sure snapshot has completed status before proceeding further.

       

Step3: Create new volume from snapshot taken.

Then we need to create a new volume from the snapshot taken in the step1.

     - Now to create volume from the snapshot taken, you need to select the snapshot and select “Create Volume” option under Action drop-down menu.

       

     - Now in next popup option enter the size of the volume 21 GB (size that need to be extended) and Availability zone ( collected in step1). Then click on Create Button.

       

     - System will respond with volume ID details upon successfully creating the volume. Kindly note down the volume ID to avoid confusion.

       

Step4: Detach old volume.

Once you are done with creating newly extended volume you need to detach the old volume from EC2 instance.

     - Go to ELASTIC BLOCK STORE –> Volumes and select volume with ID “vol-0992c847ad2cb5219”. This volume will be having status as “in-use”.

       

     - Then click on Detach volume option from Action drop down menu.

On successfully attaching the volume status revised to “In-use”.

Step5: Attach newly created extended volume.

Now attach newly created volume with volume ID “vol-089327c3c3072e6ca” with size 21 Gb. Make sure status of volume is “Available” before proceeding.

     - Go to ELASTIC BLOCK STORE –> Volumes and select volume with ID “vol-089327c3c3072e6ca”. This volume will be having status as “available”.

     - Then click on Attach volume option from Action drop-down menu.

       

In the next popup window enter details collected in the step1 and Click on Attach button.

       

On successfully attaching the volume status revised to “In-use”.

Step6: Start the EC2 instance.

This is the final step in which we need to start the instance. Select the instance from EC2 dashboard then right click to choose Start option.

       

Login to respective EC2 instance to confirm the root partition extension.

[root@server ~]# df -h

Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda2       21G  979M   21G   5% /
devtmpfs        477M     0  477M   0% /dev
tmpfs           496M     0  496M   0% /dev/shm
tmpfs           496M   13M  483M   3% /run
tmpfs           496M     0  496M   0% /sys/fs/cgroup
tmpfs           100M     0  100M   0% /run/user/1000
[root@server ~]#

We can notice that size of the root partition has been increased to 21Gb.

So This is how we can extend-resize Linux root partition on AWS EC2. ;D 8)

Thank you!!! :)

Navigation

[0] Message Index

Go to full version