Using systemd-nspawn
This method an easy way to get started with customized images. The
systemd-nspawn makes it possible to update the image from the inside using
the tools already available in the image.
# Install
apt install systemd-container qemu-user-static
# Unpack rootfs
mkdir rootfs
tar -xJf rootfs.tar.xz -C rootfs
# Start a shell in rootfs using the host network and name resolution
systemd-nspawn -D rootfs --resolv-conf=bind-host
# Work with container filesystem
# e.g. install packages using apt, edit files
# Repack
tar -cJf rootfs.tar.xz -C ./rootfs .
The qemu-user-static package is used to seamlessly emulate arm64 binaries
when executing on a x86-64 machine.
Warning
Not everything is guaranteed to work as normal when using qemu-user
emulation. Not all system calls are implemented in the emulation layer.