Welcome to ProComputers Virtual Image Library:

To see all the AMIs released by ProComputers Virtual Image Library, please browse our listing on the AWS Marketplace.

< Back Home

LVM auto-resizing functionality

This page explains how to configure the auto-resizing of LVM logical volumes and their corresponding filesystems in ProComputers's provided LVM AMIs:

DISCLAIMER: this LVM auto-resizing functionality is provided as is, and comes with no guarantees or warranties of any sorts, either written or implied. Make sure you backup all your instance volume data before the instance volume size is increased. Use this at your own risk.

NOTE1: if the below LVM auto-resizing explanation seems complex, you can always leave the default configuration unchanged, which we think will fit most situations.

NOTE2: all below examples assume a default instance volume size of 8 GiB. However, there are cases where the default instance volume size is 10 GiB (e.g. in case of RHEL instances).

By default, the LVM managed volumes are split like this:

If you increase the size of the instance volume, the size of all LVM logical volumes and their corresponding filesystems will be increased as well. The boot filesystem is on a separate partition not managed with LVM, and therefore its size will allways remain at 512 MiB.

The way LVM logical volumes are increased is specified in the /etc/sysconfig/lvmresize configuration file. The default values of the configuration parameters are displayed below:

# Size specified in GiB. Format is below:
# lv_name | size_increment | max_lv_size
LV_NAME_AND_SIZE="root|1|10
    tmp|1|4
    usr|2|20
    home|2|20
    var|100%FREE|"

# This MUST always be bigger than the sum of all LV size_increments
DENOMINATOR=8

What this means is the following: with every 8 GiB (specified by the DENOMINATOR configuration parameter) increase in the size of the instance volume, the LVM logical volumes and their corresponding filesystems will be modified like this:

The way the increased available space is split between the LVM logical volumes is specified by the LV_NAME_AND_SIZE configuration parameter, that contains, one per line, separated by | (pipe) character and no spaces, the following:

The sum of all size_increment values from all LVM logical volumes/filesystems (with the exception of last one that has 100%FREE size increment) MUST be less than the value of the DENOMINATOR configuration parameter. In our default configuration, 1 GiB for root + 1 GiB for tmp + 2 GiB for usr + 2 GiB for home is a total of 6 GiB, which is less than 8 GiB specified by DENOMINATOR configuration parameter.

The size of each LVM logical volume/filesystem will not be extended above the max_lv_size value. Furthermore, the LVM logical volume/filesystem that has the size increment configured as 100%FREE MUST allways be the last one, and should not have specified a max_lv_size, as all other ones have.

Therefore, if we take our default configuration with an instance volume size increased by 50 GiB (and therefore the total instance volume will be 58 GiB), the LVM logical volumes and corresponding filesystems will be increased like this:

This is how above numbers are calculated: DENOMINATOR value that is 8 fits in 50 GiB 6 times (8 times 6 is 48). Lets call 6 the multiplier. So:

The size of the LVM instance volume is checked every time the LVM instance boots, by means of bootcmd cloud-init configuration directive.

If we take the above example where the instance volume was increased with 50 GiB in size and the LVM auto-resizing configuration is the default one, the cloud-init console output would look like below:

[ 20.196525] cloud-init[1288]: +---------------------------------------------------------------+
[ 20.200297] cloud-init[1288]: > Found 50 GiB free on /dev/nvme0n1 device.
[ 20.203223] cloud-init[1288]: +---------------------------------------------------------------+
[ 20.209631] cloud-init[1288]: > Extending /dev/nvme0n1p3 partition to maximum available space... OK
[ 20.412609] cloud-init[1288]: > Extending /dev/nvme0n1p3 PV to maximum available space... OK
[ 20.416578] cloud-init[1288]: +---------------------------------------------------------------+
[ 21.070661] cloud-init[1288]: > Extending root LV and filesystem with 6 GiB... OK
[ 21.198815] cloud-init[1288]: > Extending tmp LV and filesystem with 3 GiB... OK
[ 21.340070] cloud-init[1288]: > Extending usr LV and filesystem with 12 GiB... OK
[ 21.486763] cloud-init[1288]: > Extending home LV and filesystem with 12 GiB... OK
[ 21.634820] cloud-init[1288]: > Extending var LV and filesystem with 100%FREE GiB... OK
[ 21.641120] cloud-init[1288]: +---------------------------------------------------------------+
[ 21.644664] cloud-init[1288]: > Extending process went OK.
[ 21.646701] cloud-init[1288]: +---------------------------------------------------------------+

After the boot process is finalised and the user logs in using ssh public key authentication, a similar message with the following one will be displayed on the screen:

  Welcome to CentOS-8.1-x86_64-LVM-8GiB-HVM-20200530_194355.

  * Use "sudo su -" command in order to become root.
  * Your default instance volume size was increased to 58 GiB.
    All LVM logical volumes as well as their corresponding filesystems were
    automatically extended as well, and currently have the following sizes:
                /       7 GiB
                /boot   512 MiB
                /tmp    4 GiB
                /usr    14 GiB
                /home   14 GiB
                /var    18 GiB and 508 MiB

  * For more details about the LVM auto-extending process please see
    /etc/sysconfig/lvmresize. If you want to customize your LVM auto-extending
    process please visit https://www.procomputers.com/lvmresize.html

  If you don't want to see this message anymore, please remove
  the content of the /etc/motd text file.

In case the instance volume size is not changed, the cloud-init console output should display something like below:

[ 10.443709] cloud-init[1282]: +---------------------------------------------------------------+
[ 10.446495] cloud-init[1282]: > No extra free space available on /dev/nvme0n1.
[ 10.448777] cloud-init[1282]: +---------------------------------------------------------------+

If you want to customise the way the increased available space is split between the LVM logical volume and their corresponding filesystems, please do the following:

  1. boot the LVM AMI in your preffered AWS region
  2. login and customize the /etc/sysconfig/lvmresize configuration file. Only the LV_NAME_AND_SIZE and DENOMINATOR parameters should be changed, the rest of the configuration parameters should retain their default value
  3. stop the LVM instance
  4. create a snapshot of the LVM instance volume, and register a new image that now contains your customised /etc/sysconfig/lvmresize configuration file

NOTE: the growpart and resizefs cloud-init modules cannot be used with LVM, and therefore their configuration directives are removed from the cloud-init /etc/cloud/cloud.cfg configuration file.

Disabling LVM auto-resizing functionality

If your instance volume size has been increased and now all LVM logical volumes and corresponding filesystems have reached the desired size, you may wish to disable the LVM auto-resizing functionality. To do this, please run the following commands as root user.

# rm -rf /etc/sysconfig/lvmresize
# rm -rf /etc/cloud/cloud.cfg.d/10_lvmresize.cfg

That's it, your LVM auto-resizing functionality is now disabled in your instance. There is no need to reboot.

< Back Home

Support request:

For any issues with images provided by ProComputers, please visit our support page.

Custom Cloud Image creation:

If you have custom image building requirements, please contact ProComputers Support, and we'll be more than happy to discuss with you.

Valid HTML 4.01 Transitional