Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Lab: Disk Partitioning, Formatting, and Logical

Volume Management (LVM) on AlmaLinux


Introduction

This lab guides you through the processes of disk partitioning, formatting, and exploring Logical
Volume Management (LVM) on your AlmaLinux system.

Learning Objectives

● Understand the essentials of partitioning and formatting a disk.


● Learn how to make filesystem mounts permanent.
● Grasp the concepts of Volume Groups (VGs) and Logical Volumes (LVs) in LVM.

Equipment

● AlmaLinux machine with four hard drives:


○ One containing the operating system
○ One unpartitioned and unformatted for partitioning and formatting practice
○ Two additional unallocated disks for LVM exercises

Part 1: Disk Partitioning, Formatting, and Permanent Mounting

1. Identify the Unpartitioned Disk:


Bash
sudo fdisk -l

Look for the disk without listed partitions (e.g., /dev/sdb).


2. Create a Partition:
Bash
sudo fdisk /dev/sdb

Inside fdisk:
○ n to create a new partition (typically use default type and size)
○ w to write the changes
3. Format the Partition:
Bash
sudo mkfs.ext4 /dev/sdb1 # Assuming your partition is /dev/sdb1

Mount /dev/sdb1 /mnt/mydata

4. Obtain the Partition's UUID:


Bash
sudo blkid /dev/sdb1

Copy the UUID value.


5. Edit /etc/fstab:
Bash
sudo nano /etc/fstab

Add a line like this:


UUID=<UUID> /mnt/mydata ext4 defaults 0 0

○ Replace <UUID> with the copied UUID.


○ Choose a suitable mount point (e.g., /mnt/mydata).
6. Save and Test Mount:
○ Save /etc/fstab (Ctrl+O, then Ctrl+X in nano).
○ Mount the partition:
Bash
sudo mount -a

Part 2: Volume Groups and Logical Volumes with LVM

1. Create Physical Volumes (PVs):


Bash
sudo pvcreate /dev/sdc /dev/sdd # Use your unallocated disk names

2. Create a Volume Group (VG):


Bash
sudo vgcreate myvg /dev/sdc /dev/sdd

3. Create Logical Volumes (LVs):


Bash
sudo lvcreate -L 500M -n data_lv myvg
sudo lvcreate -l +80%FREE -n work_lv myvg
4. Format and Mount LVs:
Bash
sudo mkfs.ext4 /dev/myvg/data_lv
sudo mkdir /mnt/data
sudo mount /dev/myvg/data_lv /mnt/data

Repeat for other LVs, adjusting mount points.


5. Make LVM Mounts Permanent:
○ Edit /etc/fstab as in Part 1, using LV paths (e.g., /dev/myvg/data_lv) instead of partition
paths.

Conclusion

You've now practiced the fundamentals of disk management on AlmaLinux, including


partitioning, formatting, permanent mounting, and LVM.

Further Exploration

● Explore fdisk options in its manual (man fdisk).


● Learn about resizing LVs with lvextend and lvreduce.

You might also like