AWS - jrwhetse/jrwhetse.github.io GitHub Wiki

AWS EC2 Volumes

Table of Contents

Overview

A disk or volume can be a single entity or broken up into partitions. Disks are located in /dev and are named sd[a-z]. Disk partitions are logical divisions of disks located in the /dev directory and are named /dev/sd[a-z][1-9].

A partition table is a special structure containing partition organizations. Two types of partition tables exist: Master Boot Record (MBR) and GUID Partition Table (GPT).

MBR partition table uses 512-byte sectors and allows for 4 main primary partitions only. If you want more, you need to create an extended partition using one of the 4 primary slots then create a logical partition inside.

GPT uses 4096-byte sectors and was created to work around the limitations imposed by MBR, specifically the 2TB limitation.

Volume Expansion

Login to the AWS Console and select the EC2 module. Select the Instances menu link on the left hand menu. In the filter input box at the top of the table enter the instance name requiring Volume Expansion. Select the instance and view the description tab at the bottom of the page. A section called block devices will list all volumes attached to the instance. Select the volume you wish to expand and then click the volume EBS ID on the pop up window. This will take you to the Volumes section where you can Create, Modify or Delete volumes. In this case, the volume you selected should be in the table.

Right mouse click the volume and select Modify Volume

aws-volumes-modify1

In the Modify Volume screen, modify the volume size. (Note: XFS volumes can only be expanded)

aws-volumes-modify2

After making modifications to the volume, wait for the Volume State to contain a green icon, meaning the modifications to the volume size are complete.

aws-volumes-modify3

Login to the instance containing the volume to be increased. There are 2 different actions that can be taken depending on if the volume is partitioned or the entire device block is managed by LVM. To determine if the disk contains a partition, run the lsblk command. If the disk contains a partition, you will see an entry under the disk with the TYPE "part". If a partition isn't used, you will see TYPE "lvm"

# example of a disk with partition
lsblk
NAME                MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
nvme1n1             259:0    0 1000G  0 disk
├─nvme1n1p1         259:1    0   60G  0 part
│ └─vg_opt-lv_opt   253:3    0  2.5T  0 lvm  /opt
└─nvme1n1p2         259:2    0  940G  0 part

# example of a disk without partition
NAME                          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
xvdf                          202:80   0  100G  0 disk
└─vg_docker-lv_var_lib_docker 253:7    0  100G  0 lvm  /var/lib/docker

For TYPE part, run the following commands

# install utility in order to grow partition size without using fdisk
yum install cloud-utils-growpart

# expand the partition
growpart /dev/<device_name> <partition> 1

# list physical volumes
pvs

# resize partition
pvresize /dev/<parition>

# list volume groups and logical volumes
vgs;lvs;

# extend the logical volume
lvextend -l +100%FREE /dev/<volume_group>/<logical_volume>
xfs_growfs /dev/<volume_group>/<logical_volume>

# verify
lsblk 

For TYPE lvm, run the following commands

# list physical volumes
pvs

# resize device
pvresize /dev/<device_name>

# list volume groups and logical volumes
vgs;lvs;

# extend the logical volume
lvextend -l +100%FREE /dev/<volume_group>/<logical_volume>
xfs_growfs /dev/<volume_group>/<logical_volume>

# verify
lsblk 
⚠️ **GitHub.com Fallback** ⚠️