- Lab
- A Cloud Guru
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.
Path Info
Table of Contents
-
Challenge
Create a Linux LVM Partition on Each of the Disks
-
Get the drive names:
lsblk
-
Your output should match the below (the disks you'll be partitioning are
nvme0n1
,nvme1n1
, andnvme2n1
):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 /
-
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.
-
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
-
Have the kernel rescan the partition table, and then list partitions to verify:
sudo partprobe lsblk
-
Repeat this process for the other two disks.
-
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 /
-
-
Challenge
Create a Physical Volume and a Volume Group Named `VolumeGroup0`
-
Create a physical volume on the first drive:
sudo pvcreate /dev/nvme0n1p1
-
Verify the physical volume was created:
sudo pvdisplay
-
Create the volume group:
sudo vgcreate VolumeGroup0 /dev/nvme0n1p1
-
Verify it was created:
sudo vgdisplay
-
-
Challenge
Add the Second Disk to the Volume Group and Then Create a Logical Volume, Create an XFS Filesystem, and Mount It
-
Extend the volume group to the second drive — this will create the necessary physical volume:
sudo vgextend VolumeGroup0 /dev/nvme1n1p1
-
Get the size, which should be 3.99 GiB:
sudo vgdisplay
-
Create the logical volume from the volume group:
sudo lvcreate -L+3.99GB -n "backups" VolumeGroup0
-
Create the filesystem on the volume:
sudo mkfs.xfs /dev/VolumeGroup0/backups
-
Create a mount point and mount the volume:
sudo mkdir /mnt/backups sudo mount /dev/VolumeGroup0/backups /mnt/backups/
-
Create a
data
file in the mount location:sudo touch /mnt/backups/data ls -l /mnt/backups
-
-
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
-
Add in the third drive to the volume group — this will also create the physical volume:
sudo vgextend VolumeGroup0 /dev/nvme2n1p1
-
Grow the logical volume by adding the size of the third disk:
sudo lvextend -L+1.91GB /dev/VolumeGroup0/backups
-
Then grow the filesystem to use the added space:
sudo xfs_growfs /mnt/backups
-
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 theSize
column for/dev/mapper/VolumeGroup0-backups
.
-
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.