1

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?

Rachid K.
  • 4,490
  • 3
  • 11
  • 30
EatTheGiant
  • 13
  • 1
  • 3

1 Answers1

1

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.

Rachid K.
  • 4,490
  • 3
  • 11
  • 30
  • I found this directory in /meta-yocto-bsp/wic and made some changes in beaglebone-yocto.wks file current code is following: `part /boot --source bootimg-partition --ondisk mmcblk0 --fstype=vfat --label boot --active --align 4 --fixed-size 32 --sourceparams="loader=u-boot" --use-uuid part / --source rootfs --ondisk sda --fstype=squashfs --label root --align 1024 --use-uuid bootloader --append="rootfstype=squashfs console=ttyS0,115200" ` I changed fstab as well, but after bitbake my root is still ext4. Am I missing something? – EatTheGiant Aug 18 '21 at 14:14
  • After bitbake there were no changes in the image, no tasks needed to be rerun . – EatTheGiant Aug 18 '21 at 14:25
  • I updated my answer to provide more information. You may be able to run wic directly on the command line passing to it the right parameters and config file. – Rachid K. Aug 18 '21 at 15:22
  • 1
    This all is true and very helpful especially the presentation you shared. Thank you for that. I found out that I didn't change correct file I believe it is suppose to be common.wks.inc and qemux86-directdisk.wks located at poky/scripts/lib/wic/canned-wks/. After cleaning images `bitbake -c clean ` and building `bitbake ` I got an error at common.wks.inc: SquashFS does not support LABEL. I managed to find actual patch for this https://www.mail-archive.com/openembedded-core@lists.openembedded.org/msg114885.html Code in partition.py is the same as you described above. – EatTheGiant Aug 19 '21 at 14:07
  • So far every part command I found with squashfs had --label so I don't think it's the real problem: `part / --source rootfs --ondisk mmcblk0 --fstype=squashfs --label root --align 1024` – EatTheGiant Aug 19 '21 at 14:28
  • 1
    I was able to build my project without --label argument, so far it's working as it should be. Thanks! – EatTheGiant Aug 26 '21 at 16:53