Coder Social home page Coder Social logo

cmhe / meta-readonly-rootfs-overlay Goto Github PK

View Code? Open in Web Editor NEW
52.0 6.0 49.0 18 KB

This layer is no longer maintained by me. Marcus Folkesson offered to take over the maintainership in: https://github.com/marcusfolkesson/meta-readonly-rootfs-overlay

License: MIT License

BitBake 14.50% Shell 77.36% C++ 8.14%

meta-readonly-rootfs-overlay's Introduction

meta-readonly-rootfs-overlay

This OpenEmbedded layer provides the necessary scripts and configurations to setup a writable root file system overlay on top of a read-only root file system.

Why does this exists?

Having a read-only root file system is useful for many scenarios:

  • Separate user specific changes from system configuration, and being able to find differences
  • Allow factory reset, by deleting the user specific changes
  • Have a fallback image in case the user specific changes made the root file system no longer bootable.

Because some data on the root file system changes on first boot or while the system is running, just mounting the complete root file system as read-only breaks many applications. There are different solutions to this problem:

  • Symlinking/Bind mounting files and directories that could potentially change while the system is running to a writable partition
  • Instead of having a read-only root files system, mounting a writable overlay root file system, that uses a read-only file system as its base and writes changed data to another writable partition.

To implement the first solution, the developer needs to analyse which file needs to change and then create symlinks for them. When doing factory reset, the developer needs to overwrite every file that is linked with the factory configuration, to avoid dangling symlinks/binds. While this is more work on the developer side, it might increase the security, because only files that are symlinked/bind-mounted can be changed. However, IMO that is better left to file permissions.

This meta-layer provides the second solution. Here no investigation of writable files are needed and factory reset can be done by just deleting all files or formatting the writable volume.

Dependencies

This layer depends on:

  URI: git://git.openembedded.org/bitbake
  branch: krogoth
  URI: git://git.openembedded.org/openembedded-core
  layers: meta
  branch: krogoth

Patches

Please submit any patches against the readonly-rootfs-overlay layer via pull request.

Table of Contents

  1. Adding the readonly-rootfs-overlay layer to your build
  2. Read-only root filesystem
  3. Kernel command line parameters

Adding the readonly-rootfs-overlay layer to your build

In order to use this layer, you need to make the build system aware of it.

Assuming the readonly-rootfs-overlay layer exists at the top-level of your OpenEmbedded source tree, you can add it to the build system by adding the location of the readonly-rootfs-overlay layer to bblayers.conf, along with any other layers needed. e.g.:

  BBLAYERS ?= " \
    /path/to/layers/meta \
    /path/to/layers/meta-poky \
    /path/to/layers/meta-yocto-bsp \
    /path/to/layers/meta-readonly-rootfs-overlay \
    "

To add the script to your image, just add:

  IMAGE_INSTALL_append = " initscripts-readonly-rootfs-overlay"

to your local.conf or image recipe. Or use core-image-rorootfs-overlay-initramfs as initrd.

Read-only root filesystem

If you use this layer you do not need to set read-only-rootfs in the IMAGE_FEATURES or EXTRA_IMAGE_FEATURES variable.

Kernel command line parameters

These examples are not meant to be complete. They just contain parameters that are used by the initscript of this repository. Some additional paramters might be necessary.

Example using initrd:

root=/dev/sda1 rootrw=/dev/sda2

This cmd line start /sbin/init with the /dev/sda1 partition as the read-only rootfs and the /dev/sda2 partition as the read-write persistent state.

root=/dev/sda1 rootrw=/dev/sda2 init=/bin/sh

The same as before but it now starts /bin/sh instead of /sbin/init.

Example without initrd:

root=/dev/sda1 rootrw=/dev/sda2 init=/init

This cmd line starts /sbin/init with /dev/sda1 partition as the read-only rootfs and the /dev/sda2 partition as the read-write persistent state. When using this init script without an initrd, init=/init has to be set.

root=/dev/sda1 rootrw=/dev/sda2 init=/init rootinit=/bin/sh

The same as before but it now starts /bin/sh instead of /sbin/init

Details

root= specifies the read-only root file system device. If this is not specified, the current rootfs is used.

rootfstype= if support for the read-only file system is not build into the kernel, you can specify the required module name here. It will also be used in the mount command.

rootoptions= specifies the mount options of the read-only file system. Defaults to noatime,nodiratime.

rootinit= if the init parameter was used to specify this init script, rootinit can be used to overwrite the default (/sbin/init).

rootrw= specifies the read-write file system device. If this is not specified, tmpfs is used.

rootrwfstype= if support for the read-write file system is not build into the kernel, you can specify the required module name here. It will also be used in the mount command.

rootrwoptions= specifies the mount options of the read-write file system. Defaults to rw,noatime,mode=755.

rootrwreset= set to yes if you want to delete all the files in the read-write file system prior to building the overlay root files system.

meta-readonly-rootfs-overlay's People

Contributors

cmhe avatar rettichschnidi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

meta-readonly-rootfs-overlay's Issues

Merge on shutdown / reboot

Thank you for this great layer.
When using your layer to create a RAMdisk on startup with an underlying read only rootfs is there a chance to merge both layers on a regular shutdown or reboot?

mounting using PARTUUID create rootfs mount issue on /media/rfs/to moint point

Hi,
I am currently working on core-image-minimal to provide support of the read-only file system using squashfs and for make it writable using overlayfs. I come across this yocto layer and integrated the changes with core-image-minimal-initramfs.bbappend file by using below lines


->Remove unwanted scripts from poky
PACKAGE_INSTALL_remove = " ${INITRAMFS_SCRIPTS}"

->Only add rootfs-ovelay mounting initrdscript
PACKAGE_INSTALL_append = " initramfs-readonly-rootfs-overlay"


The image was built successfully and the kernel is also start loading with customize initramfs.
But suddenly when mounting of squashfs rootfs event occurred using PARTUUID it goes failed to mount(as my /proc/cmdline have root=PARTUUID=xxxx).

instead of using PARTUUID if I use /dev/sdX MANUALLY then mount process gone perfectly on /media/rfs/ro dir.

Why PARTUUID is not working over here?

How to get this to work?

Hello,

I'm afraid I have a some questions concerning this layer I can't figure out. I would appreciate every little help to make me understand how this works.

I have implemented this layer into my build. As far as I understand this layer and the recipes, everything is where it's supposed to be. But there is no overlay magically appearing, which honestly I expected since I don't understand these things:

  1. How, when and by whom is the initscript which ends up as /init executed? I believe it's not executed on my build.

  2. Is my assumption right that when I get the initscript to execute correctly, that there will only be a volatile rw overlay partition? Since there is no rootrw specified. This is what the example image is doing, right?

  3. If I want a non-volatile rw partition, I need to explicitly create it, and set rootrw in the kernel cmdline? There is no example how to do that? Would you recommend creating the partition with a custom wic script? And would you also use this wic script to set the kernel command line parameters?

Thanks,
Michael

Can't use jffs2 for rw filesyste,

Hi,

I tried using your layer with a JFFS2 rw filesystem, however it fails because you have to specify the filesystem type when mounting JFFS2 (i.e. "mount -t jffs2 ...").

Thanks
Phil

Cant build image with this layer in YOCTO

Hi, i need some help building this to my raspberry pi image in yocto. I understand that this layer runs on branch krogoth, but when i start a build with master branch, the command line tells me that this layer only works with the hardknott branch of open-embedded core. I cant change to krogoth branch because i have incompatibilities with python 2 scripts, running over python 3.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.