By using AWS re:Post, you agree to the Terms of Use

Can I increase the partition size in EBS volume if I have adjacent partition - Linux

0

I have a Linux instance which has a 100GB EBS volume, within the volume I have two adjacent partitions: one is 30GB, another is 20GB. Can I increase the 30GB partition to 40GB without formatting or re-partitioning this ESB volume? My concern is the 20GB partition has already packed the adjacent space.

asked 2 months ago52 views
1 Answers
0
Accepted Answer

So, as you say, “I have a Linux instance which has a 100GB EBS volume, within the volume I have two adjacent partitions: one is 30GB, another is 20GB. Can I increase the 30GB partition to 40GB without formatting or re-partitioning this ESB volume? My concern is the 20GB partition has already packed the adjacent space.”

create snapshot of the root EBS volume that's attached as backup.

I presume your disk look something similar to this:

[ec2-user ~]$ lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT xvda 259:1 0 100G 0 disk

└─xvda1 259:2 0 30G 0 part /

└─xvda2 259:3 0 20G 0 part /data

In above example, the disk is /dev/xvda and it contains partitions xvda1 and xvda2 inside it. As you may already know, partitions inside the disk are ordered in contiguous blocks, this means you are limited in increasing the size of some partitions inside this disk to the last partition (xvda2) only. Since disk partitions are ordered in contiguous blocks, one after another in sequence, when you increase the disk the additional space is added at the end of the blocks. In this case, only the last partition can take advantage of the newly increased space, i.e partition /dev/xvda2 in this scenario. Any partition in the beginning or middle of the disk won’t be able to take advantage of the newly available space. This is generally how traditional Linux disk space is designed, to be in contiguous blocks. Having said this, you cannot fully achieve increasing first or middle partitions without formatting or re-partitioning the entire EBS volume.

A solution or workaround to this limitation is introducing LVM logical volumes to replace the partitions you have in place and use logical volumes. Generally, you would have to provision a new disk and format it entirely with LVM. The steps involve: i. creating a Physical Volume from your EBS volume ii. creating a Volume Group and add the physical volumes into the volume group iii. creating a Logical Volume and mount directories on the LVM iv. creating and mounting a file system v. thereafter, you will be able to resize the logical volume Once LVM is created as per steps in link [1], you can then migrate the data from the disk partitions to the logical volumes you’ve created. Reference:- [1] https://aws.amazon.com/premiumsupport/knowledge-center/create-lv-on-ebs-volume

This is very tricky with Boot volumes, so you will need to proceed with caution, with the help of the Linux Engineer / SysAdmin

if there's anything you need help with feel free to reach out to me

answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions