> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage partitions in Qualcomm Linux

The following section describes how you can add, delete, modify, and rename flash partitions for a Qualcomm Linux supported machine. The partitions are defined using the `partitions.conf` configuration files. These files are available at [https://github.com/qualcomm-linux/qcom-ptool/tree/main/platforms](https://github.com/qualcomm-linux/qcom-ptool/tree/main/platforms). For more information, see: [Ptool workflow](https://dragonwingdocs.qualcomm.com/Key-Documents/Yocto-Guide/manage-partitions-in-qualcomm-linux#ptool-workflow) figure.

You can modify the partition configuration files to add, delete, modify, or rename partitions. For example, to work with UFS partition files for IQ-9075 EVK, use the following file: [https://github.com/qualcomm-linux/qcom-ptool/tree/main/platforms/iq-9075-evk/ufs](https://github.com/qualcomm-linux/qcom-ptool/tree/main/platforms/iq-9075-evk/ufs)

By modifying these configuration files and integrating these in the build, you can generate a custom partition layout. When a configuration file from [https://github.com/qualcomm-linux/qcom-ptool/tree/main/platforms](https://github.com/qualcomm-linux/qcom-ptool/tree/main/platforms) is used in Qualcomm Linux builds, the workflow spans all the steps from the [Ptool workflow](https://dragonwingdocs.qualcomm.com/Key-Documents/Yocto-Guide/manage-partitions-in-qualcomm-linux#ptool-workflow) figure.

The following tables list the files and tools used for partitioning workflow:

|           **File**           |                                        **Description**                                       |
| :--------------------------: | :------------------------------------------------------------------------------------------: |
|     Partition layout file    | Defines all partitions for storage in JSON format. This file is used by gen\_partition tool. |
| Generated Partition XML file |        Defines the Qualcomm internal XML format. This generated file is used by Ptool.       |

|    **Tool**    |                                            **Description**                                           |
| :------------: | :--------------------------------------------------------------------------------------------------: |
| gen\_partition | Reads the partition layout files and generates an internal XML format handled by the Qualcomm Ptool. |
|      Ptool     |   The Qualcomm Ptool converts information in partition XML to GUID Partition Table (GPT) binaries.   |

## **Partition layout file**

The partitions on the universal flash storage (UFS) and embedded multimedia card (eMMC) store various images of the bootchain and the Linux operating system. The configuration file details the partitions configured for a specific Qualcomm development kit. The following configuration files define the UFS partitions for the RB3 Gen 2 development kit and the partitions for IQ-9075 EVK:

* RB3 Gen 2 development kit UFS partitions: [https://github.com/qualcomm-linux/qcom-ptool/tree/main/platforms/qcs6490-rb3gen2/ufs](https://github.com/qualcomm-linux/qcom-ptool/tree/main/platforms/qcs6490-rb3gen2/ufs)
* IQ-9075 EVK UFS partitions: [https://github.com/qualcomm-linux/qcom-ptool/tree/main/platforms/iq-9075-evk/ufs](https://github.com/qualcomm-linux/qcom-ptool/tree/main/platforms/iq-9075-evk/ufs)

### **Partition layout file syntax**

The following examples from the `partitions.conf` from `qcs6490-rb3gen2` show the syntax of the partition layout file.

The first entry in the configuration file defines the disk type, disk size, logical block addressing (LBA) size (sector size), and whether the last partition should grow till the last usable LBA.

* The following is an example for the UFS:
  > ```text theme={null}
  > # select disk type emmc | nand | ufs Mandatory
  > # disk size in bytes Mandatory
  >
  > --disk --type=ufs --size=137438953472 --write-protect-boundary=0 --sector-size-in-bytes=4096 --grow-last-partition
  > ```
* The following is an example for the eMMC:
  > ```text theme={null}
  > # select disk type emmc | nand | ufs Mandatory
  > # disk size in bytes Mandatory
  >
  > --disk --type=emmc --size=76841669632 --write-protect-boundary=65536 --sector-size-in-bytes=512 --grow-last-partition
  > ```

The `qcs6490-rb3gen2/ufs` file specifies the following examples of partitions. A few partitions are defined in LUN0, with each line representing an individual partition.

#### **UFS**

**Note**

In the following examples, the file names mentioned in LUN1 to LUN5 entries by the `--filename=`parameter of `partitions.conf` are downloaded by the recipe `firmware-qcom-boot-qcs6490.inc`from [Qualcomm software center](https://softwarecenter.qualcomm.com/)

* Example 1: The `efi` partition of 524288 KB is defined in LUN0. The `efi.bin` file is generated during the BitBake build.
  ```text theme={null}
  --partition --lun=0 --name=efi --size=524288KB --type-guid=C12A7328-F81F-11D2-BA4B-00A0C93EC93B --filename=efi.bin
  ```

A couple of partitions are defined in LUN1. Each line defines an individual partition:

* Example 2: The `xbl_a` partition of 3604 KB is defined for LUN1. Flash the `xbl.elf` file to this partition.
  ```text theme={null}
  #This is LUN 1 - Boot LUN A
  --partition --lun=1 --name=xbl_a --size=3604KB --type-guid=DEA0BA2C-CBDD-4805-B4F9-F428251C3E98 --filename=xbl.elf
  ```
* Example 3: The `xbl_config_a` partition of 512 KB is defined for LUN1. Flash the `xbl_config.elf` file to this partition.
  ```text theme={null}
  #This is LUN 1 - Boot LUN A
  --partition --lun=1 --name=xbl_config_a --size=512KB --type-guid=5A325AE4-4276-B66D-0ADD-3494DF27706A --filename=xbl_config.elf
  ```

A partition defined in LUN4:

* Example 4: The `aop_a` partition of 512 KB is defined for LUN4. Flash the `aop.mbn` file to this partition.
  ```text theme={null}
  --partition --lun=4 --name=aop_a --size=512KB --type-guid=D69E90A5-4CAB-0071-F6DF-AB977F141A7F --filename=aop.mbn
  ```

#### **eMMC**

* Example 1: The `xbl_a` partition of 3584 KB is defined for LUN0. Flash the xbl.elf file to this partition.
  ```text theme={null}
  #This is LUN 0 - Boot LUN A
  --partition --name=xbl_a --size=3584KB --type-guid=DEA0BA2C-CBDD-4805-B4F9-F428251C3E98 --filename=xbl.elf
  ```
* Example 2: The `xbl_config_a` partition of 128 KB is defined for LUN0. Flash the `xbl_config.elf` file to this partition.
  ```text theme={null}
  #This is LUN 0 - Boot LUN A
  --partition --name=xbl_config_a --size=128KB --type-guid=5A325AE4-4276-B66D-0ADD-3494DF27706A --filename=xbl_feature_config.elf
  ```

The options used for each partition entry are as follows:

* Mandatory options:
  * `--lun` (mandatory for UFS, not required for eMMC. Expressed as number)
  * `--name` (name for the partition, a string)
  * `--size` (size of the partition, generally expressed in KB)
  * `--type-guid` (GUID for the partition)
* Optional options:
  * `--attributes` (Optional 64 bit attribute, for example, 1000000000000004)
  * `--filename` (Name of the file that is flashed to the partition)
  * `--readonly` (whether the partition should be read-only, values true or false)
  * `--sparse` (whether the partition is for a sparse image, values true or false)

## **Linux operating system partitions**

|  **Partitions**  |                                                                                                                                                                **Description**                                                                                                                                                               |
| :--------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|   EFI partition  | The EFI system partition (ESP) contains `Esp.bin` and a `vfat` file. It contains all the details necessary for the UEFI to enable systemd-boot. For more information about this image, see [EFI image](https://dragonwingdocs.qualcomm.com/Key-Documents/Yocto-Guide/configure-and-secure-boot-with-systemd-boot-and-uki#efi-image-section). |
| Rootfs partition |                                                                                                            This partition contains the `rootfs.img` image file. This image consists of all the user space libraries and binaries.                                                                                                            |

## **Partition tool (Ptool)**

Ptool generates a GUID partition table binary that the QDL tool uses to partition the storage.

The following figure shows the Ptool workflow:

<div className="flex flex-col items-center gap-2">
  <img src="https://mintcdn.com/qualcomm-prod/T1k4QQ7G3l_dE-rX/Key-Documents/Yocto-Guide/media/k2c-qli-yocto-build-ga/ptool.png?fit=max&auto=format&n=T1k4QQ7G3l_dE-rX&q=85&s=c4e16ddcce6d9e3a78224943eea756af" alt="Figure: Ptool workflow" width="788" height="937" data-path="Key-Documents/Yocto-Guide/media/k2c-qli-yocto-build-ga/ptool.png" />

  <p className="text-sm text-gray-700">
    Figure: Ptool workflow
  </p>
</div>

The Ptool‑generated binaries for the QCS6490 RB3 Gen 2 Vision development kit are located in the `build/tmp/deploy/images/rb3gen2-core-kit/qcomflash` directory.

### **Modify partition**

The `partitions.conf` file available at [https://github.com/qualcomm-linux/qcom-ptool/tree/main/platforms/qcs6490-rb3gen2/ufs](https://github.com/qualcomm-linux/qcom-ptool/tree/main/platforms/qcs6490-rb3gen2/ufs), defines the partitions for QCS6490 RB3 Gen 2 Core development kit. The `gen_partition.py` tool processes and generates `partition.xml`, which is a mandatory input for `ptool.py`. As a final step, Ptool generates the `rawprogram.xml`, `patch.xml`, `gpt_main*.bin`, and `gpt_backup*.bin` files, which are required by the QDL tool to flash the system image to the device.

1. To add a partition, make a partition entry in the configuration file: `partitions.conf` for a particular device.
2. Run the BitBake command to generate all necessary files:
   ```text theme={null}
   bitbake <image-name>
   ```
3. After the image build completes, if MACHINE is `rb3gen2-core-kit` and the image recipe selected is `qcom-multimedia-image`, run the following command to flash the image:
   ```text theme={null}
   cd <workspace>/build/tmp/deploy/images/rb3gen2-core-kit/qcom-multimedia-image-rb3gen2-core-kit.rootfs-<timestamp>.qcomflash
   ./qdl prog_firehose_ddr.elf rawprogram*.xml patch*.xml
   ```

## **Best practices**

* Many partitions are crucial for functionality. Before removing or resizing partitions, review the partition layout documentation carefully.
* To reflect changes in `partitions.conf`, update the `QCOM_PARTITION_CONF` variable in the machine configuration.
* For UFS devices, always specify the `--lun` option for each partition entry.

## **Next steps**

* To add, delete, or rename partitions using the Yocto build, see [Modify partition layout](./modify-partition-layout).
* For the persist partition, see [Persist partition](./persist-partition).
* For storage type configuration, see [How to configure the storage type for a Yocto BSP build](./how-to-configure-storage-type).
