0

I work on an embedded system which boots from a SquashFS image located on a UBIFS formatted SPI flash. I added OverlayFS over / (root) support so that we can change all the files around but get them reset after reboot. All the OverlayFS magic is performed in initramfs. When setting up all the mountpoints, I mount --move /run and the UBIFS flash partition. I want to know whether I should mount --move the upper/lower/workdir of the OverlayFS to the new root too before switch_root. It does seem to work without it, but once in a while I get spontaneous reboots and a bus error on a manual reboot.

c_spk
  • 169
  • 16

1 Answers1

0

What tools do you have in your initramfs? Why not use busybox's switch_root or klibc's run-init, which does all the needed moving (from what I gather [0] [1])?

So to answer your question, by using the right tool, you not need to worry about using mount --move at all. If you insist however on manually doing it, do what these tools do.

[0] http://man7.org/linux/man-pages/man8/switch_root.8.html

[1] https://git.busybox.net/busybox/tree/klibc-utils/run-init.c

oliver
  • 761
  • 6
  • 4
  • If you mount your ro, overlay, combined filesystem to` /new_root` and mount on top (or move) `/run`, `/dev` etc whatever else you need for the minimal fs; you can just call `run-init` or `switch_root` to switch over to your new root and boot init from there. You do not need to `mount --move /new_root /` to do the switch, as you then loose control and have a hard time to launch init anyway. So use the tools that are there for this exact purpose. – oliver Jun 08 '21 at 13:12