Facebook X (Twitter) Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook X (Twitter) Instagram
    TecAdmin
    You are at:Home»AWS»Resizing the Root Partition on an AWS Linux Instance

    Resizing the Root Partition on an AWS Linux Instance

    By RahulJanuary 19, 20234 Mins Read

    AWS elastic volumes changed the way of using volumes in ec2 instances. You can now modify the volume’s volume size, performance, or volume type while the volume is in use. Your application will continue to function normally while the change takes effect.

    With a simple API call, you can instantly make changes to your storage infrastructure, eliminating or simplifying many of your planning, tuning, and space management duties. Instead of a traditional provisioning process that takes weeks or months, you can now make instantaneous changes to your storage infrastructure.

    This tutorial will help you to resize the root partition of the ec2 Linux instance without any downtime for your application. The same steps will also helpful to increase other partitions (non root) of the system.

    WARNING: It is strongly recommended to create a full backup (AMI) of your instance before resizing the root volume. This will be helpful for recovering from any unexpected failures.

    Resize EBS Volumes in EC2 Linux Instances

    The AWS elastic volumes allow online resizing of the volumes without any downtime of your applications. This is very useful for production applications. Here is the step-by-step tutorial to resize the EBS volume on the EC2 instance and grow the partition size.

    1. I have a running ec2 instance with Ubuntu Linux. Login to the EC2 dashboard in the AWS account and identify your instance.

      Increase Disk Size on Ec2 Linux Instance
      Running Ec2 Instance
    2. That was initially launched with 12 GB of EBS volume attached to the EC2 instance. As the application data size grows now, we need to increase the disk space.

      Increase Disk Size on Ec2 Linux Instance
      Current EBS Volume Size
    3. Check the size of the EBS volume partition attached to the root file system.
      Increase Disk Size on Ec2 Linux Instance
      Check disk size attached to root filesystem.
    4. Go to the EC2 dashboard and right-click on the EBS volume attached to your instance. Click Modify Volume:
      Resize Root Disk in Ec2 Linux  Instance
      Modify EBS Volume
    5. A dialog box will appear in the browser.Set a new size for your EBS volume and click Modify
      Resize Root Disk in Ec2 Linux  Instance
      Set the new size for EBS volume
    6. The volume will now begin the resize and optimization process, which you can see on the console. This will take a couple of minutes to complete ebs resize process. You will see a message in the volume state column:
      How to Resize Ec2 Disk Size in AWS
      Modifying EBS Volume
    7. Wait until the volume state column change to “in-use” with green color.

      How to Resize Ec2 Disk Size in AWS
      EBS volume after resizing
    8. Login to your instance and type “lsblk” command to view attached volumes and disk partitions. You may find that the volume size is increased but the partition mounted on the root (/) file system is still the same.

      Increase Disk Size on Ec2 Linux Instance
      Check increased volume size
    9. Use the “growpart” command to resize the root partition up to the free available volume. This command takes two parameters, first if the volume name, and second is the partition number.

      How to Resize Ec2 Disk Size in AWS
      Resize root partition

      Now you can see the partition size is also increased with the “lsblk” command.
    10. Now, you need to resize the partition manually from the command line. Before this, identify the type of filesystem on that partition with the following command:
      How to Increase Root Disk in Linux Ec2 Instance
      Check filesystem type
    11. Finally, resize the partition based on the filesystem. In my case, the partition was formatted with Ext4. So I used the “resize2fs” command to resize it.

      How to Resize Ec2 Disk Size in AWS
      Resize root partition

      If the partition is formatted with the XFS file system, then use “xfs_growfs -d /” command to perform this operation.
    12. All done!

    Wrap Up

    The new AWS elastic volumes allow online resizing, which is very helpful for production environments. You can quickly increase the disk size of your instances without any downtime. In this tutorial, you have learned about resizing ebs volume on ec2 Linux instances.

    In this guide, we have provides you steps to quickly resize the volume on an EC2 Linux instance.

    aws ebs ec2 root volume
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    AWS IAM Policy to Allow ssm:GetParameter

    Create AWS Cognito User with AWSCLI

    How to Create User Manually in AWS Cognito (CLI)

    Check if a script is running as root user in Linux

    View 9 Comments

    9 Comments

    1. Deepak Sharma on June 14, 2018 11:47 am

      after doing this could we save data?

      Reply
    2. Fazlu on July 16, 2017 6:17 pm

      Never save after making the changes in the disk partition. Just Quit without saving and perform a reboot. After that, log in and you can see the root volume size has increased.

      Reply
    3. Someone on May 14, 2017 5:12 pm

      Excellent! thank you very much for this step by step guide!

      Reply
    4. giuseppe on May 4, 2017 10:45 am

      After delete the partition I can’t boot anymore…grub shows up

      Reply
    5. giuseppe on May 4, 2017 10:45 am

      After delete the partition I can’t boot enaymore…grub shows up

      Reply
    6. prem on April 19, 2017 6:59 am

      wow and gud job plz update in future this type of cmd

      Reply
    7. Kevin on August 6, 2016 9:07 am

      This is great info, much easier than detaching, reattaching to a different instance to resize it, etc, etc.
      It’s just what is needed for resizing a CentOS instance that was launched with a bigger-than-default size boot volume. Thank you so much for posting this!

      Reply
    8. Carlo on May 30, 2016 8:25 am

      This is really helpful. Thank you very much.

      Reply
    9. Rohit on February 10, 2016 3:27 pm

      Thanks man,

      You saved my lot of time.
      It will be great if you explain how you achieved this.

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Difference Between Full Virtualization vs Paravirtualization
    • Virtualization vs. Containerization: A Comparative Analysis
    • Using .env Files in Django
    • Using .env File in FastAPI
    • Setting Up Email Notifications for Django Error Reporting
    Facebook X (Twitter) Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.