Tag: EC2

Expand an EBS volume of an EC2 Linux instance

In the AWS EC2 console navigate to EC2 > Volumes and select the particular volume. Then select Modify volume from the Actions menu.

Set the new size and click Modify.

Since we are increasing the size of the volume, we must extend the file system to the new size of the volume. We can only do this when the volume enters the optimizing state. The modification might take a few minutes to complete.

Once the modification is completed, we log into the instance via SSH and resize the corresponding device.

Let’s verify the file system and type of the volume (in our example it is the root file system):

admin@srv:~$ df -hT
Filesystem      Type      Size  Used Avail Use% Mounted on
udev            devtmpfs  223M     0  223M   0% /dev
tmpfs           tmpfs      47M  5.6M   41M  13% /run
/dev/nvme0n1p1  ext4      8.7G  7.9G  333M  97% /
tmpfs           tmpfs     232M     0  232M   0% /dev/shm
tmpfs           tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs           tmpfs     232M     0  232M   0% /sys/fs/cgroup
/dev/nvme0n1p15 vfat      124M  278K  124M   1% /boot/efi
tmpfs           tmpfs      47M     0   47M   0% /run/user/1000

To check whether the volume has a partition that must be extended, we use the lsblk command:

admin@srv:~$ lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
nvme0n1      259:0    0   10G  0 disk
|-nvme0n1p1  259:1    0  8.9G  0 part /
|-nvme0n1p14 259:2    0    3M  0 part
`-nvme0n1p15 259:3    0  124M  0 part /boot/efi

We use the growpart command to extend the first partition:

admin@srv:~$ sudo growpart /dev/nvme0n1 1
CHANGED: partition=1 start=262144 old: size=18612191 end=18874335 new: size=20709343,end=2097148

To extend the ext4 file system on the volume, we use the resize2fs command:

admin@srv:~$ sudo resize2fs /dev/nvme0n1p1
resize2fs 1.44.5 (15-Dec-2018)
Filesystem at /dev/nvme0n1p1 is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 2
The filesystem on /dev/nvme0n1p1 is now 2588667 (4k) blocks long

Let’s verify the file system of the volume:

admin@srv:~$ df -hT /dev/nvme0n1p1
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/nvme0n1p1 ext4  9.7G  7.9G  1.3G  87% /

That’s it…

Howto deploy a 2-Tier application in AWS

Recently, I wanted to move my applications from a tradional hosting service into AWS. The main services to be migrated are a webserver, an email server, and a database server. Both, webserver and email server connect to the backend database server with their various services (e.g. the webserver running Apache, and the mailserver running Exim).

In this article, I’ll give a detailed explanation how to setup such a solution.

All your base are belong to us.