-
Launch an EC2 instance in your preferred AWS region.
-
Create an Amazon EBS volume with the desired size and type (SSD or HDD) in the same availability zone as your EC2 instance.
-
Attach the newly created EBS volume to your EC2 instance.
-
Verify that the volume is successfully attached and visible to the instance.
# List block devices
lsblk
# Check file system type of the attached volume
sudo file -s /dev/xvdf
# Format the EBS volume with XFS file system
sudo mkfs -t xfs /dev/xvdf
# Check file system type again after formatting
sudo file -s /dev/xvdf
# Create a directory to mount the EBS volume
sudo mkdir /testebs
# List root directory contents
ls /
# Mount the EBS volume to the created directory
sudo mount /dev/xvdf /testebs
# Display disk space usage
df -k
# View UUID for the mounted volume
sudo blkid
# Edit /etc/fstab to automatically mount the EBS volume on boot
sudo vi /etc/fstab
# Additional commands for demonstration
sudo /ebsdemo
sudo vi file1
cd ..
# Unmount the volume
sudo umount /ebsdemo
# Check disk space after unmounting
df -k
# List block devices
lsblk