Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Working with Logical Volume Management

Effective storage management is a constant challenge in any enterprise environment. The ability to react quickly to increasing storage needs without disrupting the current configuration is key. In this activity, we will set up Logical Volume Manager (LVM) storage utilities to address this challenge. We will partition a disk for use with LVM, and then create Physical Volumes, Volume Groups, and Logical Volumes. We will also delete a Logical Volume, and extend a Volume Group to be able to provide additional space in a Logical Volume. Learning how to use the flexibility of LVM makes us more effective at storage management.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Intermediate
Last updated
Jul 01, 2025
Duration
30m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Create Linux LVM Type Partitions on /dev/xvdb and /dev/xvdc to Use All Space

    Start an interactive root shell with sudo. Use fdisk to create a new default partition of type 8e on /dev/xvdb and /dev/xvdc. Create the first:

    sudo -i
    fdisk /dev/xvdb
    

    Use the n command and choose all the defaults to create a new partition:

    Command (m for help): n
    Partition Type: p
    Partition number (1-4, default 1): Press Enter to accept the default
    First sector: Press Enter to accept the default
    Last sector: Press Enter to accept the default
    

    Use the t command to change to 8e (Linux LVM):

    Command (m for help): t
    Selected partition 1
    Hex code (type L to list all codes): 8e
    Changed type of partition 'Linux' to 'Linux LVM'
    

    Use the w command to write the changes to the partition table and exit:

    Command (m for help): w
    

    Now create the second:

    fdisk /dev/xvdc
    

    Use the n command and choose all the defaults to create a new partition:

    Command (m for help): n
    Partition Type: p
    Partition number (1-4, default 1): Press Enter to accept the default
    First sector: Press Enter to accept the default
    Last sector: Press Enter to accept the default
    

    Use the t command to change to 8e (Linux LVM):

    Command (m for help): t
    Selected partition 1
    Hex code (type L to list all codes): 8e
    Changed type of partition 'Linux' to 'Linux LVM'
    

    Use the w command to write the changes to the partition table and exit.

    The result is that the /dev/xvdb1 and /dev/xvdc1 partitions of type 8e have been created.

  2. Challenge

    Create Physical Volumes with the LVM Partitions /dev/xvdb1 and /dev/xvdc1, and Create the Volume Group volgroup Using /dev/xvdb1

    Initialize the /dev/xvdb1 and /dev/xvdc1 LVM partitions as Physical Volumes with pvcreate. Inspect the Physical Volumes with pvs and pvdisplay:

    pvcreate /dev/xvdb1 /dev/xvdc1
    pvs
    pvdisplay
    

    Use vgcreate to create the volgroup Volume Group using the /dev/xvdb1 Physical Volume. Inspect volgroup with vgs and vgdisplay:

    vgcreate volgroup /dev/xvdb1
    vgs
    vgdisplay
    
  3. Challenge

    Create the Logical Volume datavol Using 3GB of Space and tempvol Using 1GB of Space

    Use the lvcreate command to create two Logical Volumes, a 3 GB named datavol and a 1 GB named tempvol. Inspect them using lvs and lvdisplay commands:

    lvcreate -n datavol -L3G volgroup
    lvcreate -n tempvol -L1G volgroup
    lvs
    lvdisplay
    
  4. Challenge

    Remove /dev/volgroup/tempvol, Extend volgroup with /dev/xvdc1, and Then Resize /dev/volgroup/datavol to Use All Space in the Volume Group

    Use lvremove to get rid of the tempvol, then run vgextend to expand the volume group. Create an ext4 filesystem on /dev/volgroup/datavol and mount it on /mnt/data. Use lvresize to extend the datavol Logical Volume and filesystem to the maximum size possible. Check everything afterward using the df and vgs commands:

    lvremove /dev/volgroup/tempvol
    Type 'y' and Enter to confirm 
    vgs
    vgextend volgroup /dev/xvdc1
    vgs
    vgdisplay
    mkfs -t ext4 /dev/volgroup/datavol
    mkdir /mnt/data
    mount  /dev/volgroup/datavol /mnt/data
    df -h /mnt/data
    lvresize -r -L 9.99G /dev/volgroup/datavol
    df -h
    
  5. Challenge

    Configure the /dev/volgroup/datavol Logical Volume to Mount on /mnt/data Persistently

    Unmount the /mnt/data directory with the umount command:

    umount /mnt/data
    

    Add the following line to /etc/fstab:

    /dev/volgroup/datavol /mnt/data ext4 defaults 0 1
    

    Use an editor like vim to add the line to the file:

    vim /etc/fstab
    

    Mount the device with the mount command. Use df to verify it mounted:

    mount -a
    df -h /mnt/data
    
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight