Raspberry Pi Aims for More Flexible OS Configuration with a Move to Cloud-Init

The old firstrun.sh script is going away, in favor of YAML-flavored configuration files for a more robust, cross-distribution approach.

Gareth Halfacree
2 hours agoHW101 / Productivity

Raspberry Pi has announced plans to migrate away from its existing in-house operating system customization approach — a simple shell script dubbed firstrun.sh — towards cloud-init, and has published guidance on how users can try it out now.

"As some of you may have already noticed, the latest Raspberry Pi OS release based on Debian Trixie now includes cloud-init," Raspberry Pi's Paul Oberosler explains. "This marks the beginning of a transition away from our legacy first-boot customization system based on the firstrun.sh script. Cloud-init is a cross-platform, distribution-agnostic tool used to automatically configure systems on first boot. (Definition adapted from the official cloud-init documentation.) With it, you can provision your Raspberry Pi images with users, network settings, SSH keys, storage configurations, and much more — all without manually logging in after flashing the image."

Born from the community-driven Raspbian Linux distribution, Raspberry Pi OS takes Debian Linux and customizes it for the company's eponymous single-board computer and computer-on-module families. Part of this includes performing tasks on first boot, including resizing the partitions to fill storage, which was traditionally carried out using an in-house script called firstrun.sh. Anyone looking to do their own customization on first boot could edit this script, and while that's still supported for now the company is moving towards a more robust and cross-platform approach: cloud-init.

In a cloud-init system three YAML-format configuration files are placed in the boot partition, accessible from any Linux, Windows, or macOS machine: meta-data, network-config, and user-data. The last two are the interesting ones, allowing the user to set up a default set of users and home folders, configure the Wi-Fi and wired networks, set up SSH access, and — thanks to some handy extensions — set up Raspberry Pi-specific features like I2C, SPI, UART buses, and USB Gadget mode.

"With the release of Raspberry Pi Imager 2.0, cloud-init configuration for Raspberry Pi OS is now generated by default," Oberosler says. "This makes it easy to further customize your setup after writing the image — simply edit the generated user-data or network-config files on the boot partition. Imager 2.0 also understands the Raspberry Pi–specific rpi: options, so features like SPI or I2C can be enabled directly in the customization UI. The legacy method still works, but cloud-init and Netplan open the door to a much more flexible and modern workflow. We'll continue expanding support for Raspberry Pi-specific cloud-init modules and streamlined provisioning features in future releases."

More information, including links to documentation, is available on the Raspberry Pi blog.

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles