Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7503

Troubleshooting • rpi-image-gen, rpi-imager and cloud_init customization integration issues

$
0
0
Hi!

I was not sure which board this belonged in, but starting here based on other threads i've read on similar topics. Please feel free to tell me to move to another board.

I am undertaking a project that is best served by a custom Raspberry OS image that can be deployed as many times as required with all the tools and configuration pre-set, rather than installing a stock image and customizing every time.

To achieve this I have been building my images using rpi-image-gen. Despite the learning curve after a few days I have an image with the required layers that seems to build successfully. The layers and hooks are far from perfect, but they appear to work.

To build the SD images I am using Raspberry Pi Imager. After reading the many threads on the topic regarding customizing local .img I have been upskilling on cloud_init and manifest files. The idea of course is that the final customization to add users, set the hostname, add the wifi is handled in the cloud_init side. Eventually this will be a shell-wrapper to rpi-imager --cli that works out and builds the relevant user-data and network-config should be based on a global database and the end use case. For now I am just doing it locally on my Mac (M3)

My custom image is based on trixie-minbase.yaml; the network-config and user-data cloud_init files were taken from the BOOT partition of an SD I imaged from a standard Rasperry Pi Imager Trixie image.

This is where I have hit issues - I am very new to all of this, so am more than likely doing something wrong and would appreciate any input. I can provide any logs or other data as required

1. I tried using the image.json manifest generated by rpi-image-gen and manually configuring through rpi-imager GUI. When the SD was built I didn't see any cloud_init files on the BOOT partition
2. I then used rpi-imager --cli from a terminal pointing to the user-data and network-config files - the resulting SD card had the meta-data, user-data and network-config as expected and the contents when looked at from the SD are as expected. I ran rpi-imager --cli --debug and the log file shows the following snippets

Code:

Applications/Raspberry\ Pi\ Imager.app/Contents/MacOS/rpi-imager --cli --cloudinit-userdata ~/Desktop/user-data --cloudinit-networkconfig ~/Desktop/network-config-home  --debug ~/rpi-image-work/artifacts/my_trixie.img /dev/disk4...setSrc: initFormat parameter: "cloudinit" -> _initFormat set to: "cloudinit"...Cloudinit: "#cloud-config\nmanage_resolv_conf: false\nhostname: MyHostName\n ..... enable_ssh: true\nssh_pwauth: false\nrpi:\n  interfaces:\n    serial: true\n"initFormat parameter: "cloudinit" -> _initFormat: "cloudinit"....Checking customization: config= false cmdline= false firstrun= false cloudinit= true initFormat= "cloudinit" isEmpty= false_customizeImage: _initFormat= "cloudinit" initCloud= true _cloudinit.isEmpty()= false...Write timing stats: writes= 199 syscall= 0 ms preHashWait= 137 ms postHashWait= 0 ms sync= 0 ms syncCount= 0 avgSize= 8192 KBWriteProgressWatchdog: Stopped
Given the above, I assume that the customizations are being picked up - the imaging seem to complete and is verified. When I boot the Pi with the SD card though, it boots to a login prompt - however, the hostname is as was set in the config/project.yaml file in rpi-image-gen; The Pi doesn't appear on the network, I can't ssh in or login with the username/password I set in the user-data file (taken from a working raspberry pi imager generated SD card)

Thinking the rpi-image-gen was the cause, I cleared out the config/project.yaml to just point to image: trixie-minbase.yaml, removing all customizations (hostname, etc) passing the device type on the rpi-image-gen build command line (IGconf_device_layer=rpi3)

Code:

$ sudo rm -rf work/*; time ./rpi-image-gen build -S ./myProject/ -c project.yaml -- IGconf_device_layer=rpi3 IGconf_image_name=project_Pi3_v0.1
when I did this, the Pi got a random hostname - pi3-ivzytc - and otherwise everything else was the same, no network, unable to login with my username/pass, no ssh (no network of course!)

i am not sure if it's relevant, when I review the recording I made of the boot, everything is [ OK ] ... the only thing of note I have seen so far is

systemd[ 1 ]: Hostname set to <pi3-ivzytc>
systemd[ 1 ]: Failed to open libbpf, cgroup BPF features disabled: Operation not supported

This is far from my area of expertise and I am on a rapid education here (and to be honest enjoying the process - so happy to learn!) but based on my reading on this topic so far, for example:
viewtopic.php?t=394061
https://github.com/raspberrypi/rpi-imag ... formats.md
https://github.com/raspberrypi/rpi-imag ... local_json
various GH issues but mostly https://github.com/raspberrypi/rpi-imag ... formats.md - is that systemd would inply firstrun.sh and given I don't have a firstun.sh that might explain the issues - but everything else here is set to use cloud_init

If i have missed something in the various posts, issues and documentation I sincerely appologise I've read so much in the last couple of days I've confused myself! so feel free to point me in the right direction to RTFM!

thanks in advance

**update** I’m using the latest Raspberry Pi imager for Mac - 2.0.6

Statistics: Posted by SockThief — Thu Feb 12, 2026 4:53 pm — Replies 3 — Views 93



Viewing all articles
Browse latest Browse all 7503

Trending Articles