OverlayFS on DietPi with LXDE

Hi everyone,

I looking for a tutorial (or something similar) which could help me to install a OverlayFS on a DietPi with LXDE.
Do you have any suggestions? For Raspbian I found someone, but no DietPi-specific.

I try to get a ReadOnly-DietPi (on Raspberry Pi 3B+) with a Desktop. Until now, I try it with a separate RW-Partition, but this don‘t fit for the job.

Thank you in advance

  • Cas

Many thanks for your report. Maybe you can have a look to following post.

https://dietpi.com/forum/t/samba-fails-on-ro-filesystem/4123/2

Unfortunaly, this solution isn‘t working for me. The Bash-Prompt changed to „(ro)“, but my changes taking place and I don‘t see the Overlay mounted.

The “install.sh” run trough without any error or warning. But No overlay-fs was mounted. Is there anything other to d then you write in the linked answer?

did you copied the code lines from GitHub into /root/.bashrc ??

For my system, this is working well

root@DietPi3:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            433M     0  433M   0% /dev
tmpfs            94M  1.7M   93M   2% /run
overlay         470M   88K  470M   1% /
tmpfs           470M   88K  470M   1% /overlay
/dev/mmcblk0p2   29G  1.5G   27G   6% /overlay/lower
tmpfs           470M     0  470M   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           470M     0  470M   0% /sys/fs/cgroup
tmpfs           2.0G  8.0K  2.0G   1% /tmp
tmpfs            50M   32K   50M   1% /var/log
/dev/mmcblk0p1  253M   64M  189M  26% /boot
tmpfs            94M     0   94M   0% /run/user/0
root@DietPi3:~#

I analyze the problem;

the init-bottom-overlay throw a error (hides by default) in line 16 (. /scripts/functions) because this folder isn’t existing.

Through this, no /overlay tree is created.

So, I’m stuck here. Do you have any idea where the /scripts/functions folder should be created?


Regarding to your question, the /root/.bashrc PS1-Setting is only alternating the “name” displayed in the bash, so this has in the end no effect to the system.

there you go

root@DietPi3:~# ls -ls /usr/share/initramfs-tools/scripts
total 36
12 -rw-r--r-- 1 root root 9828 Aug 23  2019 functions
 4 drwxr-xr-x 2 root root 4096 Jun 23 23:24 init-bottom
 4 drwxr-xr-x 2 root root 4096 Aug  4 23:51 init-top
 8 -rw-r--r-- 1 root root 5679 Feb  6  2019 local
 4 drwxr-xr-x 2 root root 4096 Aug  4 23:51 local-premount
 4 -rw-r--r-- 1 root root 3093 Feb  6  2019 nfs
root@DietPi3:~#

should be created during

apt install initramfs-tools

Ok, very much thanks so far.
I change the Line to this specific tree.
Now the scirpt tries to mount the overlay-folders (they where created), but the mount-command throws a warning, that the overlay-folders are not specified in the /etc/fstab (thats the point where the partitions hook to some tree).

Do you know where the fstab should be written or could post me the containing of your file here?

are you sure your install.sh was executed correctly? because you are missing all the steps done on the script like copy new hooks-overlay and init-bottom-overlay in place

hooks-overlay should contain the correct path to scripts/functions
https://github.com/chesty/overlayroot/blob/7bad57cebd601dd92f05bb63f7c94781d1223aaf/hooks-overlay#L3

. /usr/share/initramfs-tools/scripts/functions
. /usr/share/initramfs-tools/hook-functions

and init-bottom-overlay should do mounting as well as changing /etc/fstab
https://github.com/chesty/overlayroot/blob/7bad57cebd601dd92f05bb63f7c94781d1223aaf/init-bottom-overlay#L62

mount -n -o move ${rootmnt} /overlay/lower
mount -t overlay overlay -olowerdir=/overlay/lower,upperdir=/overlay/upper,workdir=/overlay/work ${rootmnt}

mkdir -p ${rootmnt}/overlay
mount -n -o rbind /overlay ${rootmnt}/overlay

# fix up fstab
cp ${rootmnt}/etc/fstab ${rootmnt}/etc/fstab.orig
awk '$2 != "/" {print $0}' ${rootmnt}/etc/fstab.orig > ${rootmnt}/etc/fstab
awk '$2 == "'${rootmnt}'" { $2 = "/" ; print $0}' /etc/mtab >> ${rootmnt}/etc/fstab

I’m not sure about this, but like I write above, I don’t get any error massage.

But, I can see, there is only deleting changes to my fstab-file… So I don’t think that the install.sh-script was executed correctly.

Last Message is that busybody was installed…

When I execute init-bottom-overlay directly (and adjust the path), I got the error-message before on the mount-commands. The fstab is rewritten (oder better: the line should be added) afterwards.

When I try the awk-command, nothing happens.

hi,

the install script is not doing any changes on /etc/fstab.
install.sh is just going to copy hooks-overlay as well as init-bottom-overlay in place.

https://github.com/chesty/overlayroot/blob/master/install.sh

cp hooks-overlay /etc/initramfs-tools/hooks/
cp init-bottom-overlay /etc/initramfs-tools/scripts/init-bottom/

So you need to check if the new files are copied correctly

Next to this some settings are done on

/boot/config.txt

It might be better to contact the maintainer of overlayroot if you have issues with running it. I installed it 3 times without issues now.

So I try it out with a vanilla dietpi (only install lxde, xorg and xinit), now it is all ok.

I have to look what my dietpi-system do at startup. Is there some Log or where you would assume to get the informations?

Until now, I have to say very much thanks for your advices and patience.

You could have a look into journalctl or dmesg to check what happen during boot

I tried the overlayroot project @ https://github.com/chesty/overlayroot.
I found it’s method of writing to the lower level via chroot too much of a PITA.

I ended up using instructions from https://www.domoticz.com/wiki/Setting_up_overlayFS_on_Raspberry_Pi.
It has overlayfs for /home and /var with everything else mounted readonly. A job at shutdown syncs /home and /var back to the lower filesystem. Some of the locations from the author’s git repo have moved. I did a git clone, and then used find to locate the missing files.
Next, I need to setup a periodic timer to sync; the system won’t be getting many orderly shutdowns once deployed.

well it depends on your needs. The overlayroot project will put the entire system into r/o mode. But if you still need some file system being permanent, indeed you might need to use a different way.

Most importantly the variable/volatile and temporary files are on an overlayfs or tmpfs, so /var /home /root should be fine to ha e zero disk I/O. Just keep in mind, when doing package upgrades, that /var needs to write through to disk at least for storing APT/dpkg status info.