Search code examples
yoctobitbake

Yocto: Create a directory after mount


I have a Yocto bitbake recipe in my layer - base-files_%.bbappend. It creates mount points:

do_install_append() {
    mknod -m 622 ${D}/dev/console c 5 1
    install -m 0755 -d ${D}/boot/EFI
    install -m 0755 -d ${D}/data
}

The /data/ directory is later mounted to the internal SD card.

I would like to create a directory ${D}/data/test. What is the best way to do it? I've added a line install -m 0755 -d ${D}/data/test to this function but it didn't do it.

Thanks so much.


Solution

  • You have to ship those installed files by adding to your recipe:

    FILES_${PN} += "/data/test"

    Another solution is to add in your image recipe:

    create_dirs() {
        mkdir -p ${IMAGE_ROOTFS}/data/test
    }
    
    ROOTFS_POSTPROCESS_COMMAND += "create_dirs ; "