arist0v
Posts: 3
Joined: Fri Aug 05, 2022 10:26 am

Network imaging

Fri Aug 05, 2022 10:37 am

Hello, with the new beta bootloader, i saw we can boot ramdisk to flash the sd card.

For our project(https://www.candlesmarthome.com/)

We would like to automate an image creation project.
To do this i will need to do the following steps:
-remotely flash a fresh raspbian lite 32bit
-edit cmdline.txt
-boot it and run script
-boot on network to create a .img from the sdcard

Is the new bootloader can help me with that?

Is there any other way possible?

I googled a lot and didn't find a way currenty

Thank you

schufti
Posts: 23
Joined: Mon Jun 25, 2012 9:30 pm

Re: Network imaging

Fri Aug 05, 2022 7:41 pm

that sounds like the wet dream of every (virus) skript kiddy ...

trejan
Posts: 4742
Joined: Tue Jul 02, 2019 2:28 pm

Re: Network imaging

Fri Aug 05, 2022 8:12 pm

If you set a custom imager repo URL in the bootloader configuration for each Pi then you can make it download + write your custom image. You'd need to set this up on each Pi you sell.

arist0v
Posts: 3
Joined: Fri Aug 05, 2022 10:26 am

Re: Network imaging

Fri Aug 05, 2022 8:28 pm

trejan wrote:
Fri Aug 05, 2022 8:12 pm
If you set a custom imager repo URL in the bootloader configuration for each Pi then you can make it download + write your custom image. You'd need to set this up on each Pi you sell.
Thank you @trejan, this is a good start but maybe some stuff wasn'T clear.

this feature is needed for developpement /build production and not for acutal end user.

the goal is:

having a raspberry as build machine

beeing able to boot from network without keyboard interaction

then i could, with your bootloader repo url, have a specific image run that will achieve the rest of the target.

so with the custom repo url, did i still need to have a screen and keyboard? or i could just start the pi with an empty sd card, and it will build the pi, with my image from ramdisk, and then the image will auto execute the build script to create, and push the image on a ftp or similar?

trejan
Posts: 4742
Joined: Tue Jul 02, 2019 2:28 pm

Re: Network imaging

Fri Aug 05, 2022 9:11 pm

arist0v wrote:
Fri Aug 05, 2022 8:28 pm
so with the custom repo url, did i still need to have a screen and keyboard?
You need a keyboard. Monitor is probably optional but I've never tried it. It may object to not having any framebuffer.
arist0v wrote:
Fri Aug 05, 2022 8:28 pm
or i could just start the pi with an empty sd card, and it will build the pi, with my image from ramdisk, and then the image will auto execute the build script to create, and push the image on a ftp or similar?
You'd need to alter the Raspberry Pi OS image to do all of that at first boot. There is no provision for doing what you want with the customisation and then saving a copy of its own SD card.

Generating your card images by automatically booting a Pi, customising it and then saving the card is an unusual workflow. If you're not meticulous about tidying up then you'll end up with lingering bits of junk like pregenerated SSH host keys. The normal route would be to customise pi-gen to directly create your image.

bls
Posts: 2498
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: Network imaging

Fri Aug 05, 2022 10:02 pm

trejan wrote:
Fri Aug 05, 2022 9:11 pm
Generating your card images by automatically booting a Pi, customising it and then saving the card is an unusual workflow. If you're not meticulous about tidying up then you'll end up with lingering bits of junk like pregenerated SSH host keys. The normal route would be to customise pi-gen to directly create your image.
Agree. Seems like pi-gen (as you suggest) or systemd-nspawn (to update/configure a "standard" RasPiOS image) are much better approaches.
Pi tools:
Quickly and easily build customized exactly as-you-want SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure IPSEC/IKEV2 VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

arist0v
Posts: 3
Joined: Fri Aug 05, 2022 10:26 am

Re: Network imaging

Fri Aug 05, 2022 10:23 pm

Thank you, i take a look at it, it seem to ve what i need!

bls
Posts: 2498
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: Network imaging

Fri Aug 05, 2022 10:27 pm

arist0v wrote:
Fri Aug 05, 2022 10:23 pm
Thank you, i take a look at it, it seem to ve what i need!
If you're OK starting with the images from Raspberrypi.com, you could use sdm, which uses systemd-nspawn to enable you to fully customize an existing "vanilla" RasPiOS IMG. You don't have the same fine-grained control over the IMG contents as pi-gen, but if you don't need that level of control, sdm seems to be easier for new customizers than pi-gen.
Pi tools:
Quickly and easily build customized exactly as-you-want SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure IPSEC/IKEV2 VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

Return to “Raspberry Pi OS”