Install server openHAB on a android tablet

Hi all!
I’m sorry for the machine translation.
This solution has been working successfully for 2 weeks

For installation, we need a tablet with root privileges!
I am using Acer Iconia Tab A511 with installed modified firmware CyanogenMod 11 [4.4.4]

Tablet uses NVIDIA Tegra 3. Four main cores can operate at frequencies up to 1.6 GHz which is not bad.

Tried to install CyanogenMod 12.1 [5.1.1] but there were problems with WIFI in this firmware.

Next, we need the Linux Deploy program, with this program you can install Linux that runs in the chroot environment.

If you have an android version less than 5.0 (API 21) on your tablet, then version 2.6.0 will not work. On my 4.4, I installed 2.5.1 version.

After launching the application, go to settings. Here are my settings:

You can change the “User Name”, “Password” as you wish, later Password can be changed in Linux. Selected distribution, the architecture depends on the tablet processor and the Android kernel.
Installation type = file is the most optimal.
Image size can install more.
Also install checkbox SSH.
Exit the settings, click on 3 points and select Installation, wait 15-20 minutes.
After the <<< deploy message appears, the installation is complete and you can try to start Linux and connect through the SSH client.
If everything worked out, then we begin to install the openHAB server.

sudo apt update && sudo apt upgrade
sudo apt-get install mc
sudo apt-get install wget

First we install Java, we will use Zulu. Since we have a 32-bit processor with hard float support, select the following distribution:

Loading …

wget -O zulu8.tar.gz
sudo tar -xzvf zulu8.tar.gz -C /opt/
cd /opt
sudo mv zulu8.46.0.225-ca-jdk8.0.252-linux_aarch32hf zulu8
sudo chown -hR openhab:openhab /opt/zulu8

Install the openhab package:

wget -qO - '' | sudo apt-key add -
sudo apt-get install apt-transport-https
echo 'deb stable main' | sudo tee /etc/apt/sources.list.d/openhab2.list
sudo apt-get update
sudo apt-get install openhab2

After installing the package, slightly modify the openhab service startup script,
open the file /etc/init.d/openhab2 at the beginning of the file we find the line PATH = … and replace it with the addition of several lines above this line:

export JAVA_HOME
export JRE_HOME


After that, you can start the openHAB service. The first launch will be longer.

sudo service openhab2 start

It runs? So that’s great! We still need to install a couple more packages:

sudo apt-get install samba
sudo smbpasswd -a openhab
echo "[openHAB2-conf]  comment=openHAB2 site configuration  path=/etc/openhab2  browseable=Yes  writeable=Yes  only guest=no  public=no  create mask=0777  directory mask=0777" >> /etc/samba/smb.conf

Do not forget to edit smb.conf file rastavit line break.

Most likely you will need mosquitto:

sudo apt-get install software-properties-common
sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
sudo apt-get update
sudo apt-get install mosquitto

If you get an error:
E: Sub-process /usr/bin/dpkg returned an error code (1)
You must manually copy the contents of the package to the directory:

run MC
cd /var/cache/apt/archives/
enter mosquitto_1.6.3-0mosquitto1~trusty1_armhf.deb
copy CONTENTS to root "/"

The next trick is that to save the life of flash memory, the rrd4j base will be stored in RAM. And for backup, an external microUSB card.
To do this, stop Linux with the “stop” button and go to the settings and set the checkbox “INIT” and “MOUNTS”

mount point should be /mnt/sd

Launch Linux again and edit the /etc/rc.local file:

#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.
# echo "$1" >> /tmp/start.log
service mosquitto $1
service smbd $1
case "$1" in
	/etc/ $1
service openhab2 $1
case "$1" in
	/etc/ $1
exit 0 

Create a new file /etc/

#!/bin/sh -e

# Read configuration variable file if it is present
if [ -r /etc/default/openhab2 ]; then
  . /etc/default/openhab2
# Read and set openHAB variables set in /etc/default/ scripts
if [ -z "${OPENHAB_USERDATA}" ];   then OPENHAB_USERDATA="/var/lib/openhab2"; fi
if [ -z "${OPENHAB_USER}" ];       then OPENHAB_USER="openhab"; fi
if [ -z "${OPENHAB_GROUP}" ];      then OPENHAB_GROUP="openhab"; fi

case "$1" in
    if [ ! -d "/mnt/ramdisk/" ]; then
      mkdir -p "/mnt/ramdisk/"
    mount -t tmpfs -o rw,size=10M tmpfs /mnt/ramdisk
    mkdir /mnt/ramdisk/persistence
    if [ ! -h "${OPENHAB_USERDATA}/persistence" ]; then
	ln -s -d /mnt/ramdisk/persistence "${OPENHAB_USERDATA}/"
    cp -R /mnt/sd/persistence/. /mnt/ramdisk/persistence
    chown -hR "${OPENHAB_USER}":"${OPENHAB_GROUP}" /mnt/ramdisk/.
    cp -R /mnt/ramdisk/persistence/.  /mnt/sd/persistence
    umount /mnt/ramdisk
    cp -R /mnt/ramdisk/persistence/.  /mnt/sd/persistence
    echo "Usage: {start|stop|save}"
    exit 3

Done, the finishing touches: in the settings of the Linux Deploy program we set autoload.

To display habpanel, a modified habpanelviewer is used, since the original version heavily loads the processor.
Wake up the tablet using Motion Detector.
You will also need Wake Lock - PowerManager for blocking falling asleep WIFI

Well, that’s all I wanted to write briefly.
Good luck to all!


Thank you for the guide, I have used it to install openhab 3.2 on Xiaomi Mi A1 with Pixel Experience rom.
I have tried also with different version of ubuntu with xenial and bionic but nothing worked, there was an error with chroot every time :frowning: . I will try to bump the version of ubuntu later to see what I get.