Switch to LVM thin provisioning

This change switches all LVM volumes being backed by a single thin
provisioning[1] pool.

This will allow day-2 operations to use spare physical space for
things such as:
- backups during a major upgrade on an ephemeral volume
- extending /srv or /var due to inaccurate storage capacity planning

This change enables the fstrim.timer unit on a daily schedule so that
the thin provisioning layer is notified of freed blocks.

[1] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/configuring_and_managing_logical_volumes/creating-and-managing-thinly-provisioned-volumes_configuring-and-managing-logical-volumes

Change-Id: Id1c7e627b67b930347eed040176a9737cabc87d0
Depends-On: https://review.opendev.org/c/openstack/diskimage-builder/+/840144
This commit is contained in:
Steve Baker 2022-06-28 11:26:57 +12:00
parent 865bf26dba
commit 304e4d1f96
2 changed files with 30 additions and 0 deletions

View File

@ -44,27 +44,46 @@
base: [ "pv" ]
options: [ "--force" ]
lvs:
- name: lv_thinpool
type: thin-pool
base: vg
# 20MiB overhead from root partition size
size: 5044MiB
- name: lv_root
type: thin
thin-pool: lv_thinpool
base: vg
# Volume sizes should be a multiple of 4MiB (1 LVM extent)
# so this is rounded down from 3706MiB
size: 3704MiB
- name: lv_tmp
type: thin
thin-pool: lv_thinpool
base: vg
size: 240MiB
- name: lv_var
type: thin
thin-pool: lv_thinpool
base: vg
size: 952MiB
- name: lv_log
type: thin
thin-pool: lv_thinpool
base: vg
size: 240MiB
- name: lv_audit
type: thin
thin-pool: lv_thinpool
base: vg
size: 192MiB
- name: lv_home
type: thin
thin-pool: lv_thinpool
base: vg
size: 240MiB
- name: lv_srv
type: thin
thin-pool: lv_thinpool
base: vg
size: 48MiB
- mkfs:

View File

@ -0,0 +1,11 @@
#!/bin/bash
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
sed -i "/^OnCalendar=/c\OnCalendar=daily" /usr/lib/systemd/system/fstrim.timer
sed -i "/^Description=/c\Description=Discard unused blocks once a day" /usr/lib/systemd/system/fstrim.timer
systemctl enable fstrim.timer