Setting up a Banana Pi M2 with Armbian

Since some time I have a Banana Pi M2 sitting in the storage room used as a server for files and media. I do not exactly remember where I got the installed Linux, but it was something based on Raspbian, which is not really suitable for the A31 processor. So some days ago I decided to re-install it from scratch with Armbian. The following are some notes related to setting things up.


Installing Armbian was quite straight-forward: Download the image for the Banana Pi M2 and write it to the SD card with dd:

dd if=./Armbian_5.14_Bananapim2_Ubuntu_xenial_4.6.2.7z of=/dev/mmcblk0

For the first boot, I attached keyboard and monitor. The BPi rebooted once to extend the file system to the whole SD card and when logging in with the root account with default password 1234, it forced me to change the password.

Armbian login message of the day
Armbian login message of the day

So until now the experience with Armbian is really great. Everything works flawlessly.

Basic Setup

From all the Raspberry Pis I have installed, I found some basic things that I always need to configure after installing the OS in the same way:

  • Create a new user account
  • Add this account to the sudo group to be able to do administration tasks
  • Copy my SSH public key to the .ssh/authorized_keys file
  • Set up capability to send mail with ssmtp
  • Set up unattended-upgrades

The first three steps to set up a user account are really standard. If you do not know it, follow the link to read more about SSH Public Key Authentication.

Setting up Mail Sending

As the Banana Pi and also the Raspberries all run headless, I need some other way to let them talk to me and send status updates. So my preferred way is to set up a very simple mail server to send out mail. For this I use the ssmtp package. As a client tool for sending mail from the command-line I use bsd-mailx:

apt-get install ssmtp bsd-mailx

ssmtp is not really a mail server, because it cannot queue the mails. Instead, whenever you send a mail, it directly connects to another mail service for sending. If the mail service is not reachable, sending the mail fails and is not retried later.

For setup, you just configure ssmtp by its configuration file ssmtpd.conf in /etc/ssmtpd. My file looks similar to this:

# Config file for sSMTP sendmail
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named

# Where will the mail seem to come from?

# The full hostname

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address



Depending on the mail service you use, the configuration needs perhaps to be adapted. At least the mail server, user name and password need to be set correctly.

To test sending mail, use the mail command like this (please use your own e-mail address for this...):

mail -v

It asks for the recipient. After that, you can enter text. A dot (.) in a separate line ends the entered text and the e-mail gets send out.

Unattended Upgrades

When having only one or two Raspberry Pis, it's fun to keep them up-to-date. Until some time ago I used the apticron package to send e-mail notifications when updates are available. But at some point it got too much to always log in by SSH to various computers to install the updates. So now I switched to use the unattended-upgrades package. If it's not yet installed, install it like this:

apt-get install unattended-upgrades

After that, you need to edit the configuration file 50unattended-upgrades in /etc/apt/apt.conf.d. I changed the default to send status mails to root (ssmtp later translates this to my real mail address) and to reboot if this is required. Finally you need to enable the unattended upgrades like this:

dpkg-reconfigure -plow unattended-upgrades

For Armbian, you need to adapt the standard configuration for allowed package sources, from which packages are installed unattended. This is stored in /etc/apt/apt.conf.d/50unattended-upgrades:

// Automatically upgrade packages from these (origin:archive) pairs
Unattended-Upgrade::Allowed-Origins {

With this configuration, all available new packages from Ubuntu and Armbian repositories are installed automatically.

After installing the package, I recommend to monitor the log file at /var/log/unattended-upgrades/unattended-upgrades.log for a few days to see if everything is running fine. For a more detailed explanation of this package, you can have a look at the Debian website.

LinkedIn logo mail logo