Custom-built Raspberry Pi OS images
- Features
- Generate your custom images
- Configure your custom images
- Install your custom images to an SD card
- Custom Raspberry Pi OS images
- Custom APT sources (with GPG key and key server support)
- Custom pre-installed packages (from APT repositories, GitHub releases, and direct URLs)
- Custom boot command line options
- Custom boot configuration options
- Custom target build stage (default is
2
which results in thelite
image)
-
Fork this repository
-
Clone your fork
git clone https://github.com/<your-username>/raspbian-image-repository.git
-
Change
config/target-config.json
as per your requirements (See Configure your custom images section) -
Commit and push the changes
-
Go to
Actions
tab in your forked repository and selectGenerate image
workflow -
Click on
Run workflow
button, setImage target name
to the target name inconfig/target-config.json
-
Click on
Run workflow
button and wait for the workflow to complete -
Go to the
Releases
page -
Download the generated image
-
Install your custom images to an SD card (See Install your custom images to an SD card section)
The configuration file is located at config/target-config.json
. It contains a list of target configurations.
Each configuration has the following properties:
name
: The name of the configuration to use as a referenceversion
: The version of the configuration to distinguish between different versions of the same configurationreference
: The reference (tag or commit hash) of the official Raspberry Pi OS pi-gen repository to be used as a basestage
: The number of the target build stage to reach (optional, default is2
which results in thelite
image)sources
: A list of custom APT sources to be added to the image (optional)name
: The name of the source to use as a referencesource
: The source entrykey_id
: The GPG key IDkey_file
: The GPG key file URL (optional)key_server
: The GPG key server (optional)
packages
: A list of custom packages to be installed on the imagepackage
: The name of the packageversion
: The version of the package (optional)file_url
: The URL of the package file (optional)release
: The release information of the package (optional)owner
: The owner of the repositoryrepo
: The name of the repositorytag
: The tag of the releasematcher
: The matcher to filter the package filetoken
: The GitHub token to access a private repository, supports environment variable reference when$
is used like$GITHUB_TOKEN
to avoid putting the access token directly in the configuration file (optional)
boot_cmdline
: A list of boot command line parameters to be added to thecmdline.txt
file (optional)boot_config
: A list of boot configuration parameters to be added to theconfig.txt
file (optional)
A minimalist configuration to add an extra package to your image:
{
"name": "bookworm-lite-with-dns-server",
"version": "1.0.0",
"reference": "2024-07-04-raspios-bookworm-arm64",
"packages": [
{
"package": "dnsmasq"
}
]
}
A more complex configuration to add custom packages, APT sources, and boot configuration:
{
"name": "edge-pi-zero",
"version": "1.0.0",
"reference": "2024-03-12-raspios-bullseye",
"sources": [
{
"name": "effective-range",
"source": "deb http://aptrepo.effective-range.com stable main",
"key_id": "C1AEE2EDBAEC37595801DDFAE15BC62117A4E0F3",
"key_file": "http://aptrepo.effective-range.com/dists/stable/public.key",
"key_server": "keyserver.ubuntu.com"
}
],
"packages": [
{
"package": "wifi-manager",
"release": {
"owner": "EffectiveRange",
"repo": "wifi-manager",
"tag": "latest",
"matcher": "*armhf.deb"
}
},
{
"package": "picprogrammer",
"release": {
"owner": "EffectiveRange",
"repo": "pic18-q20-programmer",
"tag": "v0.3.0",
"matcher": "*armhf.deb"
}
},
{
"package": "filebeat",
"version": "8.12.2",
"file_url": "https://github.com/EffectiveRange/elastic-beats-armhf-deb/releases/download/v8.12.2/filebeat-8.12.2-armv7l.deb"
}
],
"boot_cmdline": [
"modules-load=dwc2,g_ether"
],
"boot_config": [
"enable_uart=1",
"dtoverlay=dwc2"
]
}
Flash the image to an SD card using Raspberry Pi Imager
-
Download and install the Raspberry Pi Imager
-
Open the Raspberry Pi Imager
-
Choose your
Raspberry Pi Device
type andStorage
volume -
Click
Choose OS
and selectUse custom
option -
Select the custom image file you downloaded
-
Click
NEXT
andEDIT SETTINGS
to configure theWi-Fi
,SSH
and other settings -
Click
SAVE
to apply the configuration -
Click
YES
to flash the image to the SD card -
After the flashing process is completed, insert the SD card into your Raspberry Pi and power it on