marco-netinst follows the same working principle as its parent, the raspbian-ua-netinst utility. It simply packages a minimal set of tools into a deployable minimal OS image that it installed in the first partition of the SD card. On start, the raspbian-based minimal system will use the
/etc/init.d/rcS script to discover a suitable OS server in the network (using a fallback if unsuccessful), download the image and format the SD card to appropriately install all the files. Busybox is used to reduce the number of required packages and dependencies.
The Raspberry lacks a BIOS, so it relies on several well-known files to load the operating system during the booting process . This files must be set on the first partition of the SD card to be read.
The working principle of the tool is to have a set of minimal tools in a container that the configuration files specify to use as the source for the operating system. That combined with an image of a generic Linux kernel (although it could be easily replaced by a custom one, compiled for the sole purposed of space saving) boots a minimal operating system capable of performing all the required operations. These are the relevant configuration files with their parameters:
config.txtDefines the location of the kernel and the initramfs image to be the .cpio file with all the required files.
cmdline.txtSpecifies the command-line parameters usually defined in the bootloader. In this case, the parameters are very generic:
consoleblank=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1
The following bash scripts comprise the whole functionality of the tool. The technical reference is located in the reference.
Creates a .cpio file with all the downloaded packages and packages it inside a zip file with the rest of the boot files (an image of the kernel, several configuration files, etc).
- Creates a temporary directory.
- Copies boot files to the directory.
- Creates a cpio file that packages all the required binaries and libraries.
- Copies the .cpio files to the system (one per ARM architecture).
- Creates a boot configuration file.
- Copies the marcopolo executable.
- Copies certificate files
- Copies the rest of relevant files.
Instead of a zip file it creates an image of the OS which can be flashed to the SD card.
Builds an update image instead of an installation image.
Removes all temporary files.
Deploys a zip package in the specified device, formatting it appropriately.
- Checks that the device exists.
- Unmounts the device and partitions it (creates one partition).
- Creates the filesystems.
- Mounts the new partition.
- Unzips the file inside the device.
- Unmounts the involved partitions.
Downloads all the specified packages and stores them in a temporary location.
- Cleans all previously downloaded packages.
- Downloads the raspbian public keys for integrity and validation purposes.
- Downloads the release file and its signature.
- Search for the required packages and adds them to a list.
- Downloads the packages and verifies them.
- Adds an older Busybox, since the jessie one is known to cause trouble.
init.d/rcS: The installation script. It accomplishes the following tasks:
- Creates a set of temporary directories to store the temporary filesystem.
- Starts a Busybox-based environment.
- Mounts pseudo filesystems.
- Creates devices using
- Creates a pipe with a copy of the output to a file, so it can be used later for debugging purposes.
- Detects the hardware of the Raspberry (as it is compatible with all models).
- Mounts the boot partition.
- Configures the network using DHCP or a previously defined static configuration.
- Configures the system time with a NTP server (the Raspberry Pi has no real time clock).
- If there is an online configuration file to download, it is done in this step.
- Detects a server node in the network. If unsuccessful, it will use the fallback node if it is defined.
- Loads the installation profile (minimal, full...).
- Loads the USB modules to allow the installation in a USB device.
- Defines the partition scheme. Three partitions are created, located in
- Formats the SD card, erasing all the content (the OS files are conveniently located in the RAM, so the system is functional).
- Creates the filesystems.
- Downloads the OS image using the mirror.
- Extracts the file in the root partition (the second partition).
- Moves the boot files to
- Executes the post install script, if any.
- Logs the final time variables (total time) and copies the log file to a secure location.
- Removes auxiliary files.
- Unmounts the file systems.
- Reboots. The system is now functional.
All the process is timed and this information is logged in the file.
- udhcpc/default.script A DHCP configuration script
The scripts are parts of a pipeline in the following order:
update.sh -> build.sh/buildupdate.sh -> deploy.sh (-> clean.sh)
So if deploy.sh is executed without previously executing the preceding phases, it will do so before carrying out any own operation.