Recently I ran out of storage on a AWS cloud-based virtual machine. In this guide I show a quick overfiew of the process of enlarging an AWS EC2 volume and file system. The terminology depends wheter the architecture is Xen or Nitro based, this tutorial is for Xen based architecture.
Part 1: AWS Web Interface #
To following steps can be done while the EC2 instance is running, but it’s only possible with EBS (gp2) volumes.
- Go to Instance / Storage
- Select Volume
- Select “Modify Volume”
- Increase Volume Size
Wait till “Volume Status” jumps from modifying
state to optimizing
or completed
and
go ahead with Part 2.
Part 2: SSH into the EC2 instance #
Use the lsblk
command to find the name of the partition. The
output should look as follows:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
xvda 202:0 0 8G 0 disk
├─xvda1 202:1 0 7.9G 0 part /
Choose the partition the should be extended and use the growpart
command to do so:
sudo growpart /dev/xvda 1 |
Extend the partition with growpart |
lsblk |
Check the new size of the partition |
Use the df -hT
command to list name and mount point for the file system that needs to be extend
and extend the file system with resizefs
.
df -hT |
List name, size, type and mount point for the file system |
sudo resize2fs /dev/xvda1 |
Extend the mounted file system named /dev/xvda1 |
Disk without partition #
When the disk has no partition, you can skip the growpart
command and
just check the new disk size with the following command fdisk -l /dev/<disk_name>
,
for example: fdisk -l /dev/xvdb
.
After that you can increase the file system resize2fs /dev/xvdb
.