The overall explanation of the overlayFS capability is here.
Referring to the manual for mount, the overlay mount command is:
$ mount -t overlay overlay -olowerdir=/,upperdir=/mnt/upper,workdir=mnt/work /merged
There are many references for using overlayFs including this and this. :=
However, there is a yocto script for installing the overlay here. The recipe sets up a writable root file system overlay on top of a read-only root file system. It is installed using:
BBLAYERS: add /path to layers/meta-readonly-rootfs-overlay
IMAGE_INSTALL_append = “ initscripts-readonly-rootfs-overlay”
Create and install the image
After bootup, locate the script “init” in the root directory and change ROOT_RWDEVICE=”/dev/mmcblk0p1”
Reboot.
However, this does not work as follows:
root@colibri-imx6ull:~# df -h
Filesystem Size Used Available Use% Mounted on
ubi0:rootfs 435.0M 150.7M 284.3M 35% /
# opkg install git mosquitto mosquitto-clients ffmpeg nodejs nodejs-npm
Filesystem Size Used Available Use% Mounted on
ubi0:rootfs 435.0M 227.6M 207.4M 52% /
Note that the rootfs is still only 435 MB and the /dev/mmcblk0p1 is unused.
To identify the error, I try to use the script manually as follows:
I use a fresh image with filesystem extract as shown:
root@colibri-imx6ull:~# df
Filesystem 1K-blocks Used Available Use% Mounted on
ubi0:rootfs 445440 89364 356076 20% /
/dev/mmcblk0p1 29766716 44988 28186600 0% /media/mmcblk0p1
root@colibri-imx6ull:~# ls /media
mmcblk0p1
root@colibri-imx6ull:~# ls /mnt
root@colibri-imx6ull:~#
root@colibri-imx6ull:~# ls /
bin boot dev etc home lib media mnt proc run sbin sys tmp usr var
####make directories and mount root filesystem to new mount point####
$ mkdir -p /media/ro /media/rw
$ mount -o bind / /media/ro
root@colibri-imx6ull:/# ls /media/ro
bin boot dev etc home lib media mnt proc run sbin sys tmp usr var
####mount the read-write filesystem####
$ mount -o rw,noatime,mode=755 /dev/mmcblk0p1 /media/rw
New filesystem extract as follows:
root@colibri-imx6ull:/# df -h
Filesystem Size Used Available Use% Mounted on
ubi0:rootfs 435.0M 80.0M 355.0M 18% /
/dev/mmcblk0p1 28.4G 43.9M 26.9G 0% /media/mmcblk0p1
ubi0:rootfs 435.0M 80.0M 355.0M 18% /media/ro
/dev/mmcblk0p1 28.4G 43.9M 26.9G 0% /media/rw
/dev/mmcblk0p1 28.4G 43.9M 26.9G 0% /media/ro/media/rw
root@colibri-imx6ull:/#
create overlay file systems
$ mkdir -p /media/rw/upperdir /media/rw/work
root@colibri-imx6ull:/# ls /media/rw
upperdir work
####mount the overlay filesystem ####
$ mount -t overlay overlay -o lowerdir=/media/ro,upperdir=/media/rw/upperdir,workdir=/media/rw/work /mnt
The new filsystem looks like this:
root@colibri-imx6ull:/# df -h
Filesystem Size Used Available Use% Mounted on
ubi0:rootfs 435.0M 80.0M 355.0M 18% /
/dev/mmcblk0p1 28.4G 43.9M 26.9G 0% /media/mmcblk0p1
ubi0:rootfs 435.0M 80.0M 355.0M 18% /media/ro
/dev/mmcblk0p1 28.4G 43.9M 26.9G 0% /media/rw
/dev/mmcblk#0p1 28.4G 43.9M 26.9G 0% /media/ro/media/rw
overlay 28.4G 43.9M 26.9G 0% /mnt
overlay 28.4G 43.9M 26.9G 0% /media/ro/mnt
root@colibri-imx6ull:/# ls /mnt
bin boot dev etc home lib media mnt proc run sbin sys tmp usr var
root@colibri-imx6ull:/# ls /media/rw
upperdir work
root@colibri-imx6ull:/# ls /mnt/media/rw
root@colibri-imx6ull:/#
root@colibri-imx6ull:/# ls /mnt/media
mmcblk0p1 ro rw
Move ro and rw root file system into the overlay file system####
root@colibri-imx6ull:/# mount -n --move /media/ro /mnt/media/ro
This gives the follwing error:
mount: /mnt/media/ro: bad option; moving a mount residing under a shared mount is unsupported.
The above error stops going any further.
Remaining commands:
$ mount -n --move /media/rw /mnt/media/rw
$ mount -n --move /proc /mnt/proc
$ mount -n --move /sys /mnt/sys
$ mount -n --move /dev /mnt/dev
$ cd /mnt
# switch to actual init in the overlay root file system
$ exec chroot /mnt /sbin/init
I don’t know how to proceed. If you are successful, then let me know.