Skip to content

Automatic first boot configuration

Reading presets from local config

It is possible to configure your device automatically at first boot. Settings like: root password, IP address, connecting to wireless.

After flashing an image to boot media, mount it and add a file containing your config to /root/.not_logged_in_yet

Info

This file will be read at your first login and configure system automatically.

Config example for reference:

Bash
 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
# Set PRESET_NET_CHANGE_DEFAULTS to 1 to apply any network related 
# settings below
PRESET_NET_CHANGE_DEFAULTS="1"

# Enable WiFi or Ethernet. # If both are enabled, WiFi will take priority 
# and Ethernet will be disabled.
PRESET_NET_ETHERNET_ENABLED="1"
PRESET_NET_WIFI_ENABLED="1"

# Enter your WiFi credentials
# SECURITY WARN: Your wifi keys will be stored in plaintext, no encryption.
PRESET_NET_WIFI_SSID="MySSID"
PRESET_NET_WIFI_KEY="MyWiFiKEY"

# Country code to enable power ratings and channels for your country. 
# eg: GB US DE | https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
PRESET_NET_WIFI_COUNTRYCODE="GB"

#If you want to use a static ip, set it here
PRESET_NET_USE_STATIC="1"
PRESET_NET_STATIC_IP="192.168.0.100"
PRESET_NET_STATIC_MASK="255.255.255.0"
PRESET_NET_STATIC_GATEWAY="192.168.0.1"
PRESET_NET_STATIC_DNS="8.8.8.8 8.8.4.4"

# Preset user default shell, you can choose bash or zsh
PRESET_USER_SHELL="bash"

# Set PRESET_CONNECT_WIRELESS=y if you want to connect wifi manually 
# at first login
PRESET_CONNECT_WIRELESS="n"

# Set SET_LANG_BASED_ON_LOCATION=n if you want to choose 
# "Set user language based on your location?" with "n" at first login
SET_LANG_BASED_ON_LOCATION="y"

# Preset default locale
PRESET_LOCALE="en_US.UTF-8"

# Preset timezone
PRESET_TIMEZONE="Etc/UTC"

# Preset root password
PRESET_ROOT_PASSWORD="RootPassword"

# Preset URL for root SSH key
# Use GitHub stored keys: https://github.com/<username>.keys
PRESET_ROOT_KEY=""

# Preset username
PRESET_USER_NAME="armbian"

# Preset user password
PRESET_USER_PASSWORD="UserPassword"

# Preset URL for user SSH key
# Use GitHub stored keys: https://github.com/<username>.keys
PRESET_USER_KEY=""

# Preset user default realname
PRESET_DEFAULT_REALNAME="Armbian user"

Reading presets from a remote config

You can use the same config file for more images. In this case you create file that is accessible via HTTP with the same content and place only URL to this config

Bash
1
/root/.not_logged_in_yet
Text Only
1
PRESET_CONFIGURATION="http://URL_OF_THIS_CONFIG"
Tip

If you want to use first run automatic configuration at build time, check this GitHub pull request.

tl;dr;

  1. Copy the template with cp extensions/preset-firstrun.sh userpatches/extensions/
  2. Edit the template userpatches/extensions/preset-firstrun.sh according to your situation
  3. Build your Armbian image using the additional parameter ENABLE_EXTENSIONS=preset-firstrun