{"id":21969609,"url":"https://github.com/cinderblock/raspberrypi-image-edit","last_synced_at":"2025-04-28T10:21:03.147Z","repository":{"id":41160999,"uuid":"387263512","full_name":"cinderblock/RaspberryPi-Image-Edit","owner":"cinderblock","description":"Shell scripts for modifying Raspberry Pi OS images **before** writing them to an SD card, from any Linux system","archived":false,"fork":false,"pushed_at":"2023-02-25T23:15:36.000Z","size":90,"stargazers_count":21,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T08:41:24.443Z","etag":null,"topics":["raspberry-pi","raspberry-pi-3","raspberry-pi-4","raspberry-pi-zero","raspberry-pi-zero-w","raspberrypi","raspbian"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cinderblock.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-18T20:29:05.000Z","updated_at":"2025-01-29T01:13:31.000Z","dependencies_parsed_at":"2024-11-29T14:24:11.105Z","dependency_job_id":"fed904ec-bdd0-4fee-acaa-8be94f02a3d6","html_url":"https://github.com/cinderblock/RaspberryPi-Image-Edit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinderblock%2FRaspberryPi-Image-Edit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinderblock%2FRaspberryPi-Image-Edit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinderblock%2FRaspberryPi-Image-Edit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinderblock%2FRaspberryPi-Image-Edit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cinderblock","download_url":"https://codeload.github.com/cinderblock/RaspberryPi-Image-Edit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251293243,"owners_count":21566070,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["raspberry-pi","raspberry-pi-3","raspberry-pi-4","raspberry-pi-zero","raspberry-pi-zero-w","raspberrypi","raspbian"],"created_at":"2024-11-29T14:22:52.565Z","updated_at":"2025-04-28T10:21:03.110Z","avatar_url":"https://github.com/cinderblock.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Setup Raspberry Pi OS Image Script\n\nScripts for modifying Raspberry Pi OS images **before** writing to SD card.\n\n## Easy Mode\n\n```bash\ngit clone https://github.com/cinderblock/RaspberryPi-Image-Generator.git\ncd RaspberryPi-Image-Generator\n# Edit `setup.sh`. This gist adds *my* keys!\n./new.sh\n```\n\n#### With already downloaded img zip\n```bash\n./new.sh path-to-raspbian.img.zip\n```\n\n## Manual Mode\n\n1. Download a Raspberry Pi OS image and unzip it:\n   ```bash\n   wget https://downloads.raspberrypi.org/raspios_lite_armhf_latest --trust-server-names --timestamping --quiet\n   unzip *-*-*-raspios-buster-lite-armhf.zip\n   ```\n2. Download gist files:\n   ```bash\n   wget https://raw.githubusercontent.com/cinderblock/RaspberryPi-Image-Generator/master/{setup,chroot,grow,new}.sh --timestamping --quiet\n   chmod +x {setup,chroot,grow,new}.sh\n   ```\n3. Edit `setup.sh` as desired. *default adds **my** keys!*\n4. Run scripts.\n\n## Available scripts\n\n```bash\nsudo ./chroot.sh 2020-05-27-raspios-buster-lite-armhf.img [executable] [mount point]\nsudo ./grow.sh 2020-05-27-raspios-buster-lite-armhf.img [megabytes]\n./new.sh [image-path]\n# `setup.sh` is meant to be run on a Raspberry Pi image in a chroot.\nsudo ./edit-boot.sh 2020-05-27-raspios-buster-lite-armhf.img\n./get-latest.sh\n```\n\nThe default `setup.sh` script **will fail** unless you `grow` the standard `.img` by ~400MB first *(as of 2021-07-15)*.\n\nRuns the `setup.sh` (or other) script in a chroot in specified image.\n\n### Chroot\n\nGives you a chroot in the image to change whatever manually.\n\n```bash\n ./chroot.sh my-raspios.img\n ```\n\n *If anything goes wrong, the script should cleanup after itself and not leave dangling mounts or loopback devices.*\n\n**Planned changed:** Use `systemd-nspawn` instead of `chroot`.\n\nMaintains a separate \"`.bash_history`\" that is re-used for all images in a `.persist` folder.\nThis behavior can be overridden by setting `LEAVE_HISTORY_ALONE=yes` (any non-zero length string).\n\n### Prepare\n\nThe `./chroot.sh` script can also be run in \"prepare\" mode.\nGive it a second argument of an executable to run inside the chrooted environment as root.\nFor example: `./chroot.sh my-raspios.img some-executable`.\n\n### Grow\n\nGrow the image (and main partition) by some number of megabytes.\n\n```bash\n ./grow.sh my-raspios.img 400\n ```\n\nThis only affects the local `.img` file. On first boot, Raspbian will automatically grow the parition to fill the full card.\n\n*Adding 100MB adds aproximately 10 seconds to the write time when transfering to an SD card.*\n\n### New\n\nDoes all the steps needed to get a brand new image in a single command.\nAssumes other scripts are in the same folder.\n\n```bash\n./new.sh\n```\n\nThe steps are:\n\n1. Download a new `img` file\n2. `unzip` it on the fly\n3. Save to a custom img file (overwritting if it exists)\n4. Grows the image\n5. Runs `setup.sh` inside the `chroot`\n6. Zips the img to save space\n\n### Setup\n\nThis script is meant to be run inside a raspberry pi chroot, as root.\n\nIt might run succesfully running directly on a Pi, but that is not a supported use case.\n\n#### Current Features\n\n- Adds ssh keys\n- Enables sshd, without passwords\n- Sets US locale\n- Adds WiFi configuration to `/boot`\n- Adds a new script to change a Pi's hostname with a file `/boot/hostname`\n- Sets timezone to `America/Los_Angeles`\n- Updates \u0026 Upgrades\n- Installs `git`, `vim`, `screen`, and `node`\n- Sets the passwd for `pi`\n- Sets `python3` as the default Python version\n- Sets `vim` as the default editor\n\n### Edit Boot `get-boot.sh`\n\nA simplified mounting of the filesystem that only accesses the image's `/boot` parition.\n\n### Get Latest `get-latest.sh`\n\nDownload the official latest version of raspios-lite.\nDon't overwrite if it already exists.\nContinue downloading if previously interrupted.\n\n## See also\n\n- https://github.com/RPi-Distro/pi-gen - Full featured `.img` generator\n- https://wiki.debian.org/RaspberryPi/qemu-user-static - Debian instructions to grow/mount/chroot/qemu-run\n- https://gist.github.com/htruong/0271d84ae81ee1d301293d126a5ad716 - Instructions to grow and chroot\n- https://gist.github.com/htruong/7df502fb60268eeee5bca21ef3e436eb - Script to just mount \u0026 chroot (no loopback)\n- https://gist.github.com/kmdouglass/38e1383c7e62745f3cf522702c21cb49 - Script: loopback, mount, chroot. No cleanup.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcinderblock%2Fraspberrypi-image-edit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcinderblock%2Fraspberrypi-image-edit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcinderblock%2Fraspberrypi-image-edit/lists"}