top of page

Oracle Linux Basic Administration Series - Part 9 - How to Manage Logical Volume Management (LVM) in Oracle Linux

  • Jason Beattie
  • 19 hours ago
  • 2 min read


Logical Volume Management (LVM) gives you flexibility and control over disk storage.Instead of being locked into fixed partitions, LVM lets you resize, extend, or combine storage dynamically which is perfect for growing environments or virtualized systems.


In this blog, you’ll learn how to:

  • Create physical volumes (PVs)

  • Combine them into volume groups (VGs)

  • Create and extend logical volumes (LVs)

  • Format, mount, and resize LVs



Step 1: Check Available Disks

Before setting up LVM, list your disks:

lsblk
ree

We’ll use /dev/sdb for this example.

⚙️ Step 2: Create a Partition for LVM

Use fdisk to create an LVM partition:

sudo fdisk /dev/sdb
ree

Verify:

sudo fdisk -l /dev/sdb

You should see Linux LVM under type.

🧱 Step 3: Create a Physical Volume (PV)

Initialize the new partition for LVM:

sudo pvcreate /dev/sdb1
ree

Verify:

sudo pvs
ree

Step 4: Create a Volume Group (VG)

Create a volume group named vgdata:

sudo vgcreate vgdata /dev/sdb1

Verify:

sudo vgs

ree


Step 5: Create a Logical Volume (LV)

Create a logical volume named lvdata with 10 GB space:

sudo lvcreate -L 10G -n lvdata vgdata
ree

sudo lvs

ree


Step 6: Format the Logical Volume

Format it with a file system (XFS recommended):

sudo mkfs.xfs /dev/vgdata/lvdata
ree

sudo mkfs.ext4 /dev/vgdata/lvdata

Step 7: Mount the Logical Volume

Create a mount point:

sudo mkdir /data
ree

sudo mount /dev/vgdata/lvdata /data

Check:

df -h | grep /data

ree


Step 8: Make the Mount Persistent

Find the LV’s UUID:

sudo blkid /dev/vgdata/lvdata
ree

Add it to /etc/fstab:

sudo vi /etc/fstab
ree

sudo mount -a

Step 9: Extend a Logical Volume

If you need more space, you can extend both the LV and the file system.


Step 1: Extend the LV by 5G:

sudo lvextend -L +5G /dev/vgdata/lvdata

Step 2: Resize the file system:

For XFS:

sudo xfs_growfs /data

For EXT4:

sudo resize2fs /dev/vgdata/lvdata

Verify:

df -h /data

The size should increase.



Step 10: Add Another Disk to a Volume Group


If you add another disk (say /dev/sdc1), add it to the VG:

sudo pvcreate /dev/sdc1
sudo vgextend vgdata /dev/sdc1

Then extend your LV as needed — you now have a storage pool that can grow dynamically.


Conclusion


You’ve now mastered LVM (Logical Volume Management) in Oracle Linux. This is a tool for managing and scaling storage efficiently. With LVM, you can easily expand your storage, migrate volumes, and allocate space dynamically without downtime.

In the next post, we’ll move into scheduling tasks, learning how to automate jobs using cron and systemd timers.

 
 
 

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
Post: Blog2 Post
  • LinkedIn

©2023 Proudly created with Wix.com

bottom of page