Chapter 2. Managing LVM physical volumes


A physical volume (PV) is a physical storage device or a partition on a storage device that LVM uses.

During the initialization process, an LVM disk label and metadata are written to the device, which allows LVM to track and manage it as part of the logical volume management scheme.

Note

You cannot increase the size of the metadata after the initialization. If you need larger metadata, you must set the appropriate size during the initialization process.

When initialization process is complete, you can allocate the PV to a volume group (VG). You can divide this VG into logical volumes (LVs), which are the virtual block devices that operating systems and applications can use for storage.

To ensure optimal performance, partition the whole disk as a single PV for LVM use.

2.1. Creating an LVM physical volume

You can use the pvcreate command to initialize a physical volume LVM usage.

Prerequisites

  • Administrative access.
  • The lvm2 package is installed.

Procedure

  1. Identify the storage device you want to use as a physical volume. To list all available storage devices, use:

    $ lsblk
    Copy to Clipboard Toggle word wrap
  2. Create an LVM physical volume:

    # pvcreate /dev/sdb
    Copy to Clipboard Toggle word wrap

    Replace /dev/sdb with the name of the device you want to initialize as a physical volume.

Verification

  • Display the created physical volume:

    # pvs
    
      PV         VG  Fmt  Attr PSize  PFree
      /dev/sdb       lvm2 a--  28.87g 13.87g
    Copy to Clipboard Toggle word wrap

With the storage system role, you can resize LVM physical volumes after resizing the underlying storage or disks from outside of the host. For example, you increased the size of a virtual disk and want to use the extra space in an existing LVM.

Prerequisites

  • You have prepared the control node and the managed nodes.
  • You are logged in to the control node as a user who can run playbooks on the managed nodes.
  • The account you use to connect to the managed nodes has sudo permissions on them.
  • The size of the underlying block storage has been changed.

Procedure

  1. Create a playbook file, for example, ~/playbook.yml, with the following content:

    ---
    - name: Manage local storage
      hosts: managed-node-01.example.com
      tasks:
        - name: Resize LVM PV size
          ansible.builtin.include_role:
            name: redhat.rhel_system_roles.storage
          vars:
            storage_pools:
               - name: myvg
                 disks: ["sdf"]
                 type: lvm
                 grow_to_fill: true
    Copy to Clipboard Toggle word wrap

    The settings specified in the example playbook include the following:

    grow_to_fill

    true The role automatically expands the storage volume to use any new capacity on the disk.

    false The role leaves the storage volume at its current size, even if the underlying disk has grown.

    For details about all variables used in the playbook, see the /usr/share/ansible/roles/rhel-system-roles.storage/README.md file on the control node.

  2. Validate the playbook syntax:

    $ ansible-playbook --syntax-check ~/playbook.yml
    Copy to Clipboard Toggle word wrap

    Note that this command only validates the syntax and does not protect against a wrong but valid configuration.

  3. Run the playbook:

    $ ansible-playbook ~/playbook.yml
    Copy to Clipboard Toggle word wrap

Verification

  1. Verify the grow_to_fill setting works as expected. Prepare a test PV and VG:

    # pvcreate /dev/sdf
    # vgcreate myvg /dev/sdf
    Copy to Clipboard Toggle word wrap
  2. Check and record the initial physical volume size:

    # pvs
    Copy to Clipboard Toggle word wrap
  3. Edit the playbook to set grow_to_fill: false and run the playbook.
  4. Check the volume size and verify that it remained unchanged.
  5. Edit the playbook to set grow_to_fill: true and re-run the playbook.
  6. Check the volume size and verify that it has expanded.

2.3. Removing LVM physical volumes

You can use the pvremove command to remove a physical volume for LVM usage.

Prerequisites

  • Administrative access.

Procedure

  1. List the physical volumes to identify the device you want to remove:

    # pvs
    
      PV           VG Fmt  Attr PSize  PFree
      /dev/sdb       lvm2 ---  28.87g 28.87g
    Copy to Clipboard Toggle word wrap
  2. Remove the physical volume:

    # pvremove /dev/sdb
    Copy to Clipboard Toggle word wrap

    Replace /dev/sdb with the name of the device associated with the physical volume.

    Note

    If your physical volume is part of the volume group, you need to remove it from the volume group first.

    • If you volume group contains more that one physical volume, use the vgreduce command:

      # vgreduce VolumeGroupName /dev/sdb
      Copy to Clipboard Toggle word wrap

      Replace VolumeGroupName with the name of the volume group. Replace /dev/sdb with the name of the device.

    • If your volume group contains only one physical volume, use the vgremove command:

      # vgremove VolumeGroupName
      Copy to Clipboard Toggle word wrap

      Replace VolumeGroupName with the name of the volume group.

Verification

  • Verify the physical volume is removed:

    # pvs
    Copy to Clipboard Toggle word wrap

2.4. Creating logical volumes in the web console

Logical volumes act as physical drives. You can use the RHEL 10 web console to create LVM logical volumes in a volume group.

Prerequisites

  • You have installed the RHEL 10 web console.

    For instructions, see Installing and enabling the web console.

  • The cockpit-storaged package is installed on your system.
  • The volume group is created.

Procedure

  1. Log in to the RHEL 10 web console.
  2. Click Storage.
  3. In the Storage table, click the volume group in which you want to create logical volumes.
  4. On the Logical volume group page, scroll to the LVM2 logical volumes section and click Create new logical volume.
  5. In the Name field, enter a name for the new logical volume. Do not include spaces in the name.
  6. In the Purpose drop-down menu, select Block device for filesystems.

    This configuration enables you to create a logical volume with the maximum volume size which is equal to the sum of the capacities of all drives included in the volume group.

  7. Define the size of the logical volume. Consider:

    • How much space the system using this logical volume will need.
    • How many logical volumes you want to create.

    You do not have to use the whole space. If necessary, you can grow the logical volume later.

  8. Click Create.

    The logical volume is created. To use the logical volume you must format and mount the volume.

Verification

  • On the Logical volume page, scroll to the LVM2 logical volumes section and verify whether the new logical volume is listed.

2.5. Formatting logical volumes in the web console

Logical volumes act as physical drives. To use them, you must format them with a file system.

Warning

Formatting logical volumes erases all data on the volume.

The file system you select determines the configuration parameters you can use for logical volumes. For example, the XFS file system does not support shrinking volumes.

Prerequisites

  • You have installed the RHEL 10 web console.

    For instructions, see Installing and enabling the web console.

  • The cockpit-storaged package is installed on your system.
  • The logical volume created.
  • You have root access privileges to the system.

Procedure

  1. Log in to the RHEL 10 web console.
  2. Click Storage.
  3. In the Storage table, click the volume group in the logical volumes is created.
  4. On the Logical volume group page, scroll to the LVM2 logical volumes section.
  5. Click the menu button, , next to the volume group you want to format.
  6. From the drop-down menu, select Format.
  7. In the Name field, enter a name for the file system.
  8. In the Mount Point field, add the mount path.
  9. In the Type drop-down menu, select a file system:

    • XFS file system supports large logical volumes, switching physical drives online without outage, and growing an existing file system. Leave this file system selected if you do not have a different strong preference.

      XFS does not support reducing the size of a volume formatted with an XFS file system.

    • ext4 file system supports:

      • Logical volumes
      • Switching physical drives online without an outage
      • Growing a file system
      • Shrinking a file system
  10. Select the Overwrite existing data with zeros checkbox if you want the RHEL web console to rewrite the whole disk with zeros. This option is slower because the program has to go through the whole disk, but it is more secure. Use this option if the disk includes any data and you need to overwrite it.

    If you do not select the Overwrite existing data with zeros checkbox, the RHEL web console rewrites only the disk header. This increases the speed of formatting.

  11. From the Encryption drop-down menu, select the type of encryption if you want to enable it on the logical volume.

    You can select a version with either the LUKS1 (Linux Unified Key Setup) or LUKS2 encryption, which allows you to encrypt the volume with a passphrase.

  12. In the At boot drop-down menu, select when you want the logical volume to mount after the system boots.
  13. Select the required Mount options.
  14. Format the logical volume:

    • If you want to format the volume and immediately mount it, click Format and mount.
    • If you want to format the volume without mounting it, click Format only.

      Formatting can take several minutes depending on the volume size and which formatting options are selected.

Verification

  1. On the Logical volume group page, scroll to the LVM2 logical volumes section and click the logical volume to check the details and additional options.
  2. If you selected the Format only option, click the menu button at the end of the line of the logical volume, and select Mount to use the logical volume.

2.6. Resizing logical volumes in the web console

You can extend or reduce logical volumes in the RHEL 10 web console. The example procedure demonstrates how to grow and shrink the size of a logical volume without taking the volume offline.

Warning

You cannot reduce volumes that contains GFS2 or XFS filesystem.

Prerequisites

  • You have installed the RHEL 10 web console.

    For instructions, see Installing and enabling the web console.

  • The cockpit-storaged package is installed on your system.
  • An existing logical volume containing a file system that supports resizing logical volumes.

Procedure

  1. Log in to the RHEL 10 web console.
  2. Click Storage.
  3. In the Storage table, click the volume group in the logical volumes is created.
  4. On the Logical volume group page, scroll to the LVM2 logical volumes section and click the menu button, , next to volume group you want to resize.
  5. From the menu, select Grow or Shrink to resize the volume:

    • Growing the Volume:

      1. Select Grow to increase the size of the volume.
      2. In the Grow logical volume dialog box, adjust the size of the logical volume.
      3. Click Grow.

        LVM grows the logical volume without causing a system outage.

    • Shrinking the Volume:

      1. Select Shrink to reduce the size of the volume.
      2. In the Shrink logical volume dialog box, adjust the size of the logical volume.
      3. Click Shrink.

        LVM shrinks the logical volume without causing a system outage.

Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat