yoctopartitionrootfsyocto-wic

Create an image with a read write partition using a Read-only file-system on yocto


I've build a Linux image with Yocto Poky kirkstone (4.0.2) for corei7-64-poky-linux 'core-image-minimal'.

rootfs is mounted on RAM as read-only using:

IMAGE_FEATURES += "read-only-rootfs"

I'm now trying to create a new rw partition ( mounted on /usr/local) (or a RO that can be remount as RW) to store and update my application when needed.

I tried to add my own fstab using a base-files/base-files_%.bbappend (https://stackoverflow.com/a/47250915/2482513) , and adding something like:

/usr/local           /usr/local           ext2       defaults,rw           0  0 

But this doesn't work, I can see my custom fstab (/etc/fstab) on the target, but it seems that it is not used at all.

mount -v shows:

proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
devtmpfs on /dev type devtmpfs (rw,relatime,size=852628k,nr_inodes=213157,mode=755)
/dev/loop0 on / type ext4 (ro,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /var/volatile type tmpfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /var/lib type tmpfs (rw,relatime)

I suspect yocto is using recipes-core/initrdscripts/files/init-install.sh or something similar instead of my custom fstab. This link https://www.digi.com/resources/documentation/digidocs/embedded/dey/3.2/cc8x/yocto_t_read-only-rootfs suggest to use volatile blinds on a read-write partition, but doesn't explain how to create that read-write partition as part of my image.

I found people using wks files to create partition in the final wic image, but I'm using hddimg (IMAGE_FSTYPES += " hddimg") for compatibility with the hardware bootloader, so I'm not sure this could work, or how to make it work. Yocto - Create and populate a separate /home partition

I'm new to all of this, so thank you in advance for your help.


Solution

  • Turns out that I didn't need hddimg, you can simply create a wic image that can boot with a legacy bios using the bootimg-pcbios option:

    part /boot --source bootimg-pcbios --sourceparams="loader=systemd-boot,initrd=microcode.cpio" --ondisk sda --label msdos --active --align 1024 --use-uuid