25.12. Resizing physical volumes by using the storage RHEL system role
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
sudopermissions for these nodes. - The size of the underlying block storage has been changed.
Procedure
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: trueThe settings specified in the example playbook include the following:
grow_to_filltrueThe role automatically expands the storage volume to use any new capacity on the disk.falseThe 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.mdfile on the control node.Validate the playbook syntax:
$ ansible-playbook --syntax-check ~/playbook.ymlNote that this command only validates the syntax and does not protect against a wrong but valid configuration.
Run the playbook:
$ ansible-playbook ~/playbook.yml
Verification
Verify the
grow_to_fillsetting works as expected. Prepare a test PV and VG:# pvcreate /dev/sdf # vgcreate myvg /dev/sdfCheck and record the initial physical volume size:
# pvs-
Edit the playbook to set
grow_to_fill: falseand run the playbook. - Check the volume size and verify that it remained unchanged.
-
Edit the playbook to set
grow_to_fill: trueand re-run the playbook. - Check the volume size and verify that it has expanded.