chroot script to customize your rootfs interactively

Due to popular demand for the ability to make changes to a rootfs (such as installing software prior to first boot), I’m publishing a script to enter a chroot so that these sorts of changes can be made interactively. Many thanks to the Debian wiki.

Software can be compiled and/or installed. Apt and dpkg can be used to update the system or add and remove packages. Users can be created (and removed), though you may wish to only create system users this way (< uid 1000) unless modifying nvidia’s first boot process to account for this. Most things apart from gui apps, or those that rely on actual harware like the gpu can be tested.

All steps will happen prior to first boot so you can put the system in a desired state and still allow for first boot configuration. Nvidia’s first boot scripts can be disabled by removing their .service unit files from /etc/systemd/system

Many (but not all) of nvidia’s actual first boot scripts seem to be located in the /etc/systemd root should you wish to edit them to account for your changes rather than disable them. Many of the things they do are necessary to a proper first boot.

You will also likely wish to run apply_binaries.sh as outlined in the nvidia documentation before this if you extracted your rootfs from a tarball. Once a rootfs is created, you can flash it to sd card by using create-jetson-nano-sd-card-image.sh (or the appopriate procedure for a production module). Please see the Linux for Tegra documentation for details

Lastly, while the method used by the script is well tested and every effort has been made to ensure it runs perfectly, it will have bugs. Please report any issues you have with the script on github.

Nice! Thanks for the sharing.