Usage
- Download a Raspberry Pi OS image and unzip it:
wget https://downloads.raspberrypi.org/raspios_lite_armhf_latest --trust-server-names --timestamping --quiet unzip 2020-05-27-raspios-buster-lite-armhf.zip
- Download gist files:
wget https://gist.githubusercontent.com/cinderblock/20952a653989e55f8a7770a0ca2348a8/raw/{prepare,chroot,grow,setup}.sh --timestamping --quiet chmod +x {prepare,chroot,grow}.sh
- Edit
setup.sh
as desired. default adds my keys! - Run scripts.
Available scripts
sudo ./prepare.sh 2020-05-27-raspios-buster-lite-armhf.img [setup.sh] [mount point]
sudo ./chroot.sh 2020-05-27-raspios-buster-lite-armhf.img [mount point]
sudo ./grow.sh 2020-05-27-raspios-buster-lite-armhf.img [megabytes]
The default setup.sh
script will fail unless you grow
the standard .img
first (for 2020-02-13).
Prepare
Runs the setup.sh
(or other) script in a chroot in specified image.
Chroot
Gives you a chroot in the image to change whatever manually.
Planned changed: Use systemd-nspawn
instead of chroot
.
Note: Bash history will be saved too. Subject to change.
Grow
Grow the image (and main partition) by some number of megabytes.
This only affects the local .img
file. On first boot, Raspbian will automatically grow the parition to fill the full card.
Adding 100MB adds aproximately 10 seconds to the write time when transfering to an SD card.
See also
- https://github.com/RPi-Distro/pi-gen - Full featured
.img
generator - https://gist.github.com/htruong/0271d84ae81ee1d301293d126a5ad716 - Instructions to grow and chroot
- https://gist.github.com/htruong/7df502fb60268eeee5bca21ef3e436eb - Script to just mount & chroot (no loopback)
- https://gist.github.com/kmdouglass/38e1383c7e62745f3cf522702c21cb49 - Script: loopback, mount, chroot. No cleanup.
This comment has been minimized.
@cinderblock I just downloaded fresh copy of Raspbian Buster Lite, unpacked it and did this:
Here is my chroot:
user@laptop:~/download$ ll chroot/ total 76 drwxr-xr-x 2 root root 4096 Feb 13 10:56 bin/ drwxr-xr-x 3 root root 4096 May 19 10:55 boot/ drwxr-xr-x 4 root root 4096 Feb 13 10:51 dev/ drwxr-xr-x 79 root root 4096 Feb 13 11:09 etc/ drwxr-xr-x 3 root root 4096 Feb 13 10:55 home/ drwxr-xr-x 16 root root 4096 Feb 13 10:58 lib/ drwx------ 2 root root 4096 Feb 13 11:09 lost+found/ drwxr-xr-x 2 root root 4096 Feb 13 10:51 media/ drwxr-xr-x 2 root root 4096 Feb 13 10:51 mnt/ drwxr-xr-x 3 root root 4096 Feb 13 10:55 opt/ drwxr-xr-x 2 root root 4096 Feb 8 21:47 proc/ drwx------ 2 root root 4096 May 19 10:56 root/ drwxr-xr-x 4 root root 4096 Feb 13 10:51 run/ drwxr-xr-x 2 root root 4096 Feb 13 10:58 sbin/ drwxr-xr-x 2 root root 4096 Feb 13 10:51 srv/ drwxr-xr-x 2 root root 4096 Feb 8 21:47 sys/ drwxrwxrwt 2 root root 4096 Feb 13 11:09 tmp/ drwxr-xr-x 10 root root 4096 Feb 13 10:51 usr/ drwxr-xr-x 11 root root 4096 Feb 13 10:51 var/
Check to make sure
bash
inside chroot is indeed an ARM binary:Check if I am cheating and somehow have copied
qemu-static-binary
into the chroot:Finally, chroot:
Boom, we are in.