🌟 Volume Management in Linux & AWS EBS πŸ’½

🌟 Volume Management in Linux & AWS EBS πŸ’½

🌟 Volume Management in Linux & AWS EBS πŸ’½

ABHISHEK

Β·Dec 30, 2024Β·

3 min read

Volumes in Linux and AWS Elastic Block Store (EBS) are essential for managing storage. Let’s explore how to create, manage, and mount volumes step-by-step.


πŸ—οΈ Introduction to Linux Volumes and AWS EBS


πŸ› οΈ Creating and Attaching Volumes

Steps to Create Volumes in AWS EBS

  1. Go to AWS Management Console and navigate to EC2.

  2. Select "Elastic Block Store" under storage.

  3. Create three volumes: ( For Example )

Note: Your Instance volume already show in Dashboard.

  1. Set volume size and choose the same availability zone as your instance.

  2. Click "Create Volume".

Note: Snapshot ID is optional unless restoring from a backup.

Attaching Volumes to an Instance

  1. Go to the "Volumes" section and select the volume ID.

  2. Click on "Actions" > "Attach Volume".

  3. Choose the instance and specify the device name (e.g., /dev/sdf).

  4. Repeat for other volumes, using /dev/sdg and /dev/sdh for the second and third volumes.

Verify Attachment:


πŸ”„ Physical vs. Logical Volumes & Volume Groups

Physical Volume (PV)

Volume Groups (VG)

Logical Volume (LV)


πŸ“Š Using LVM (Logical Volume Manager)

Creating Physical Volumes

lvm> pvcreate /dev/xvdf /dev/xvdg /dev/xvdh

lvm> pvs

Detailed info on physical volumes

lvm> pvdisplay

Creating Volume Groups

lvm> vgcreate <group_name>_vg /dev/xvdf /dev/xvdg

lvm> vgs ( List volume groups )

lvm> vgdisplay ( Detailed info on volume groups )

Creating Logical Volumes

lvm> lvcreate -L 10G -n <logical_volume_name>_lv <volume_group_name>_vg

lvm> lvdisplay ( Detailed info on logical volumes )


πŸ“‚ Mounting Volumes

Steps to Mount Volumes

  1. Create a directory for mounting:

    mkdir /mnt/<logical_volume_name>_mount

  2. Format the volume:

    mkfs.ext4 /dev/<volume_group_name>/<logical_volume_name>

  3. Mount the volume:

    mount /dev/<volume_group_name>/<logical_volume_name> /mnt/<logical_volume_name>_mount

  4. Verify Mounting:

    Run lsblk and df -h to check mounted volumes.

Unmounting Volumes:

umount /mnt/<logical_volume_name>_mount


🌟 AWS EBS Management on EC2 Instances

Format and Mount EBS Volume

  1. Create a directory: mkdir /mnt/<volume_name>

  2. Format the disk: mkfs -t ext4 /dev/xvdh

  3. Mount the disk: mount /dev/xvdh /mnt/<disk_name>

  4. Verify with: df -h


πŸ“ˆ Dynamic Storage Management with LVM

Extending Logical Volumes

lvm> lvextend -L +5G -n <logical_volume_name> <volume_group_name>

Resizing Filesystem

Sometimes errors occur. To fix:

lvm> lvresize -L +5G /dev/<volume_group_path>/<logical_volume_name>

Verification

  • Use df -h and lsblk to confirm changes.


⚑ Difference Between Volume Attach and Volume Mount


πŸŽ‰ Conclusion

Managing volumes using Linux and AWS EBS is crucial for storage efficiency. From creating and attaching to logical grouping and dynamic resizing, mastering these steps empowers you to handle data with ease. Start exploring volume management today!

Β