embedded-linuxbitbakerootfssquashfsyocto-wic

Yocto - How do I change the rootfs file system type


I'm trying to build vdi image with squashfs rootfs, but cannot find where to change current ext4 fs into squash. Closest solutions I found is here: How do I change the rootfs file system type used for the sdcard image in yocto? But I don't feel like this answered my problem. I am able to build .rootfs.squashfs and .rootfs.wic.vdi. Is it possible to build .rootfs.wic.vdi with squashfs root using bitbake?


Solution

  • Look for the configuration file of the wic command: if you search in the yocto tree or look at the logs (use bitbake -D ... to get more logs), you will probably find a file name suffixed by .wks. This is the file of directives passed to wic.

    In yocto environment, wic can be used on the command line. For example, to get the manual overview:

    $ wic help overview
    
    
    NAME
        wic overview - General overview of wic
    
    DESCRIPTION
        The 'wic' command generates partitioned images from existing
        OpenEmbedded build artifacts.  Image generation is driven by
        partitioning commands contained in an 'Openembedded kickstart'
    [...]
    

    The --source option triggers a plugin. The manual is probably not up to date and you may need to go into the source code of the plugins (wic is written in python) which is located in something like: ...poky/scripts/lib/wic. There you will see, the code managing the "rootfs" plugin in partition.py. You will see that only a reduced set of file system types are supported. Hopefully, squashfs is part of them. Here is the code snippet managing it:

        def prepare_rootfs_squashfs(self, rootfs, oe_builddir, rootfs_dir,
                                    native_sysroot, pseudo):
            """
            Prepare content for a squashfs rootfs partition.
            """
            extraopts = self.mkfs_extraopts or '-noappend'
            squashfs_cmd = "mksquashfs %s %s %s" % \
                           (rootfs_dir, rootfs, extraopts)
            exec_native_cmd(squashfs_cmd, native_sysroot, pseudo=pseudo)
    
    

    The preceding shows that wic calls mksquashfs tool to build the file system.

    Example of howto.