Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

Creating and Managing Logical Volumes in SUSE Linux Enterprise

In this hands on lab, we will work with LVM in SUSE Linux Enterprise as we create a volume group and then extend that group to increase the available size of the logical volume.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Beginner
Duration
Clock icon 30m
Published
Clock icon Jan 10, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Create a Linux LVM Partition on Each of the Disks

    1. Get the drive names:

      lsblk
      
    2. Your output should match the below (the disks you'll be partitioning are nvme0n1, nvme1n1, and nvme2n1):

      NAME        MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
      nvme2n1     259:0    0   2G  0 disk
      nvme1n1     259:1    0   2G  0 disk
      nvme0n1     259:2    0   2G  0 disk
      nvme3n1     259:3    0  10G  0 disk
      ├─nvme3n1p1 259:4    0   2M  0 part
      ├─nvme3n1p2 259:5    0  20M  0 part /boot/efi
      └─nvme3n1p3 259:6    0  10G  0 part /
      
    3. Run fdisk against the first of the drives that has no partitions listed:

      sudo fdisk /dev/nvme0n1
      
      Enter n to create a new partition, 
      Then p for primary
      Then 1 for the partition number.
      Hit Enter for first and last sector since we will use the whole drive
      Enter p to see the partition. 
      
    4. Change the partition type label to Linux LVM:

      Enter t to set the label
      Then L to get a list of possible types
      Then 8e for Linux LVM
      The p to review the changes
      Then w to write the changes
      
    5. Have the kernel rescan the partition table, and then list partitions to verify:

      sudo partprobe
      lsblk
      
    6. Repeat this process for the other two disks.

    7. When finished with all three disks, run lsblk again to confirm the partitions are correct:

      NAME        MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
      nvme2n1     259:0    0   2G  0 disk
      └─nvme2n1p1 259:7    0   2G  0 part
      nvme1n1     259:1    0   2G  0 disk
      └─nvme1n1p1 259:11   0   2G  0 part
      nvme0n1     259:2    0   2G  0 disk
      └─nvme0n1p1 259:8    0   2G  0 part
      nvme3n1     259:3    0  10G  0 disk
      ├─nvme3n1p1 259:4    0   2M  0 part
      ├─nvme3n1p2 259:5    0  20M  0 part /boot/efi
      └─nvme3n1p3 259:6    0  10G  0 part /
      
  2. Challenge

    Create a Physical Volume and a Volume Group Named `VolumeGroup0`

    1. Create a physical volume on the first drive:

      sudo pvcreate /dev/nvme0n1p1
      
    2. Verify the physical volume was created:

      sudo pvdisplay
      
    3. Create the volume group:

      sudo vgcreate VolumeGroup0 /dev/nvme0n1p1
      
    4. Verify it was created:

      sudo vgdisplay
      
  3. Challenge

    Add the Second Disk to the Volume Group and Then Create a Logical Volume, Create an XFS Filesystem, and Mount It

    1. Extend the volume group to the second drive — this will create the necessary physical volume:

      sudo vgextend VolumeGroup0 /dev/nvme1n1p1
      
    2. Get the size, which should be 3.99 GiB:

      sudo vgdisplay
      
    3. Create the logical volume from the volume group:

      sudo lvcreate -L+3.99GB -n "backups" VolumeGroup0
      
    4. Create the filesystem on the volume:

      sudo mkfs.xfs /dev/VolumeGroup0/backups
      
    5. Create a mount point and mount the volume:

      sudo mkdir /mnt/backups
      sudo mount /dev/VolumeGroup0/backups /mnt/backups/
      
    6. Create a data file in the mount location:

      sudo touch /mnt/backups/data
      ls -l /mnt/backups
      
  4. Challenge

    Add the Third Disk to the Volume Group, Extend the Size of the Logical Volume, and Grow the Filesystem to Use the Added Space

    1. Add in the third drive to the volume group — this will also create the physical volume:

      sudo vgextend VolumeGroup0 /dev/nvme2n1p1
      
    2. Grow the logical volume by adding the size of the third disk:

      sudo lvextend -L+1.91GB /dev/VolumeGroup0/backups
      
    3. Then grow the filesystem to use the added space:

      sudo xfs_growfs /mnt/backups
      
    4. Verify data is still there and that the drive is the correct size:

      ls -l /mnt/backups
      df -hT 
      

      This should show 5.9G in the Size column for /dev/mapper/VolumeGroup0-backups.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

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.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans