Files
diskimage-builder/diskimage_builder/elements/growvols
mcreach ff5c11c095 Fix growvols multipath partition_delimiter detect
On nodes with Fiber Channel multipath, the growvols command is
failing sometimes with the following stack trace:

Traceback (most recent call last):
  File "/usr/local/sbin/growvols", line 650, in <module>
    sys.exit(main(sys.argv))
  File "/usr/local/sbin/growvols", line 541, in main
    partnum = find_next_partnum(devices, disk)
  File "/usr/local/sbin/growvols", line 341, in find_next_partnum
    max_partnum = max(max_partnum, int(dev_name[disk_name_length:]))
ValueError: invalid literal for int() with base 10: 'p1'

The error is related to the kernel naming scheme for disk partitions.
If the disk name is ending with a digit, the kernel adds "pX" (where
X is  the partition number) instead of just "X" when the disk name
ends with a letter.

Consulting the manual page multipath.conf(5), the partition_delimiter
is configurable. If partition_delimiter is <unset> (the default) a
delimiter 'p' is inserted only if the map name ends in a digit. If
however the user configured a partition_delimiter, it will always be
used.

To try to handle both cases, use a regular expression to catch only
the digits at the end of the string.

Authored-By: mcr.opensource@gmail.com
Co-Authored-By: hjensas@redhat.com
Closes-Bug: #2109988
Change-Id: Ifbd58000601b7fc5635dcc2c7a897462000319b0
2025-05-06 02:17:40 +02:00
..

growvols

Grow one or more LVM volumes on first boot.

This installs utility growvols which grows the logical volumes in an LVM group to take available device space.

The positional arguments specify how available space is allocated. They have the format <volume>=<amount><unit> where:

<volume> is the label or the mountpoint of the logical volume <amount> is an integer growth amount in the specified unit <unit> is one of the supported units

Supported units are:

% percentage of available device space before any changes are made MiB mebibyte (1048576 bytes) GiB gibibyte (1073741824 bytes) MB megabyte (1000000 bytes) GB gigabyte (1000000000 bytes)

Each argument is processed in order and the requested amount is allocated to each volume until the disk is full. This means that if space is overallocated, the last volumes may only grow by the remaining space, or not grow at all, and a warning will be printed. When space is underallocated the remaining space will be given to the root volume (mounted at /).

The currently supported partition layout is: - Exactly one of the partitions containing an LVM group - The disk having unpartitioned space to grow with - The LVM logical volumes being formatted with XFS filesystems

Example usage:

growvols /var=80% /home=20GB

growvols --device sda --group vg img-rootfs=20% fs_home=20GiB fs_var=60%

Environment variables can be set during image build to enable a systemd unit which will run growvols on boot:

# DIB_GROWVOLS_TRIGGER defaults to 'manual'. When set to 'systemd' a systemd # unit will run using the following arguments export DIB_GROWVOLS_TRIGGER=systemd

# DIB_GROWVOLS_ARGS contains the positional arguments for which volumes to grow # by what amount. If omitted the volume mounted at / will grow by all available # space export DIB_GROWVOLS_ARGS="img-rootfs=20% fs_home=20GiB fs_var=60%"

# DIB_GROWVOLS_GROUP contains the name of the LVM group to extend. Defaults the # discovered group if only one exists. export DIB_GROWVOLS_GROUP=vg

# DIB_GROWVOLS_DEVICE is the name of the disk block device to grow the # volumes in (such as "sda"). Defaults to the disk containing the root mount. export DIB_GROWVOLS_DEVICE=sda