Skip to main content
Version: kirkstone_1-08-00

Disk Layout

Changing the disk layout in a Yocto build involves modifying the partitioning and file system configuration. Yocto uses the wic tool to create disk images.
To change the disk layout, you'll need to create a custom .wks (Wic Kickstart) file that defines the desired partition scheme. The .wic file changes depending on the SoC in use.
For example, Clea OS Embedded has the following .wic files pre-defined in layers/meta-seco-clea-os-embedded/classes/clea-os-embedded.bbclass:

WKS_FILE:seco-mx6 = "image-imx6.wks.in"
WKS_FILE:seco-mx8 = "image-imx8.wks.in"
WKS_FILE:seco-intel = "image-intel.wks.in"

Considering the iMX8 case, the content of image-imx8.wks.in is:

# description: Create i.MX8 Clea OS Embedded SD/eMMC image

# 0~32K: gpt
bootloader --ptable gpt
part u-boot --source rawcopy --sourceparams="file=imx-boot" --ondisk mmcblk --no-table --align ${IMX_BOOT_SEEK}

part /boot --source bootimg-partition --ondisk mmcblk --fstype=vfat --label bootfs --active --align 8192 --size 64
part / --source rootfs --ondisk mmcblk --fstype=ext4 --label rootfs --align 8192

To create a different disk layout for the iMX8 platform, the new .wks.in should be created starting from the default Clea OS's image-imx8.wks.in.

Assumption

A new custom layer is created to add both the image and wic configuration.

Assuming that a new custom layer is created to implement the disk layout customization, to add a new ext4 partition called example of 100MBytes to the disk layout create wic/example-image-imx8.wks.in with:

# description: Create i.MX8 Clea OS Embedded SD/eMMC image

# 0~32K: gpt
bootloader --ptable gpt
part u-boot --source rawcopy --sourceparams="file=imx-boot" --ondisk mmcblk --no-table --align ${IMX_BOOT_SEEK}

part /boot --source bootimg-partition --ondisk mmcblk --fstype=vfat --label bootfs --active --align 8192 --size 64
part / --source rootfs --ondisk mmcblk --fstype=ext4 --label rootfs --align 8192

# Custom partition
part /example --ondisk mmcblk --fstype=ext4 --label example --align 8192 --size 100M

A new image called recipes-core/images/example-image must be created to build with the aimed disk layout and its recipe must contain the string:

WKS_FILE:seco-mx8 = "example-image-imx8.wks.in"

to include the changes. Now running the command bitbake example-image creates .wic file containing the customized disk layout. It's possible to run the fdisk utility on the generated .wic file to have a deeper look of the disk layout.

If the request is to create also the mountpoint for the custom partition, recipes-core/images/example-image should be modified adding:

# Create custom partitions mount-points
create_mount_points(){
mkdir -p ${IMAGE_ROOTFS}/mnt/example
}

ROOTFS_POSTPROCESS_COMMAND += "create_mount_points;"