mkrpimg is a script to create a bootable Raspberry Pi SD card image from scratch. It uses GNU Parted to prepare partitions in the image or on a physical block device, Apt and debootstrap to setup a Raspbian installation and QEMU to run ARM code in the new system image.
Usage
Before you can run mkrpimg, the required tools must be installed and qemu-arm-static
must be set up to handle ARM executables transparently (through the binfmt_misc mechanism). A standard installation of a Debian-based operating system with the parted
and qemu-user-static
packages should suffice.
mkrpimg defaults to creating a basic Raspbian installation. To verify the installed packages you should also give a public key to the script. To make the image bootable on an actual Raspberry Pi you should arrange for the installation of the bootloader code and kernel. A simple invocation of the tool could look like this:
mkrpimg --sudo --raspbian --foundation
The --sudo
option will automatically run all scripted commands that usually require root privileges under Sudo. Alternatively you can run the entire script as the superuser.
The --raspbian
option will select the Raspbian mirror for installation and install a copy of raspbian.public.key for package verification.
The --foundation
option will add the Raspberry Pi Foundation software repository to the configuration, install a copy of its package verification key and select the firmware packages for installation.
If nothing else is specified, mkrpimg creates a sparse disk image as a file called raspbian.img
in the current directory.
All non-option arguments to mkrpimg are taken to be software packages to install into the new image. If an argument references an existing file, the script tries to install it as a Debian package, unpack it in the image root directory or execute it as a script in the fresh system environment, depending on the file name extension. If an argument does not exist as a file, mkrpimg passes the argument to apt-get install
. You can setup additional repositories of Debian packages in the new image using the --repo
option.
Run
mkrpimg --help
to obtain a short description of all valid options for the script.