Lately, I'm using the Orange Pi Zero bought some time ago for new projects. It is important to validate procedures by repeating them in fresh installation of the operating system. That means burning the OS image on a microSD card and then performing a number of initial steps such as setting up the network, upgrading all installed packages and so on that need to be repeated in exactly the same way each time a new image is used. All this takes time and somewhat error prone. So I decided to create a binary image that avoids these steps.
It is much easier to create a custom image of Armbian than it was to do it for Raspbian. However, it is necessary to have access to a Linux machine with a microSD card reader and with GParted installed. Probably the command line utility
parted could be used in place of the latter.
The elegant way of doing this would be to build the OS image from sources modifying it to meet my needs. But a cursory look at the Developer Guide was enough to convince me that such an endeavour was above my pay scale.
Table of Contents
Copy Armbian on a microSD card
Get the Armbian image from the download page. Since the target is an Orange Pi Zero, I ended up getting Armbian Stretch even though Bionic is already available.
The downloaded file is a 7z compressed archive so it is necessary to
extract the image file,
Armbian_5.69_Orangepizero_Debian_stretch_next_4.19.13.img in
order to use Balena
Etcher as recommended by Igor Pečovnik et al at
Armbian.com.
Updating Armbian Stretch
The initial boot and configuration of the Orange Pi Zero are done with
the serial connection as described before. It could be done with an SSH session over a wired Ethernet connection. I connected a USB to
serial adapter to the header on the Opiz, opened a serial connection using
screen and powered up the Opiz with the microSD card in its
reader of course.
dmesg latter.
None of this will be seen if an SSH connection is used
instead of a serial connection.
...
Debian GNU/Linux 9 orangepizero ttyS0
orangepizero login: root
Password: 1234 not echoed to the screen
You are required to change your password immediately (root enforced)
Changing password for root.
(current) UNIX password: 1234 not echoed to the screen
Enter new UNIX password: xyxyxy your chosen password, not echoed to the screen
Retype new UNIX password: xyxyxy repeat the chosen password, not echoed to the screen
___ ____ _ _____
/ _ \ _ __ __ _ _ __ __ _ ___ | _ \(_) |__ /___ _ __ ___
| | | | '__/ _` | '_ \ / _` |/ _ \ | |_) | | / // _ \ '__/ _ | |_| | | | (_| | | | | (_| | __/ | __/| | / /| __/ | | (_) |
\___/|_| \__,_|_| |_|\__, |\___| |_| |_| /____\___|_| \___/
|___/
Welcome to ARMBIAN 5.69 stable Debian GNU/Linux 9 (stretch) 4.19.13-sunxi
System load: 0.11 0.26 0.15 Up time: 4 min
Memory usage: 11 % of 493MB IP:
CPU temp: 38°C
Usage of /: 6% of 15G
[ General system configuration (beta): armbian-config ]
New to Armbian? Check the documentation first: https://docs.armbian.com
Thank you for choosing Armbian! Support: www.armbian.com
Creating a new user account. Press <Ctrl-C> to abort
Please provide a username (eg. your forename): zero
Trying to add user zero
Adding user `zero' ...
Adding new group `zero' (1000) ...
Adding new user `zero' (1000) with group `zero' ...
Creating home directory `/home/zero' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: xxxyyy
Retype new UNIX password: xxxyyy
passwd: password updated successfully
Changing the user information for zero
Enter the new value, or press ENTER for the default
Full Name []: Enter pressed
Room Number []: Enter pressed
Work Phone []: Enter pressed
Home Phone []: Enter pressed
Other []: Enter pressed
Is the information correct? [Y/n] y
Dear zero, your account zero has been created and is sudo enabled.
Please use this account for your daily work from now on.
On the first boot, you are made to change the root
password and to create a default user. I chose zero at
its name and did not bother entering any personal information.
As can be seen, the file system has been expanded to the full 15 GB
on the microSD card. It takes forever to create backup images of this size card which is quite
frustrating. So after setting up a minimal common configuration, the
file system will be shrunk back down to 2 GB. Note that the current user
is root so there will not be any need for the sudo
prefix.
In the main screen shown above, use the cursor keys to highlight Network, then press Tab to get to the < OK > button and press the space bar or the Enter key go on to configure the wireless network interface.
Use the cursor keys to highlight wlan0, then press Tab to get to the < OK > button and press the space bar or the Enter key to go on.
Use the cursor keys to highlight WiFi, then press Tab to get to the < OK > button and press the space bar or the Enter key to go on.
Use the cursor keys to highlight the name of the local Wi-Fi network, in this case MY_SSID, then press the Enter key to enter the password.
Once the password has been entered activate the <OK> button
and the Authentication window will close and a connection will be
attempted. Once the Connecting... pop-up is no longer displayed,
select the network name again and if there is no * appearing to the
left of the name, use Tab to highlight
<Activate> and space bar or the Enter key. Finally, once the connection to the Wi-Fi
network is established, activate the <Quit> button.
Back in the Wired, Wireless, Bluetooth, Hotspot screen,
I chose to Disable IPV6 for APT and system by highlighting and
then activating the <OK> button. Now that IPV6 is disabled,
the menu entry becomes Enable IPV6 for APT and system.
Press <Cancel>, to return to the main armbian-config
menu and select Personal to change the time zone, proceeding much like
above. Since the Orange Pi Zero will be used as a headless server, there is
no point in changing the keyboard layout, locale and so on. When the basic
configuration is completed, press on <Cancel> enough times to back out of the
configuration utility.
Check that the wireless interface is up. This is a good time to update all packages.
On January 30, 2019, a total of 22 packages were updated which require downloading 35.4MB from the archives.
As can be seen below, avahi (zero configuration) is not
installed, so I chose to install it.
I did this because I want to be able to connect to the device
with a simple command: ssh zero@orangepizero.local without
having to look up the IP address. Some would not agree, but the daemon can always be removed
later on if a fixed IP is assigned and in the meantime I find it useful.
Note that it would not be a good idea to set a fixed IP address at this
point; think of the problem if an image with a fixed IP address were
copie onto a second Orange Pi Zero.
The last step I undertook was to modify the sudoers
configuration file so that the default user would not be
constantly asked to supply its password whenever the sudo
prefix is used
Now there remains to shut down the Orange Pi Zero in an orderly fashion so as to be able to resize the partition and copy the image on the desktop computer.
With the Orange Pi Zero, it is easy to spot when everything is stopped; the green LED above the microSD card goes off.
Save the Modified OS Image
Insert the modified microSD card into a reader connected to a Linux box and start GParted. The
latter is not installed by default on Ubuntu so I
used the software library to install. After the utility has scanned all the
storage drives connected to the computer, which can take some time, select
the microSD card containing the modified Armbian image. It was
/dev/sde on my machine and very easy to find as all the other
drives were much bigger than it.

Right click on its ext4 partition, the only partition,
and select unmount in the menu if you see a keys icon to the right of the
partition. Gparted will again read the information, and the keys icon will no
longer be visible. Select the ext4 partition again, and click on the resize
icon which is the orange arrow pointing right. The Partition/Resize Move
menu selection could be used instead.

I chose to set the partition size to 2044 MiB. Given that there was 4 MiB not allocated ahead of the partition, that made for an image size of 2 GiB on the dot with 826.73 MiB free.

Click on apply button (with the green check icon) and let Gparted do its
thing. All that remains is to copy the first 2 GiB from the microSD card into an
image file. This is easily done with the dd utility. The
partition should not be mounted, but if it is then un mount it as shown below
before saving it.
Usage
There is not much to using this customized image. Copy it to an microSD card with Etcher. Once that is done, just insert the microSD card in the Orange Pi Zero card reader and power it up. The initial boot of the Orange Pi Zero can take a very long time, many minutes, so be patient. Eventually, it will be possible to reach it over a wireless connection.
Reboots will be much faster. Note how the partition is 2 GiB in size and slightly more than half is free.
Packages should also be upgraded with the usual commands.
As time goes on, this will take ever longer and it could become worthwhile to save the updated image as shown in the previous section for future use.
It is a very good idea to change the host name immediately using
armbian-config. Otherwise, avahi will assign
a different name to a second Orange Pi Zero on which this same image has
been copied because of the common orangepizero host name.
It will be harder to open an SSH session.