Configuring memory allocation¶
To configure memory allocation, you must tune the memory_limit attributes of high and max for the
QM partition.
The max value represents the maximum limit for memory use in the QM partition. QM processes that attempt to exceed the max limit initiate the
Out of Memory killer. The high value is the
memory threshold that the kernel tries not to exceed. If QM processes reach the high limit, the kernel will proactively release memory.
Writable QM container in package mode
When you build with aib-dev build (package mode), the QM container runs as writable by default.
When you build with aib build (bootc/image mode), the QM container remains read-only.
The writable setting appears as ReadOnly=false in the [Container] section of the QM drop-in configuration file.
Prerequisites
- Podman
automotive-image-builder- A custom manifest file with a QM partition, such as the manifest file that you created in Embedding containerized applications in the QM partition.
Procedure
-
In your manifest file, configure the
memory_limitattributesmaxandhighto40%and35%, respectively:
Verification
-
Build a disk image:
-
Run the image:
-
After the image starts, log in as
rootusing the passwordpassword. -
Use the
systemctl showcommand to display theMemoryMaxvalue generated by themaxoption you set in your manifest:Expected output:
-
Use the
systemctl showcommand to display theMemoryHighvalue generated by thehighoption you set in your manifest:Expected output:
-
Review the contents of the drop-in file generated by your manifest using the
catcommand:Show drop-in configuration file contents[root@localhost ~]# cat /usr/share/containers/systemd/qm.container.d/10-automotive.confExpected output:
Out of Memory (OOM) protection¶
Automotive Image Builder automatically enables Out of Memory (OOM) protection when the QM partition
is active. OOM protection sets DefaultOOMScoreAdjust=-1000 in the systemd configuration, which
prevents the OOM killer from terminating critical host processes.
To explicitly control OOM protection, set enable_oom_protection in the image section of your
manifest as shown in the following example:
For more information about OOM behavior in the QM partition, see Memory allocation in the QM partition.
Separate QM data partition¶
By default, QM data resides in the main /var partition. For images that require stronger
isolation between QM and host data, you can configure a dedicated /var/qm partition by adding
a var_qm section under image.partitions in your manifest.
The var_qm partition supports the following options:
relative_size: Set the size of the partition as a fraction of the total image size.0is the default value, which disables the feature.size: Set the absolute size of the partition in bytes with a suffix (for example,500 MiB).external: Set totruewhen/var/qmresides on a separate physical device.uuid: Assign a specific UUID for the partition.
image:
partitions:
var:
relative_size: 0.3
var_qm:
relative_size: 0.1
Note
When planning partition sizes, ensure the combined relative_size of
var and var_qm fits within the total image size. Both partitions
are sized independently as fractions of the total image.
The var_qm partition is only created when the QM partition is enabled.
Additional resources