znailnetem / znail

Network emulator intended to run on a Raspberry Pi.
Apache License 2.0
16 stars 3 forks source link

Fix building of rpi image from scratch #5

Closed Risca closed 3 years ago

Risca commented 3 years ago

Also move the image files to dist/image/

Risca commented 3 years ago

I had a strange issue with the pi-gen scripts:

[13:39:02] Begin /pi-gen/export-image
[13:39:02] Begin /pi-gen/export-image/prerun.sh
losetup: /pi-gen/work/2021-08-18-znail/export-image/2021-08-18-znail-lite.img: failed to set up loop device: No such file or directory

The issue magically disappeared when I added

set -x

to pi-gen/export-image/prerun.sh :man_shrugging:

That's unrelated to this pull request anyway

andni233 commented 3 years ago

Nice!

I havent had time to test but my gut feeling is that the loopback issue happens when there are no unused loopback devices available. losetup will then create a new one, that does not immediately become visible inside the Docker container where the build happens. Notably the new loopback device sticks around, so the next time the build runs a free device is available and it can proceed.

Assuming this is the case: I think the solution is to make sure there is a free loopback device available before starting the RPi build, or have Docker mount the hosts /dev filesystem into the container. The later is a little bit dangerous :)