-
Notifications
You must be signed in to change notification settings - Fork 99
doc: add a guide on getting started using configuration files #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
johanehnberg
wants to merge
10
commits into
raspberrypi:master
Choose a base branch
from
johanehnberg:doc/gettingstarted
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7d07357
doc: add a guide on getting started using configuration files
johanehnberg 014f4c0
Add README link to getting started, and fix code highlight
johanehnberg 9c7aeda
Add simple wifi configuration as example use case
johanehnberg 723c49b
Consolidate paths, conventions, and file names used
johanehnberg a15e4b1
Add default wifi config
johanehnberg f3d21cc
Improve based on PR feedback and further testing
johanehnberg f12bf6b
Layout and heading polish
johanehnberg 02e4b6c
Use source directory instead of assetdir, can instead of <, and fix p…
johanehnberg 516b365
Update getting started doc for terminology and PR decay
johanehnberg a0b6970
Fix use case descriptions and minimize dependencies from assumed usef…
johanehnberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| = Getting Started | ||
|
|
||
| This guide aims to get you started on building your own custom image using `rpi-image-gen` configs, without yet defining your own layers. | ||
|
|
||
| == Requirements | ||
|
|
||
| * The build environment needs 2GB RAM or more for tmpfs | ||
| - RPi4 or later if building on RPi | ||
| - Building with foreign dpkg operation support on a workstation or build server | ||
| * The build environment needs 4GB storage or more for build artefacts and images | ||
| - 8GB SD card is the absolute minimum when building on RPi, but larger is needed for bigger images | ||
| * The build target can be any Raspberry Pi, but all features are available only on RPi4 or later | ||
| - When building for older targets, some layers will not work | ||
|
|
||
| == Building on Ubuntu or Debian amd64 | ||
|
|
||
| While not officially supported, cross building works well on a recent Debian or Ubuntu amd64. In lieu of the quick start, use the following: | ||
|
|
||
| [,sh] | ||
| ---- | ||
| sudo apt-get -q -y --no-install-recommends install binfmt-support qemu-user-static debian-archive-keyring git | ||
| git clone https://github.com/raspberrypi/rpi-image-gen.git | ||
| cd rpi-image-gen | ||
| sudo ./install_deps.sh | ||
| ---- | ||
|
|
||
| This will: | ||
|
|
||
| * Install foreign dpkg operation support and further host dependencies | ||
| * Install Debian keyring from package on Ubuntu | ||
|
|
||
| == Define Your Image | ||
|
|
||
| We will build three images starting with a single image for a single device. Then we use includes to show how you can define multiple images to manage your whole landscape. In this example, we will assume you have various RPi generations deployed across different locations serving as simple SSH servers on wifi. | ||
|
|
||
| === Project Setup | ||
|
|
||
| Let's set up a simple project that includes a configuration file and a script to run installation. | ||
|
|
||
| [,sh] | ||
| ---- | ||
| mkdir -p myproject/bdebstrap | ||
| echo -e 'ClientAliveInterval 60' > myproject/sshdkeepalive.conf | ||
| echo -e '#!/bin/bash\n\nset -eu\n\nchroot $1 sh -c "apt-get -y install network-manager"\ncp ../sshdkeepalive.conf $1/etc/sshd_config.d/\nchroot $1 sh -c "nmcli --offline connection add type wifi ssid $SSID wifi-sec.psk $PSK wifi-sec.key-mgmt wpa-psk autoconnect yes > /etc/NetworkManager/system-connections/$SSID.nmconnection"\nchroot $1 sh -c "chmod 600 /etc/NetworkManager/system-connections/$SSID.nmconnection"' > myproject/bdebstrap/customize90-myscript | ||
| chmod 755 myproject/bdebstrap/customize90-myscript | ||
| ---- | ||
|
|
||
| === A Simple Base Configuration | ||
|
|
||
| Now create the base config file called `myimage.yaml` in `myproject` with the following content: | ||
|
|
||
| [,yaml] | ||
| ---- | ||
| device: | ||
| user1: myuser | ||
| user1pass: Fo0bar!! | ||
| layer: rpi5 | ||
|
|
||
| image: | ||
| layer: image-rpios | ||
| boot_part_size: 128M | ||
| root_part_size: 1536M | ||
|
|
||
| ssh: | ||
| pubkey_user1: $(cat ${HOME}/.ssh/id_rsa.pub) | ||
| pubkey_only: y | ||
|
|
||
| packages: | ||
| - wpasupplicant | ||
|
|
||
| env: | ||
| SSID: default | ||
| PSK: 12345678 | ||
| ---- | ||
|
|
||
| Ensure you have an SSH key on the build host, or remove the pubkey_user1 line. Go ahead and build using the instructions below. This will already produce a bootable image, and the config will serve a shared base. | ||
|
|
||
| === Adding Image Identities | ||
|
|
||
| Create a file called `myimage-location1.yaml` in `myproject` with the following content: | ||
|
|
||
| [,yaml] | ||
| ---- | ||
| include: | ||
| file: myimage.yaml | ||
|
|
||
| device: | ||
| hostname: location1 | ||
|
|
||
| env: | ||
| SSID: localssid | ||
| PSK: localpsk | ||
| ---- | ||
|
|
||
| This will define an image with a hostname specific to the location and override the wifi configuration. Again, you can build this and it will work if your device happens to be the same as in the main yaml. | ||
|
|
||
| === Adding Device Specifications | ||
|
|
||
| Create a file called `myimage-location1-rpi3.yaml` in `myproject` with the following content: | ||
|
|
||
| [,yaml] | ||
| ---- | ||
| include: | ||
| file: myimage-location1.yaml | ||
|
|
||
| device: | ||
| layer: rpi3 | ||
| ---- | ||
|
|
||
| Building this will produce the specific image for the device you are deploying to location1 at the time. Here we override the rpi5 default. | ||
|
|
||
| == Build Your Image | ||
|
|
||
| Once your image configuration is ready, you can build everything with specifying just one configuration file. `customize90-myscript` will be automatically included based on its name, executability and location in relation to the `-S` source directory flag. Change `myimage.yaml` to `myimage-location1.yaml` and `myimage-location1-rpi3.yaml` to build the more specific images. | ||
|
|
||
| [,sh] | ||
| ---- | ||
| ./rpi-image-gen build -S myproject/ -c myproject/myimage.yaml | ||
|
johanehnberg marked this conversation as resolved.
|
||
| ---- | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.