# Configure the postboot settings

Postboot settings comprise completing initial setup, configuring memory, and CPU frequency parameters. These steps ensure proper configuration and functionality after the system boots up.

## Postboot framework overview

A postboot script file is used to configure system parameters on the Qualcomm Linux distribution.

Postboot settings are managed through a *systemd service* file.

For more information about systemd, see [systemd(1) - Linux manual page](https://www.man7.org/linux/man-pages/man1/systemd.1.html).

## Systemd service overview

A systemd service is a background process that starts or stops based on specific conditions.

A `systemd service` file is written to allow systemd to parse, understand, and run as instructed.

For more information about the background process, see [background process](https://linuxhandbook.com/run-process-background/).

## Basic structure of systemd service file

To modify the behavior of systemd based on the requirement, use the following procedure:

The following is the example of the systemd service file:

[Unit]
    SourcePath=/etc/initscripts/log_restrict.sh
    Description=QTI logging service
    
    [Service]
    ExecStart=/etc/initscripts/post_boot.sh
    
    [Install]
    WantedBy=multi-user.target
    Copy to clipboard

### The `[Unit]` section

In systemd, a unit refers to any resource that the system knows how to operate and manage. It encompasses services, sockets, devices, mount points, and groups of externally created processes.

Each unit is defined using a configuration file called a `unit` file, which has metadata and configuration details. The `[Unit]` section within a unit file provides information about the description
and relationships with other units.

The `[Unit]` section has the following fields:

Table: Supported fields for [Unit] section

| Fields | Description |
| --- | --- |
| Description<br>    Copy to clipboard | Human-readable title of the systemd service. |
| After<br>    Copy to clipboard | Set dependency on a service. For example, if you are configuring a WCN3960 web server, you want the server to  start after the network is online. |
| Before<br>    Copy to clipboard | Start current service before specified service. In this example, the WCN3960 web server is running before the service for the next cloud is started because the next cloud server depends on the WCN3960 web server. |

### The `[Service]` section

The `[Service]` section contains details of the execution and termination of service.

The `[Service]` section has the following fields:

Table: Supported fields for [Service] section

| Fields | Description |
| --- | --- |
| ExecStart<br>    Copy to clipboard | The command that you must run when the service starts. For example, a web server service to start. |
| ExecReload<br>    Copy to clipboard | The optional field that it specifies how a service is restarted. For services that perform disk I/O, it’s recommended to kill them and restart the service. Use the `ExecReload` field if you want to have a specific restart mechanism. |
| Type<br>    Copy to clipboard | Indicates the start-up type of a process for a specified systemd service. The options available are `simple`, `exec`, `forking`, `oneshot`, `dbus`, `notify`, and `idle`. |

For more information, see [Options](https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html?ref=linuxhandbook.com#Options).

### The `[Install]` section

The `[Install]` section handles the installation of a systemd service or unit file. This is used when you run either the `systemctl enable` or `systemctl disable` command for enabling or disabling a service.

The `[Install]` section has the following fields:

- `WantedBy`: Similar to the `After` and `Before` fields of the
[The \[Unit\] section](https://docs.qualcomm.com/doc/80-70020-3/topic/post-boot-settings.html#kernelexternaldocumentation-the-unit-section).
However, it’s used to specify systemd-equivalent **run levels**.

    The `default.target` is used when all the system initialization is
complete and you are asked to log in. Most user-facing services (like
WCN3960, cron, GNOME-stuff) use this target.

    The `shutdown.target` is to run the service just before the device
shuts down.

    The `multi-user.target` is to run the service at the time of system
boot, as the root user.

    It can be either a target or a service, for example
`network.target`.
- `RequiredBy`: This field is similar to `WantedBy`. However, the
field specifies **hard dependencies**. If a dependency fails, the
service also fails.

## Install the postboot systemd service

The postboot script file is present in the core recipe of the `meta-qcom-hwe` layer.

Run the postboot script as a part of the previous systemd service. All postboot settings are hosted in a
`meta-qcom-hwe/recipes-core/initscripts/files/post_boot.sh` script.

#!/bin/sh
    # Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
    # SPDX-License-Identifier: BSD-3-Clause-Clear
    
    # Apply postboot settings
    Copy to clipboard

### Recipe for postboot systemd service

Use the `initscripts_1.0.bbappend` file to understand the recipe configuration procedure to install the `post_boot` script.

The recipe to install the postboot bash script in `/etc/init.d` is present in the `meta-qcom-hwe/recipes-core/initscripts/initscripts_1.0.bbappend` file.

# postboot
    
    inherit systemd externalsrc
    
    FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
    SRC_URI:append = " \
       file://post_boot.sh \
       file://logging-restrictions.sh \
       file://log-restrict.service \
       file://post-boot.service \
       "
    
    do_install:append() {
       # postboot
       install -m 0755 ${WORKDIR}/post_boot.sh ${D}${sysconfdir}/initscripts/post_boot.sh
       install -m 0644 ${WORKDIR}/post-boot.service -D ${D}${systemd_unitdir}/system/post-boot.service
       ln -sf ${systemd_unitdir}/system/post-boot.service ${D}${systemd_unitdir}/system/multi-user.target.wants/post-boot.service
    }
    
    S = "${WORKDIR}"
    
    INITSCRIPT_PACKAGES =+ "${PN}-post-boot"
    INITSCRIPT_NAME:${PN}-post-boot = "post_boot.sh"
    
    PACKAGES =+ "${PN}-post-boot"
    FILES:${PN}-post-boot += "${systemd_unitdir}/system/post-boot.service ${systemd_unitdir}/system/multi-user.target.wants/post-boot.service ${sysconfdir}/initscripts/post_boot.sh"
    Copy to clipboard

Last Published: Jul 02, 2025

[Previous Topic
Boot flow and architecture overview](https://docs.qualcomm.com/bundle/publicresource/80-70020-3/topics/boot-flow-and-architecture-overview.md) [Next Topic
Develop the kernel](https://docs.qualcomm.com/bundle/publicresource/80-70020-3/topics/kernel-development.md)