Linux Volumes: A Comprehensive Guide for DevOps Engineer

🟡Introduction to Linux Volumes and AWS & EBS
in simple term :-
Linux Volume: Think of it as an extra storage unit that you can add to your Linux server when needed. You can mount, unmount, resize, or move it dynamically without affecting the entire system.
AWS EBS (Elastic Block Store): It’s like an external SSD that provides persistent storage for AWS EC2 instances. You can attach it when you need extra space and detach it when not in use, just like plugging in and removing an external SSD from your computer.
How to Create an EC2 Instance – Learn to set up a virtual machine in AWS.
How to Create and Attach an EBS Volume – Understand how to add extra storage to your EC2 instance.
🟡Physical vs Logical Volumes vs Volume Groups in Linux
Physical Volumes (PVs): The actual storage device or disk (like a hard drive, SSD, or EBS volume).
Volume Groups (VGs):A collection of physical volumes combined into one storage pool.
Logical Volumes (LVs): A flexible, customizable storage space created from the volume group, which you can resize as needed.
For example(LV), you have a 512GB hard drive and divide it into:
C: Drive (312GB) for the operating system
D: Drive (200GB) for personal files
Logical Volume Management (LVM) enables flexible disk space allocation, making it easier to manage storage efficiently.
Here’s how you can practically understand Physical Volume, Volume Group, and Logical Volume using commands in Linux:
what you need before practical:-
first, you need to create an EC2 on AWS
and then create 3 EBS on AWS(you can take reference from the above link)(I create 3 EBC 10GB , 12 GB , 14 GB)
then install lvm using this command:-
sudo apt install lvm2 # ony for Ubuntu/Dabian
Let’s do practical:-
1.For Physical Volume
- after attaching EBS to your EC2 run this command
lsblk
output:-
now it’s attached with EC2 but not mounted with it
DIff between attach and mount:-
Attach: Connects storage to the system. (Like plugging in a USB drive)
Mount: Makes storage usable by the OS. (Like opening the USB drive to access files)
write command:-
lvm
Then create a physical volume
pvcreate /dev/xvdf /dev/xvdg /dev/xvdh pvc #show details of pv
use this command to show more details about it
pvdisplay
2.For Logical group:-
- Let’s create a Logical group
vgcreate first_vg /dev/xvdf /dev/xvdg
vgdisplay #use this command for detailed information about a specific Volume Group.
vgs #shows a summary of all Volume Groups
3.For Logical volume:-
Create Logical volume from logical group
lvcreate -L 10G -n first_lv first_vg lvdisplay # shows all details about lv lvs #shows a summary of all lvs
Let’s understand what we have done till now using the diagram:-
🟡Mounting Volumes in Linux
To mount the volume you need to create a directory
mkdir /mnt/first_lv_mount
then you need to format your lv
mkfs.ext4 /dev/first_vg/first_lg
then mount it
mount /dev/first_vg/first_lg /mnt/first_ls_mount
how to unmount volume
umount /mnt/first_ls_mount
🟡Using LVM with EBS for dynamic storage management
create directory
mkdir /mnt/second_disk_mount
Then format your volume
mkfs -t ext4 /dev/xvdh
let’s mount them
mount /dev/xvdh /mnt/second_disk_mount
let’s extend 5GB in the lv (using lvm with EBS for dynamic storage management)
lvm #inside lvm lvextend -L +5G /dev/first_vg/first_lv
Conclusion
Understanding Linux volumes and AWS EBS is essential for effective storage management. Using LVM with EBS offers flexibility and scalability, ensuring optimal performance for cloud and on-premises environments.
Subscribe to my newsletter
Read articles from Nenis Rudani directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Nenis Rudani
Nenis Rudani
🌟 Hello , I am Nenis Rudani, a passionate tech enthusiast carving my path as a DevOps maven and cloud sorcerer. My journey blends curiosity, innovation, and an insatiable appetite for building scalable systems and automating the mundane.