Bookmark this page

Lab: Manage Storage Stack

In this lab, you 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

  • Resize the serverb_01_lv logical volume to 768 MiB.

  • Create the serverb_02_lv logical volume with 128 MiB with an XFS file system.

  • Persistently mount the volume on the /storage/data2 directory.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise.

This command prepares your environment and ensures that all required resources are available.

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

Instructions

On the serverb machine, the serverb_01_lv logical volume that is mounted on the /storage/data1 directory is running out of disk space, and must be extended to 768 MiB. You must ensure that the serverb_01_lv LV remains persistently mounted on the /storage/data1 directory.

The serverb_01_lv LV is present on the serverb_01_vg volume group. It has insufficient space to extend the existing logical volume. A 512 MiB partition exists on the /dev/vdb disk. Create a partition with the 512 MiB size on the /dev/vdb disk.

Important

Note especially the specification of the partition size in MiB (220 bytes). If you create the partition in MB (106 bytes), it does not satisfy the evaluation criteria, because 1 MiB = 1.048576 MB.

Although the default unit when using the parted /dev/vdb print command is MB, you can verify the size of the /dev/vdb device partitions in MiB units. Use the parted /dev/vdb unit MiB print command to print the partition sizes in MiB.

Create the serverb_02_lv LV with 128 MiB. Create the XFS file system on the newly created volume. Mount the newly created logical volume on the /storage/data2 directory.

  1. Create a 512 MiB partition on the /dev/vdb disk. Initialize this partition as a physical volume, and extend the serverb_01_vg volume group to use this partition.

    1. Log in to the serverb machine as the student user and switch to the root user.

      [student@workstation ~]$ ssh student@serverb
      ...output omitted...
      [student@serverb ~]$ sudo -i
      [sudo] password for student: student
      [root@serverb ~]#
    2. Print the partition sizes in MiB to determine where the first partition ends.

      [root@serverb ~]# parted /dev/vdb unit MiB print
      ...output omitted...
      
      Number  Start    End     Size    File system  Name     Flags
       1      1.00MiB  513MiB  512MiB               primary
    3. Create the 512 MiB partition and set the lvm partition type.

      [root@serverb ~]# parted /dev/vdb mkpart primary 514MiB 1026MiB
      ...output omitted...
      [root@serverb ~]# parted /dev/vdb set 2 lvm on
    4. Register the new partition with the kernel.

      [root@serverb ~]# udevadm settle
    5. Initialize the partition as a PV.

      [root@serverb ~]# pvcreate /dev/vdb2
        Physical volume "/dev/vdb2" successfully created.
    6. Extend the serverb_01_vg VG by 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.

    1. Extend the serverb_01_lv LV to 768 MiB.

      Alternatively, you can also use the lvcreate command -L +512M option to resize the LV.

      [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.
    2. Extend the XFS file system to consume the remaining 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...
      data blocks changed from 65536 to 196608

      Note

      The xfs_growfs command introduces an extra step to extend the file system. An alternative would be to use the lvextend command -r option.

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

    1. Create the serverb_02_lv LV with 128 MiB 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. Create the xfs file system on the serverb_02_lv LV.

      [root@serverb ~]# mkfs -t xfs /dev/serverb_01_vg/serverb_02_lv
      ...output omitted...
    3. Create the /storage/data2 directory as the mount point.

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

      /dev/serverb_01_vg/serverb_02_lv /storage/data2 xfs defaults 0 0
    5. Update the systemd daemon with the new /etc/fstab configuration file.

      [root@serverb ~]# systemctl daemon-reload
    6. Mount the serverb_02_lv LV.

      [root@serverb ~]# mount /storage/data2
  4. Verify that the newly created LV is mounted with the intended size.

    1. Use the df command to verify the serverb_01_lv LV size.

      [root@serverb ~]# df -h /storage/data1
      Filesystem                               Size  Used Avail Use% Mounted on
      /dev/mapper/serverb_01_vg-serverb_01_lv  763M   19M  744M   3% /storage/data1
    2. Verify the serverb_02_lv LV size.

      [root@serverb ~]# df -h /storage/data2
      Filesystem                               Size  Used Avail Use% Mounted on
      /dev/mapper/serverb_01_vg-serverb_02_lv  123M  7.6M  116M   7% /storage/data2
    3. Verify the serverb_01_lv LV details.

      [root@serverb ~]# lvdisplay /dev/serverb_01_vg/serverb_01_lv
        --- Logical volume ---
        LV Path                /dev/serverb_01_vg/serverb_01_lv
        LV Name                serverb_01_lv
        VG Name                serverb_01_vg
        LV UUID                1pY3DZ-fs1F-mptC-fL32-e8tG-PFBT-bs7LSJ
        LV Write Access        read/write
        LV Creation host, time serverb.lab.example.com, 2022-05-05 14:40:51 -0400
        LV Status              available
        # open                 1
        LV Size                768.00 MiB
        Current LE             192
        Segments               2
        Allocation             inherit
        Read ahead sectors     auto
        - currently set to     8192
        Block device           253:0
    4. Verify the serverb_02_lv LV details.

      [root@serverb ~]# lvdisplay /dev/serverb_01_vg/serverb_02_lv
        --- Logical volume ---
        LV Path                /dev/serverb_01_vg/serverb_02_lv
        LV Name                serverb_02_lv
        VG Name                serverb_01_vg
        LV UUID                0aJIb6-Ti2b-jLCk-imB6-rkLx-mUoX-acjkz9
        LV Write Access        read/write
        LV Creation host, time serverb.lab.example.com, 2022-05-05 14:45:46 -0400
        LV Status              available
        # open                 1
        LV Size                128.00 MiB
        Current LE             32
        Segments               1
        Allocation             inherit
        Read ahead sectors     auto
        - currently set to     8192
        Block device           253:1

Evaluation

As the student user on the workstation machine, use the lab command to grade your work. Correct any reported failures and rerun the command until successful.

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

Finish

On the workstation machine, change to the student user home directory and use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

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

This concludes the section.

Revision: rh199-9.0-4fecb06