Bookmark this page

Lab: Managing Logical Volumes

Performance Checklist

In this lab, you will resize an existing logical volume, add LVM resources as necessary, and then add a new logical volume with a persistently mounted XFS file system on it.

Outcomes

You should be able to:

  • Resize the serverb_01_lv logical volume to 768 MiB.

  • Create a new 128 MiB logical volume called serverb_02_lv with an XFS file system, persistently mounted at /storage/data2.

Log in to workstation as student using student as the password.

On workstation, run the lab lvm-review start command. This command runs a start script that determines if the serverb machine is reachable on the network. It also prepares the storage on serverb for the exercise.

[student@workstation ~]$ lab lvm-review start

On serverb, a logical volume called serverb_01_lv mounted at /storage/data1 is running out of disk space, and you have been asked to extend it to 768 MiB in size. You must ensure that serverb_01_lv remains persistently mounted on /storage/data1.

You have also been asked to create a new 128 MiB logical volume called serverb_02_lv, mounted on /storage/data2. You have been instructed to format the new logical volume with the XFS file system.

The serverb_01_vg volume group holds the logical volumes. Unfortunately, it has insufficient space to extend the existing logical volume and add the new one. A 512 MiB partition was created previously on /dev/vdb. You have been instructed to use a further 512 MiB on /dev/vdb. You must create the new partition.

  1. Create a 512 MiB partition on /dev/vdb, initialize it as a physical volume, and extend the serverb_01_vg volume group with it.

    1. Log in to serverb as the student user.

      [student@workstation ~]$ ssh student@serverb
      ...output omitted...
      [student@serverb ~]$ 
    2. Use the sudo -i command to switch to the root user. The password for the student user is student.

      [student@serverb ~]$ sudo -i
      [sudo] password for student: student
      [root@serverb ~]# 
    3. Use parted to create the 512 MiB partition and set it to type Linux LVM.

      [root@serverb ~]# parted -s /dev/vdb mkpart primary 514MiB 1026MiB
      [root@serverb ~]# parted -s /dev/vdb set 2 lvm on
    4. Use udevadm settle for the system to register the new partition.

      [root@servera ~]# udevadm settle
    5. Use pvcreate to initialize the partition as a PV.

      [root@serverb ~]# pvcreate /dev/vdb2
        Physical volume "/dev/vdb2" successfully created.
    6. Use vgextend to extend the VG named serverb_01_vg, using the new /dev/vdb2 PV.

      [root@serverb ~]# vgextend serverb_01_vg /dev/vdb2
        Volume group "serverb_01_vg" successfully extended
  2. Extend the serverb_01_lv logical volume to 768 MiB, including the file system.

    1. Use lvextend to extend the serverb_01_lv LV to 768 MiB.

      [root@serverb ~]# lvextend -L 768M /dev/serverb_01_vg/serverb_01_lv
        Size of logical volume serverb_01_vg/serverb_01_lv changed from 256.00 MiB (64 extents) to 768.00 MiB (192 extents).
        Logical volume serverb_01_vg/serverb_01_lv successfully resized.

      Note

      Alternatively, you could have used the -L +512M option to resize the LV.

    2. Use xfs_growfs to extend the XFS file system to the remainder of the free space on the LV.

      [root@serverb ~]# xfs_growfs /storage/data1
      meta-data=/dev/mapper/serverb_01_vg-serverb_01_lv isize=512    agcount=4, agsize=16384 blks
      ...output omitted...

      Note

      This example shows the xfs_growfs step to extend the file system. An alternative would have been to add the -r option to the lvextend command.

  3. In the existing volume group, create a new logical volume called serverb_02_lv with a size of 128 MiB. Add an XFS file system and mount it persistently on /storage/data2.

    1. Use lvcreate to create a 128 MiB LV named serverb_02_lv from the serverb_01_vg VG.

      [root@serverb ~]# lvcreate -n serverb_02_lv -L 128M serverb_01_vg
        Logical volume "serverb_02_lv" created
    2. Use mkfs to place an xfs file system on the serverb_02_lv LV. Use the LV device name.

      [root@serverb ~]# mkfs -t xfs /dev/serverb_01_vg/serverb_02_lv
      meta-data=/dev/serverb_01_vg/serverb_02_lv isize=512    agcount=4, agsize=8192 blks
      ...output omitted...
    3. Use mkdir to create a mount point at /storage/data2.

      [root@serverb ~]# mkdir /storage/data2
    4. Add the following line to the end of /etc/fstab on serverb:

      /dev/serverb_01_vg/serverb_02_lv  /storage/data2  xfs  defaults  1 2
    5. Use systemctl daemon-reload to update systemd with the new /etc/fstab configuration.

      [root@servera ~]# systemctl daemon-reload
    6. Use mount to verify the /etc/fstab entry and mount the new serverb_02_lv LV device.

      [root@serverb ~]# mount /storage/data2
  4. When you are done, reboot your serverb machine, then run the command lab lvm-review grade from your workstation machine to verify your work.

    Wait until serverb is completely up and then proceed to run the evaluation.

    [root@serverb ~]# systemctl reboot

Evaluation

On workstation, run the lab lvm-review grade script to confirm success on this exercise.

[student@workstation ~]$ lab lvm-review grade

Finish

On workstation, run the lab lvm-review finish script to complete the lab.

[student@workstation ~]$ lab lvm-review finish

This concludes the lab.

Revision: rh134-8.2-f0a9756