Is it possible to exclude paths from rootfs tar in a teziimg?

I am using the latest and greatest code pulled using the tdxref repo manifest.

I have my own custom image_type_custom_tezi.bbclass which inherits the base one (doing this as I need to inject an extra partition into the final image).

What I am trying to figure out is if there is a way to remove the files from the RootFS tar/partition?
Basically removing what I have now put into my other partition (essentially a /data partition).

I came across the IMAGE_ROOTFS_EXCLUDE_PATH variable, which looks like it should be what I need, but it doesn’t appear to be doing anything.
Just wondering if I am looking in the right place for my solution or am I way off the mark?

Any help (enlightenment) would be greatly appreciated.

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!


Hello,

I understand you’re trying to exclude certain paths from the RootFS tarball in your custom Toradex image. The IMAGE_ROOTFS_EXCLUDE_PATH variable is indeed intended for such purposes, allowing you to specify paths that should not be included in the root filesystem image.

If setting IMAGE_ROOTFS_EXCLUDE_PATH does not seem to have an effect, ensure that you are applying it correctly within your Yocto Project environment. This variable should be set in your image recipe or in a conf file that is included by your image recipe. Here’s a basic example of how to use it:

IMAGE_ROOTFS_EXCLUDE_PATH += "/data"

This line would exclude the /data directory from the generated RootFS. Make sure that the path you are trying to exclude is correctly specified and that the variable is being set before the root filesystem is created.

If after ensuring the correct usage the paths are still not excluded, it might be worth checking if your custom image_type_custom_tezi.bbclass is somehow interfering with the process. Since you’ve inherited the base class, ensure that any additional functionality you’ve added does not conflict with the root filesystem generation process, particularly with how IMAGE_ROOTFS_EXCLUDE_PATH is handled.

Another aspect to consider is the timing when variables are parsed and applied in the Yocto build process. It’s crucial that IMAGE_ROOTFS_EXCLUDE_PATH is set at a point where it can still influence the creation of the root filesystem tarball.

Lastly, since you are working with a custom partition setup, double-check that the exclusions you’re aiming for are not being overridden or ignored due to the customizations you’ve introduced.

If after checking these points you still face issues, it might be helpful to review the logs generated during the build process for any clues or to ensure that your custom bbclass is correctly integrated with the Yocto build system’s root filesystem generation stages.

Best regards,
Toradex AI Assistant

Please, also check if these links can help you solve your problem:

TorizonCore Builder Tool “build” command | Toradex Developer Center.


How did you like my response?

:+1: :-1:

I am currently setting IMAGE_ROOTFS_EXCLUDE_PATH in my layer.conf file so I am pretty sure this is being applied as early as possible. I can also verify this using bitbake-getvar.

My custom image is just adding an extra prefunc that loads the image.*.json file and appends the relevant custom partition. It also adds the IMG_CMD:datafs which is pretty much a copy of what bootfs does but targeting the /data folder for populating it’s content.

UPDATE:
I have just run this again (double checked I was using the same path syntax as originally I had data/ instead of /data) and this also fails to remove the directory from the rootfs tar image.

Ideally I want to remove all the content of the directory, but not the directory itself as I need the directory there for mounting my custom partition to (At least I believe this is required to mount it properly).

Hello @izzy_building,

I could not find a lot of information about IMAGE_ROOTFS_EXCLUDE_PATH, so it is possible that this is not fully supported.
I think this may require some additional changes to the do_rootfs command, but I am not sure.
The base-files recipe may also be worth checking as it creates many base directories.

As this is a very specific use case, we can introduce you to one of our partners that would be able to help you with this implementation.

Other community users are welcome as always to comment on this if they want.

Best Regards,
Bruno

Hi @bruno.tx,

I have managed to dig deeper into things and it turns out that variable is mentioned on some other threads about different images.
However, while digging I found that the process that needed to change to support this variable is do_image_tar which is where the tar and tar.xz are created for the rootfs.

My current fix that would seem to work for my case is:

image_type_custom_tezi.bbclass

IMAGE_CMD_TAR_ORIGINAL := "${IMAGE_CMD_TAR}"
IMAGE_ROOTFS_TAR_EXCLUSIONS = "${@ ''.join(" --exclude='.%s'" % p for p in '${IMAGE_ROOTFS_EXCLUDE_PATH}'.split())}"
IMAGE_CMD_TAR:tar = "${IMAGE_CMD_TAR_ORIGINAL}${IMAGE_ROOTFS_TAR_EXCLUSIONS}"

local.conf or layer.conf:

IMAGE_ROOTFS_EXCLUDE_PATH += "${data_dir}"

This addition adds the --exclude parameter for each entry in the IMAGE_ROOTFS_EXCLUDE_PATH variable (in case there is more than one) to the tar command, but only when building the tar image (e.g. rootfs).

Not sure if this will be helpful for others, or if there is a better way to do this. But it solves my current needs.

Regards,

Hello @izzy_building,

Thanks for sharing your solution.

Best Regards,
Bruno