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 , you can then migrate the data from the disk partitions to the logical volumes you’ve created. Reference:-  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
This is a common partition management issue and is not unique to AWS, and happens on all OSes (win/mac/linux)
To understand the issue better, do a web search for the term 'How to extend C drive to a non adjacent partition' , to get more info on this. Or see - https://www.reddit.com/r/sysadmin/comments/10rl05w/how_to_extend_c_drive_to_a_non_adjacent_partition/
You will need to use a rescue instance along with proper partition management software such as-
GParted (Needs GUI via X11) - see https://www.pcquest.com/pcqlinux-gparted-aws-appliance/ Minitool Partition Manager -Paid AOMEI Partition Assistant - Paid
- to shuffle partitions down to the new unused space on the right. Then there should be free space to the right of the partition you want to extend and you regular partition expansion cli or above software can expand the 'sanwiched' partition. Please take a snapshot before you start.
Also its AWS best practice to keep one partition on one EBS volume, that way you would never run into this issue.
- Accepted Answerasked 6 months ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 5 months ago
- EXPERTpublished a year ago
- EXPERTpublished 6 months ago