I'm trying to build a read only version of raspbian using overlayfs, the kernel version my raspberry pi is running apparently doesn't include it i'm wondering how i can recompile my own kernel with overlayfs.
According to this Source:
Kernel version 3.18 and later, have the OverlayFS already on it.
However if you want to compile the kernel on your own following the aforementioned Source link.
The steps tend to be quite tedious, so it is good to perform it on a new SD card or make sure to back up the data from the old one.
For building a Read-Only version follow the steps on this Source:2
You can find the Pi kernel source here:
Note that's by default set to the 4.4 branch, but the latest is actually 4.9.
It will take a long time to compile on the Pi, although that may not be necessary if you can find the build tree for your current kernel...which as far as I am aware is not available via Raspbian, unfortunately. Cross-compiling is probably a better option...
The kernel I'm using definitely has
overlay.ko. It comes from the "firmware" repo:
The kernel is in
boot, you also need the directories from
rpi-update pulls from a slightly different repo, but that one has
overlay.ko as well. This would be the easiest method (
apt install rpi-update first).
Beware if you use any of these methods (building your own or pulling from a repo) then subsequent
apt upgrades will overwrite
/boot. My solution to this is to mount
/dev/mmcblk0p1 somewhere else, then the stuff that's written into
/boot is just a few wasted MB. However, that approach will be awkward with
rpi-update; you may be able to set
$BOOT_PATH first, or you could just mount it on
/boot temporarily. That partition isn't needed during runtime, it is just mounted for updates and so you can edit
config.txt easily, etc.
There are some caveats around about the latest kernel (as pulled by
rpi-update) being a bleeding edge (the Raspbian kernel lags behind a bit), but I have never suffered any grief from it. I am pretty sure most of the time the Raspbian kernel isn't any different, i.e., what's "bleeding edge" today will be used unchanged as the default kernel next month. Although that makes your missing module a bit odd...