How to increase the size of the volume in AWS Linux Server

How to increase the size of the volume in AWS Linux Server

April 27, 2020 / Eternal Team

To increase the size of your volume from console side please follow the steps given below :

  • Step 1
    • Login to AWS account

  • Step 2
    • Click on “Service“ located on the top left corner of console

  • Step 3
    • Click on ”EC2

  • Step 4
    • Select “Volume“ on the left side of the console

  • Step 5
    • Click on “Actions

  • Step 6 ( Optional )
    • If you don’t want to create a snapshot please skip and jump to step 7
    • Click on “Create Snapshot

  • Step 7
    • Click On “Modify Volume

  • Step 8
    • Find the size field which will show the current “Size“ of the volume

  • Step 9
    • Input your desired size

  • Step 10
    • Click on “Modify”

Increasing space in the linux server

  • After you increment the size of an EBS volume, you must use a file system–specific commands to extend the file system to the larger size. You can resize the file system while you are working on it.

Just For Information

  • Before extending a file system that contains valuable data, it is best practice to create a snapshot of the volume, in case you need to roll back your changes. For more information, see Creating Amazon EBS Snapshots.

To verify the file system of the instance connect and run the file -s command.

Command for file systems on a Nitro-based Instance

$ sudo file -s /dev/nvme?n*

Command for file systems on a T2 Instance

$ sudo file -s /dev/xvd*

Extending a Partition

  • Increasing the size of from console side will not increase the size of the volume inside the server
  • Use the lsblk command to display information about the block devices attached to your instance

Example: Partitions on a Nitro-based Instance

  • The following example shows the volumes on a Nitro-based instance:
    • $ lsblk
    • NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    • nvme0n1 259:0 0 600G 0 disk
    • └─nvme0n1p1 259:1 0 400G 0 part /
  • The root volume, /dev/nvme0n1, has a partition, /dev/nvme0n1p1. While the size of the root volume reflects the new size, 600 GB, the size of the partition reflects the original size, 400 GB, and must be extended before you can extend the file system.
  • To extend the partition on the root volume, use the following growpart command.
$ sudo growpart /dev/nvme0n1 1
  • TYou can verify that the partition reflects the increased volume size by using the lsblk command again.
    • $ lsblk
    • NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    • nvme0n1 259:0 0 600G 0 disk
    • └─nvme0n1p1 259:1 0 600G 0 part /

Example: Partitions on a T2 Instance

  • The following example shows the volumes on a T2 instance:
    • $ lsblk
    • NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    • xvda 202:0 0 600G 0 disk
    • └─xvda1 202:1 0 400G 0 part /
  • The root volume, /dev/xvda, has a partition, /dev/xvda1. While the size of the volume is 600 GB, the size of the partition is still 400 GB and must be extended.
  • To extend the partition on each volume, use the following growpart commands.
  • $ sudo growpart /dev/xvda 1
  • You can verify that the partitions reflect the increased volume size by using the lsblk command again.
      $ lsblk
    • NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    • xvda 202:0 0 16G 0 disk
    • └─xvda1 202:1 0 16G 0 part /
  • Now just restart your server and space will be increased
AWS-Consulting-Partner

Talk to AWS Certified Consultant

Want to start a project?

It’s simple.

Contact us