Auto Hostname

This section shows how to enable lmp-auto-hostname. This utility customizes a device’s hostname at runtime, by appending it with either the serial number from the device tree, or the mac address.

The recipe for lmp-auto-hostname is provided by meta-lmp and can be added by customizing meta-subscriber-overrides.git.

Adding the Recipe

Clone your meta-subscriber-overrides.git repo and enter its directory:

git clone https://source.foundries.io/factories/<factory>/meta-subscriber-overrides.git
cd meta-subscriber-overrides

Edit recipes-samples/images/lmp-factory-image.bb, adding the recipe to the CORE_IMAGE_BASE_INSTALL list:

diff --git a/recipes-samples/images/lmp-factory-image.bb b/recipes-samples/images/lmp-factory-image.bb
--- a/recipes-samples/images/lmp-factory-image.bb
+++ b/recipes-samples/images/lmp-factory-image.bb
@@ -30,6 +30,7 @@ CORE_IMAGE_BASE_INSTALL += " \
     networkmanager-nmcli \
     git \
     vim \
+    lmp-auto-hostname \
     packagegroup-core-full-cmdline-extended \
     ${@bb.utils.contains('LMP_DISABLE_GPLV3', '1', '', '${CORE_IMAGE_BASE_INSTALL_GPLV3}', d)} \
"

LmP Auto Hostname Variables

The lmp-auto-hostname recipe can be configured through variables.

LMP_HOSTNAME_MODE=<option>
Default: serial
serial

Appends the serial number of the device:

raspberrypi4-64-100000008305bbc3

mac

Appends the MAC address of a chosen network interface.

raspberrypi4-64-dca6321669ea

LMP_HOSTNAME_NETDEVICE=<interface>
Default: eth0

If using mac mode, provide the device network interface to retrieve a MAC address from:

eth0 or wlan0

Configuring the LmP Auto Hostname

Select the Serial or MAC tab below, according to your needs.

Serial is configured by default in the lmp-auto-hostname recipe, no need for extra changes. Add the recipes-samples/images/lmp-factory-image.bb file, commit, and push:

git commit -m "lmp-auto-hostname: Adding recipe" recipes-samples/images/lmp-factory-image.bb
git push

The latest Target named platform-devel should be the CI job you just created.

If your device is already registered, when all jobs finish, wait until the Over-the-Air update completes. Otherwise download and flash the image.

Testing Auto Hostname

Log in to the device via SSH and check the new hostname (right after fio@). You can also check /etc/hostname to confirm the new hostname.

cat /etc/hostname
raspberrypi3-64-51ca7875