DAY 3 - AWS EBS (Elastic Block Storage)
Amazon EBS Volume is basically a block based storage or the virtual hard disk to run your EC2 Instance.
It is a critical component of AWS Infrastructure.
EBS provides block-level storage, which means data is stored in fixed-size blocks which is used for running EC2 OS, store data from databases, file systems and other applications that require frequent reads/writes.
It is placed in specific availibility zone and automatically replicated within the availibility zone to protect from failure.
Your EBS Volume should be in the same zone where your instance is placed.
EBS Types
General Purpose (SSD) - Used for Most work loads
Provisioned IOPS - Used for Large Databases
Throughput Optimized HD - Used for Big Data and Data Warehouses
Cold HDD - Used for File Servers and are usually low cost
Magnetic - Used for Backup and archives and are usually very low cost and slowest one
Snapshot
Snapshot is one of the major feature that amazon EBS offers that is used to create backups for existing EBS Volume and restore it in the event of failures or deletion of some important data by mistake.
Snapshot can be also used for changing the Volume type, size and zone of an instance.
Hands on knowledge :-
There are three steps after creating a new EBS volume and attaching it to an instance.
Partitioning
Formatting
Mounting
Why they are necessary to do?
If you skip partitioning, the entire EBS volume will be treated as a single block of storage. This might be fine for some use cases, but it limits your flexibility in managing and organizing your data.
An unformatted partition cannot be used to store files. The operating system won't recognize it as usable storage, and any attempt to access it will result in errors.
After mounting, you can start using the storage for applications, databases, or as a directory to store data. The mount point acts as a gateway between the operating system and the EBS volume.
How to perform?
Some Linux commands for partition, format and mount :
fdisk -l
This command is going to list all your disks attached to your instance.
After finding our the new attached EBS Volume name.
fdisk /dev/xvdd
/dev/xvdd is just an example, it could be different in your case but the fdisk command will open a tab for partition or other options.
n - add a new partition
Look for this one and type n then it will ask you some questions about your partitioning and when you're done type w
.
For formatting :-
Type mkfs
then hit tab two times and it will show you available utilities
for example : mkfs.ext4, mkfs.xyf etc.
mkfs.ext4 /dev/xvdf1
- It means, I'm using extension 4 for formatting the volume.
For Temporary Mounting :-
mount /dev/xvdd1 /var/www/html/images
then check by using df -h
for unmounting : umount /var/www/html/images
For Permanent Mounting :-
vi /etc/fstab
then add entry for your disk consisting destination mounting place and other information.
mount -a
To mount every entries after adding in fstab file.
Subscribe to my newsletter
Read articles from Aaril Ansari directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by