Implement a factory reset image feature. We\'ll use one of the union mount technologies (aufs/overlayfs/union mounts) to create an overlay on the file system as the final piece of rootfs creation. The overlaid file-system will be the target of all writes made to the image after the image is generated. A user-space mechanism to disable the overlay, and therefore reset to the state of the image just after it was created, will also be provided. This feature could be further enhanced by integrating with the package manager, and other user-space switches, to create system restore points which can later be rolled back to.
There are another option to don't depend on filesystem but it requires partition support in Yocto that now is done by Openembedded wic tool. Example of the partition/disk, - Bootloader - Linux Recovery OS (Minimal) - Linux RW - Linux RO The Bootloader need to have a mechanism (store some value on disk?) to detect when a factory reset is needed and if factory reset is needed boot Linux recovery OS if not set boots the Linux RW. The Linux Recovery OS reads the RO partition and then writes into RW and then reset. The settings for the factory reset/partition schema needs to be specified at level of configuration.
Created attachment 2479 [details] Design
Below is an article I read some time ago. http://0pointer.net/blog/projects/stateless.html I know it's based on systemd, and our project provides both sysvinit and systemd, but I think its approach is somewhat interesting. Note that the whole implementation is on the filesystem level. Hope it would provide some useful information. //Chen Qi
Support for stateless is tracked in bug #9527.
There are a number of layers which implement this. Please look to them for solutions: http://layers.openembedded.org/layerindex/branch/master/layer/meta-mender-core/ http://layers.openembedded.org/layerindex/branch/master/layer/meta-resin-common/ http://layers.openembedded.org/layerindex/branch/master/layer/meta-swupdate/ http://layers.openembedded.org/layerindex/branch/master/layer/meta-updatehub/