Is it possible to use overlay on emmc?

Hi All,

On our device, we have 8GB emmc storage. We would like to use 1GB for overlay.
I try to use following command to create ext4 partition and hope procd will help me to mount overlay. But it did not.

mkfs.ext4 /dev/mmcblk0p8 -L rootfs_data

Is there any info/doc I can check to resolve this issue? Thanks.

Why use ext4? Why not use squashfs?

root=/dev/mmcblk1p4 rootfstype=squashfs,f2fs rootwait is in my command line to do this, I've got 4Gb eMMC on the device broken up into 3 900MB partitions and 1 1.2GB FAT partition to boot. squashfs just rolls the image out over the root partition as overlay. If you go with a ext4 rootfs, you're images will carry the compressed (empty) ext4 partition.

Hi Grommish,

Yes, my rootfs is squashfs. My bootargs is very similar with yours.
But, I expect my rootfs_data is ext4. I use it with overlay feature and we can write config on ext4.

squashfs just rolls the image out over the root partition as overlay.

I don't understand this, do you mean your rootfs_data is squashfs?

Seems like OpenWrt creates ext4 overlay:
https://git.openwrt.org/?p=project/fstools.git;a=blob;f=libfstools/rootdisk.c;hb=HEAD#l278
but as You can see the f2fs takes precedence. First, make sure You have ext4 support built in kernel. Second, remove mkf2fs package from Your image.
With both these conditions fulfilled, the ext4 overlay should work.
Disclaimer: personally never tried that.

nbg6817 would be a device with eMMC and ext4 based overlay (not exactly the best example, as it has to split a single partition into rootfs and overlay, due to the OEM partitioning choices, but still a working one).

Hi @tmn505

Thanks. I double check rootdisk.c in libfstool, openwrt try to mount loop device for overlay.
Openwrt did not check the volume name on ext4 partition, so the result like following output, am I right? What I expect is openwrt will help me to mount ext4 partition with volume name 'rootfs_data' to be overlay.

root@OpenWrt:/# mount
/dev/mmcblk0p3 on /rom type squashfs (ro,relatime)
none on /rom/dev type tmpfs (rw,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
cgroup on /sys/fs/cgroup type cgroup (rw,nosuid,nodev,noexec,relatime,cpu)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/loop0 on /overlay type ext4 (rw,noatime,data=ordered)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
/dev/mmcblk0p7 on /etc/factory type ext4 (ro,noatime,data=ordered)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)

Hi @slh

Thanks. The information of nbg6817 is useful, I will refer it to implement the upgrade script.

If you can, do it better - the nbg6817 is just constrained by the OEM partitioning choices. Using dedicated partitions for kernel, rootfs and overlay are a better choice, especially on devices with more than hundreds of MB free space.

Yes, we assign different partition for kernel/rootfs/overlay and even the cfg for factory production.
Thanks for the tips.

Hi @tmn505

loop0 device is very interesting. It can save my changes even I reboot/power off/on the device.
Do you know why? What cmd/info I can make sure the loop0 device bind to my partition?
Thanks.

Hi @Grommish

I think I understand what I mentioned. Openwrt will mount overlay with loop0 and loop0 is bind my squashfs partition.

root@OpenWrt:/sys/devices/virtual/block/loop0/loop# cat backing_file 
/mmcblk0p3
root@OpenWrt:/sys/devices/virtual/block/loop0/loop# mount
/dev/mmcblk0p3 on /rom type squashfs (ro,relatime)
none on /rom/dev type tmpfs (rw,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
cgroup on /sys/fs/cgroup type cgroup (rw,nosuid,nodev,noexec,relatime,cpu)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/loop0 on /overlay type ext4 (rw,noatime,data=ordered)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
/dev/mmcblk0p7 on /etc/factory type ext4 (ro,noatime,data=ordered)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)

This is quite interesting. My squashfs is read-only, but loop0 can save my changes. Do you know why?
Please help. Thanks.

Hi @Grommish and @tmn505

Looks like openwrt use ioctl to make a offset on squashfs partition and create a loop device for overlay.

1 Like

Hi All,

I follow this page to change fstool and make it read volume name to mount overlay.
Thanks.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.