Coder Social home page Coder Social logo

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

View Code? Open in Web Editor NEW

This project forked from cmhe/meta-readonly-rootfs-overlay

0.0 0.0 0.0 18 KB

This yocto meta layer implements a read-only root filesystem with a writable 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

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.