genimage icon indicating copy to clipboard operation
genimage copied to clipboard

Filesystem overlays

Open Harvie opened this issue 2 years ago • 1 comments

I think it would be really beneficial to allow filesystems to be overlayed.

For example, currently if you want to build ext4, you use something like this:

image rootfs2.ext4 {
  ext4 {}
  mountpoint = "/"
}

But what i actualy need for serious work is bit different. Eg. i have following directories

  • root - containing complete userspace from debootstrap
  • overlay_generic - containing some files that i want to replace in all devices, eg. custom /etc/ssh/sshd_config
  • overlay_alice - containing device specific stuff, eg. /etc/hostname = alice
  • overlay_bob - containing device specific stuff, eg. /etc/hostname = bob

Then i would want to do something like this:

image generic.img {
  ext4 {}
  overlay_dirs {
    "root"
    "overlay_generic"
  }
}

image alice.img {
  ext4 {}
  overlay_dirs {
    "root"
    "overlay_generic"
    "overlay_alice"
  }
}

image bob.img {
  ext4 {}
  overlay_dirs {
    "root"
    "overlay_generic"
    "overlay_bob"
  }
}

So that i will only need to build one debootstrap chroot and then copy it to all of my ext4 images. without having to manage several copies of the chroot. Then apply/copy the overlays over it in exact order as specified in genimage.cfg, assuming that the files from later overlay will overwrite the files in former.

BTW This is probably related to #181 which points out that genimage is dogmaticaly stuck on some "root path" concept, which often does not reflect reality of embedded development very well. Project structure tends to be more complex than just having one root that contains everything. I suggest not to force such concept and leave the directory structure up to users.

Harvie avatar Mar 18 '22 14:03 Harvie

Tools like mke2fs only accept one directory for root. So at some point, all those directories must be copied together. I think that's out of scope for genimage. But with #184 you could probably do it in a exec-pre command.

michaelolbrich avatar Mar 21 '22 09:03 michaelolbrich