DevOps Interview: Increase EBS volume size

AWS EBS volume is one of the popular persistent block storage services in AWS. Sometimes, based on our needs we want to increase the size of the volume. We will go through steps to increase the size.

Good Practices:

  1. It's always a good practice to back up important data on your EC2 instance.

  2. Taking a snapshot of your EBS volume can serve as an additional backup.

Follow the below steps to increase the size.

  1. From the EC2 dashboard, select the required EBS volume name from the EBS lists. Choose "Actions" > "Modify Volume Size". Enter the new size and fill in the details like description, key-value name etc. and create a snapshot. It will take a few minutes.

  2. Again click on volume and go to "Modify Volume". Fill in the size based on your needs and click "modify". You will get a pop-up "Are you sure want to modify the volume" click "Yes".

  3. Now we need to extend the OS file system to see increased size. Log into the ec2 instance attached with the EBS volume. In the terminal, run the "lsblk" command. It means "list block device". It will list the associated block devices. After running this command, you will see your increased volume above your current volume size.

  4. We need to extend the partition in a partition table using the "growpart" cmd.

    syntax- growpart < device name and partition number>

    e.g.- growpart /dev/xvdf 1

    This command will ask the system to grow the first partition on the device /dev/xvdf to fill the available space.

  5. Now we will resize the filesystem using "resize2fs" cmd. It adjusts the size of the filesystem to fill the available space on the underlying partition.

    syntax- resize2fs <<device name and partition number>>

    e.g.- resize2fs /dev/xvdf1

    After running this command, the filesystem on /dev/xvdf1 will be resized to use the available space on the partition.

  6. you can now run" df -Th" to check volume size.

That’s all. Pat yourself on the back. :)

Hope you enjoyed it. Don’t forget to like it.

Did you find this article valuable?

Support Aishwary Prakash by becoming a sponsor. Any amount is appreciated!