[Update June 28: Post updated with correct procedure thanks to Collabora help]
Armbian provides lightweight Debian or Ubuntu images for various Arm Linux SBC, and over the years has become the recommended source for stable firmware images for boards part of Orange Pi & Banana Pi families, and others.
Uncompressed images are still over 1GB and come with Armbian-specific tools, kernel and bootloader. If you’d like to leverage Armbian images, but instead create a Debian upstream image with only the packages you intend to use, Collabora explains how to do just that with Orange Pi Zero +2 H5 and Libre Computer AML-S905X-CC (aka Le Potato) boards using Debos Debian OS builder.
I’ve decided to give a try at the instructions for Orange Pi Zero Plus2 H5 in my laptop running Ubuntu 18.04 to better understand how this all works.
I’ll assume you’ve already installed Docker, and made sure you’ve got it working as a non-root user, so we can install Debos as follows:
1 |
docker pull godebos/debos |
Configuration for Debos is made through a YAML files. Collabora has already provided such file for Orange Pi Zero 2+ board: orangepi0p2.yaml. You’ll need to modify it to your version of Armbian as I did below. Note getting the latest version number for Armbian is critical, or the script will fail with something like:
1 2 3 |
2019/06/28 09:30:44 ==== raw ==== 2019/06/28 09:30:44 Action <code>raw</code> failed at stage Run, error: Failed to read /scratch/mnt/usr/lib/linux-u-boot-next-orangepizeroplus2-h5_5.83_arm64/sunxi-spl.bin Powering off. |
I’ve also added comments explaining a bit more about each sections:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# Base recipe for minimal Debian SID ARM64 image architecture: arm64 actions: - action: debootstrap suite: sid components: - main mirror: https://deb.debian.org/debian variant: minbase - action: apt packages: [ sudo, adduser, systemd-sysv, initramfs-tools, u-boot-tools, u-boot-menu, util-linux ] - action: run chroot: true command: echo debian-sid-arm64 > /etc/hostname - action: run chroot: true command: echo "127.0.1.1\tdebian-sid-arm64" >> /etc/hosts - action: overlay source: overlays/etc destination: /etc - action: run chroot: true script: scripts/setup-user.sh # End of base recipe for minimal Debian SID ARM64 image # Add armbian repository - action: overlay source: overlays/armbian # Get Linux kernel and U-boot from Armbian repository - action: apt packages: [ linux-image-next-sunxi64, linux-dtb-next-sunxi64, linux-u-boot-orangepizeroplus2-h5-next ] # Create the (rootfs) partitions - action: image-partition imagename: debian-sid-arm64.img imagesize: 1GB partitiontype: msdos mountpoints: - mountpoint: / partition: root partitions: - name: root fs: ext4 start: 2MB end: 100% flags: [ boot ] # Deploy the filesystem to an image - action: filesystem-deploy description: Deploying filesystem onto image # U-boot-menu expects FDT directory name to include the kernel version as # returned by linux-version. - action: run chroot: true command: ln -s linux-image-next-sunxi64 /usr/lib/linux-image-$(linux-version list) # Update U-Boot menu after creation of image partitions and filesystem # deployment to get correct root information from /etc/fstab - action: run description: Update U-Boot menu chroot: true command: u-boot-update # Install Install uboot in our image. # Armbian encode a version number in path to u-boot binaries, 5.85 at time I write this blog, this may need to be changed - action: raw origin: filesystem source: /usr/lib/linux-u-boot-next-orangepizeroplus2-h5_5.85_arm64/sunxi-spl.bin offset: 8192 # bs=8k seek=1 - action: raw origin: filesystem source: /usr/lib/linux-u-boot-next-orangepizeroplus2-h5_5.83_arm64/u-boot.itb offset: 40960 # bs=8k seek=5 # Create block map file - action: run description: Create block map file postprocess: true command: bmaptool create debian-sid-arm64.img > debian-sid-arm64.img.bmap #Compress final image - action: run description: Compressing final image postprocess: true command: gzip -f debian-sid-arm64.img |
The next command requires KVM for QEMU, and we should run it as normal user:
1 |
sudo usermod -aG kvm $USER |
Logout and login again. Now in theory this command should create our image:
1 |
docker run --rm --interactive --tty --device /dev/kvm --user $(id -u) --workdir /recipes --mount "type=bind,source=$(pwd),destination=/recipes" --security-opt label=disable godebos/debos orangepi0p2.yaml |
But sadly, I’ve run into permissions errors, I’ve been unable to fix after a couple of hours:
1 2 3 |
Could not access KVM kernel module: Permission denied qemu-system-x86_64: failed to initialize KVM: Permission denied open /tmp/fakemachine-048715194/result: no such file or directory |
My username is part of kvm and docker groups:
1 2 |
groups jaufranc adm dialout cdrom sudo dip plugdev lpadmin sambashare vboxusers docker kvm libvirt |
and the KVM modules are indeed loaded:
1 2 3 4 5 |
lsmod | grep kvm kvm_amd 94208 0 ccp 86016 1 kvm_amd kvm 634880 1 kvm_amd irqbypass 16384 1 kvm |
I got stuck here, but with Frédéric Danis’ help (see comments below), I could solve the permission issue:
1 2 3 |
docker run --rm --interactive --tty --device /dev/kvm --group-add $(getent group kvm | cut -d: -f3) --user $(id -u) --workdir /recipes --mount "type=bind,source=$(pwd),destination=/recipes" --security-opt label=disable godebos/debos orangepi0p2.yaml qemu-system-x86_64: -virtfs local,mount_tag=virtfs-5,path=/recipes/scripts,security_model=none: cannot initialize fsdev 'virtfs-5': failed to open '/recipes/scripts': No such file or directory open /tmp/fakemachine-686249639/result: no such file or directory |
The /recipes/scripts directory is however missing, and that’s because I wrongly assume debos would just need to be feed the yaml file. Instead we also need to get scripts and overlays directories from gitlab, and copy our updated yaml file into debos-armbian2debian/1-ArmbianKernel directory:
1 2 |
git clone https://gitlab.collabora.com/fdanis/debos-armbian2debian/ cp orangepi0p2.yaml debos-armbian2debian/1-ArmbianKernel |
Now we can enter the directory, and run the previous command to generate the minimal image:
1 |
docker run --rm --interactive --tty --device /dev/kvm --group-add $(getent group kvm | cut -d: -f3) --user $(id -u) --workdir /recipes --mount "type=bind,source=$(pwd),destination=/recipes" --security-opt label=disable godebos/debos orangepi0p2.yaml |
After a few minutes, the image should be generated:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
2019/06/28 14:25:45 ==== Deploying filesystem onto image ==== 2019/06/28 14:25:47 Setting up fstab 2019/06/28 14:25:47 Setting up /etc/kernel/cmdline 2019/06/28 14:25:47 ==== run ==== 2019/06/28 14:25:48 ==== Update U-Boot menu ==== 2019/06/28 14:25:48 u-boot-update | P: Checking for EXTLINUX directory... found. 2019/06/28 14:25:49 u-boot-update | P: Writing config for vmlinuz-4.19.38-sunxi64... 2019/06/28 14:25:49 u-boot-update | P: Updating /boot/extlinux/extlinux.conf... 2019/06/28 14:25:49 ==== raw ==== 2019/06/28 14:25:49 ==== raw ==== Powering off. 2019/06/28 14:25:53 ==== Create block map file ==== 2019/06/28 14:25:57 ==== Compressing final image ==== 2019/06/28 14:26:19 ==== Recipe done ==== |
You’ll find it in the working directory:
1 2 |
ls -lh debian-sid-arm64.img.gz -rw-r--r-- 1 jaufranc root 111M มิ.ย. 28 21:25 debian-sid-arm64.img.gz |
Now you can flash the image to your SD card as follows:
1 2 |
$ DEV=/dev/your_sd_device $ sudo bmaptool copy --no-sig-verify --no-verify debian-sid-arm64.img.gz $DEV |

Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress