How to: Adjust / Manipulate LVM disk in VIRL PE (bare-metal)

    applies to VIRL-CORE: all versions

    (not applicable to virtual machine deployments)

    Introduction

     

    In some instances, the VIRL PE bare-metal installation does not allocate the disk space efficiently. When this happens it is important to correct the partitions prior to using the system to ensure the disk does not become full unexpectedly. This guide will assist in adjusting the LVM partitions to ensure the root partition has as much of the available space as allowed. DO NOT use the steps shown here to adjust or change a VIRL PE virtual machine's virtual disk. For instructions on how to add more disk space on a VIRL PE virtual disk use this guide: How to: Extending the VIRL PE virtual disk


    Assumptions


    • VIRL PE has been deployed on a bare-metal system as per installation instructions where a LVM partition layout is created.

    and

    • The bare-metal system is running in a RAID configuration where additional space is available by extending the virtual disk.
    • Space has already been added to the virtual disk allocated to VIRL PE

    or

    • The bare-metal system is running in a JBOD (Just a Bunch Of Disks) and a new physical hard drive has been installed for the sole purpose of providing additional storage space to VIRL PE.

     

    Getting Started

     

    Adjust LVM Partition

    (no change in virtual disk size)

     

    In this example we will adjust an oversized swap partition and give the additional space to the root partition. The current Swap space in this example is too large to be of any real benefit to the system and is taking away usable storage space. We will reduce swap from 125 GB to 25 GB and give the newly freed space to the root partition. When complete, the root partition will be 200 GB and swap will be 25 GB in size.

     

    LVM Partition Information

    Partition NameAllocated Space
    SWAP125 GB
    Root100 GB

     

    1. Connect to VIRL PE via console or SSH (recommended). Keep in mind that all commands are case sensitive.
    2. Once you are logged in change to elevated user (root)
      • sudo su
    3. Verify available space seen by the operating system
      • df -h
    4. Collect Logical Volume (LV) name and size information
      • lvs
    5. Turn off swap partition (device name may differ on your system)
      • swapoff -v /dev/ubuntu-vg/swap_1
    6. Reduce the swap partition size by 100GB
      • lvm lvreduce /dev/ubuntu-vg/swap_1 -L -100G
    7. Enable swap partition
      • mkswap /dev/ubuntu-vg/swap_1
    8. Turn swap partition on
      • swapon /dev/ubuntu-vg.swap_1
    9. Extend LV root to use newly created empty space
      • lvextend -l100%FREE /dev/mapper/ubuntu--vg-root
      • resize2fs /dev/mapper/ubuntu--vg-root
    10. Confirm new partition size
      • lvdisplay (detailed Logical Volume information)
      • lvs

     

    Your system is now ready for use and UWM should report the new root partition size. If UWM is not reporting the correct available space but the last two commands do report correctly, refresh the browser or CLEANLY reboot your VIRL PE server. To cleanly reboot the server run sudo reboot now  via CLI.