Tagged: aws-ec2

Extend AWS EBS volumes after extending current volume in EC2 instance with no downtime

Problem: well there is a guide from AWS official website but I want to make a simplified version.

This post mainly takes this website as a reference, I saw the website have some indentation problem so I make a refined version here.

Solution: we mainly using “lsblk” and “growpart” command to extend drive storage.

First, after extending current volume in EC2 instance, enter “lsblk” to get block devices information:

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 20G 0 disk
└─xvda1 202:1 0 8G 0 part /

You can see the original file system size is 8G, and we extend the space from 8G to 20G. But the 12G new, fresh storage still hasn’t applied to the current system.

Second, using “growpart” to extend a partition in a partition table,  we know that the current system file partition is xvda1 so enter below command:

sudo growpart /dev/xvda 1

now check again with “lsblk”

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 20G 0 disk
└─xvda1 202:1 0 20G 0 part /

Although the partition now reflects the increased volume size, last we need to extend the filesystem itself. If your filesystem is an ext2, ext3, or ext4, type:

sudo resize2fs /dev/xvda1

If your filesystem is an XFS, then type:

sudo xfs_growfs /dev/xvda1

Error “mount: unknown filesystem type ‘(null)'” occurred in CentOS 7 AWS

Problem: Attach a volume to AWS EC2 instance, after enter a command for mount drive:

sudo mount /dev/xxxx /xxx

An error occurred:

mount: /dev/xxxx is write-protected, mounting read-only mount: unknown filesystem type ‘(null)’

Solution: the volume is unformatted and you should format it first. Enter below command to format volume to ext4 file system :

sudo mkfs.ext4 /dev/xxxx

Then mount again:

sudo mount /dev/xxxx /xxx

By the way, you can use lsblk command to retrieve hard disk partitions and disk space information.