LibreELEC entware-ng installation (opkg / optware)

Published on Author Artem Butusov5 Comments

Why?

LibreELEC is perfect linux distro for running Kodi almost everywhere.

LibreELEC has a powerful add-on system and it also has docker container support, so technically you could run everything you need inside docker container.

But sometimes it is not enough. All (or almost all) Linux distros have their package manager with set of well known packages and either binaries or build files for them. While LibreELEC has its own build system and you could use it to add support for another packages but in that case you will have rebuild almost whole LibreELEC.

Building customized version of LibreELEC could be overkill if you need to install something like Midnight Commander or cron, right?

Here is one possible solution – use entware-ng.

There are other optware-like alternatives, but I found that entware-ng is supported better than others.

Alternatives:

  • optware / optware-ng: http://www.nslu2-linux.org/wiki/pmwiki.php?pagename=Optware/HomePage/
  • entware-ng-3.x (NEW!!!): https://github.com/Entware-for-kernel-3x/Entware-ng-3x

entware-ng is tiny and has minimalistic package manager designed for embedded systems.

Fix LibreELEC image

To be able to easy work with entware-ng we will need folder in root /opt. LibreELEC uses read only root filesystem so we will have to fix system image.

My LibreELEC is installed on SD card and I also have OS X on my laptop.

Prerequisites:

  • OS X (but it could be Linux too but instruction how to install squashfs is different)
  • Homebrew package manager installed: https://brew.sh
  • In terminal: brew install squashfs

Actions:

  • Disconnect SD card
  • Connect SD card to OS X
  • Connected volume should have label “LIBREELEC”
  • Open terminal
cd /Volumes/LIBREELEC
mkdir -p new/opt
mksquashfs new SYSTEM -all-root
rm -rf new
  • Thats it, now SYSTEM image should have /opt directory and you could connect SD card back to your media player
  • You will need to do this step each time you will update LibreELEC system image.

Connect to LibreELEC over SSH

Enable SSH access in LibreELEC configuration or during setup. Remember hostname, by default, it is LibreELEC.

Run from terminal: ssh root@LibreELEC.local (or CustomHostname.local)

Install entware-ng

Root filesystem is still unreadable, but /storage has read-write access, so we could install entware-ng into, for example, /storage/opt and bind /opt to /storage/opt (thats why we created /opt in the root).

Install opkg:

mkdir -p /storage/opt
mount -o bind /storage/opt /opt
wget -O - http://pkg.entware.net/binaries/armv7/installer/entware_install.sh | sh
export PATH=$PATH:/opt/bin:/opt/sbin
opkg update
opkg install coreutils-expr

Make /opt bind persistent:

Run: nano -w /storage/.config/system.d/opt.mount

Please note, filename opt.mount make sense here: /{name} -> {name}.mount.

[Unit]
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target

[Mount]
What=/storage/opt
Where=/opt
Type=none
Options=bind

[Install]
WantedBy=local-fs.target

Enable mount point to be activates on reboot:

systemctl enable opt.mount

Fix profile to have entware-ng available in SSH session by default and enable unicode:

Run: nano /storage/.profile

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8

export PATH=$PATH:/opt/bin:/opt/sbin

Now you could reboot LibreELEC and test if changes are persistent. After reboot you should be able to:

  • connect to LibreELEC over SSH
  • see that /opt is mounted. ls /opt should show files (test for /opt bind)
  • opkg list should show list of available packages (test for PATH in profile)

Usage

Now you could install packages available in entware-ng with opkg package manager.

  • opkg list will show list of available packages.
  • opkg list | grep package will help you to find needed package.
  • opkg install package will install package
  • some packages are designed to be daemonized, for example cron.
    • init scripts are located here: /opt/etc/init.d
    • you could start service with /opt/etc/init.d/SXX{name} start
    • you could stop service with /opt/etc/init.d/SXX{name} stop
    • services should be also wrapped into systemd config files to persist their state on reboot
  • opkg uninstall package will uninstall package

Examples

midnight commander (application)

Install mc: opkg install mc

Thats it 🙂

cron (service)

Install cron: opkg install cron

Wrap service into systemd config: nano -w /storage/.config/system.d/cron.service

[Unit]
Requires=network-online.service

[Service]
Type=oneshot
ExecStart=/opt/etc/init.d/S10cron start
ExecStop=/opt/etc/init.d/S10cron stop
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Auto start service on reboot: systemctl enable cron.service

Start service now: systemctl start cron.service

This is a perfect example how easy could be to install binary package with entware-ng.

dnsmasq (service)

Below is example how to setup dnsmasq with ads blacklist.

Download ads domains blacklist in hosts file format:

cd /opt/etc && wget https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts

Install dnsmasq: opkg install dnsmasq-full

Run: nano -w /opt/etc/dnsmasq.conf

server=8.8.8.8
server=8.8.4.4
addn-hosts=/opt/etc/hosts

Wrap service into systemd config: nano -w /storage/.config/system.d/dnsmasq.service

[Unit]
Requires=network-online.service

[Service]
Type=oneshot
ExecStart=/opt/etc/init.d/S56dnsmasq start
ExecStop=/opt/etc/init.d/S56dnsmasq stop
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Auto start service on reboot: systemctl enable dnsmasq.service

Start service now: systemctl start dnsmasq.service

Now you could set for any device at home main DNS server address to LibreELEC ip address and all (almost) ads will be removed.

Another perfect example how easy is entware-ng.

5 Responses to LibreELEC entware-ng installation (opkg / optware)

  1. Thank you for this guide. I followed it on my mac so everything should work. I would like to install shairport-sync on Rasplex which is based on LibreELEC.
    I get stuck at the line opkg update. I get: Illegal instruction (core dumped)
    I’ve tried this on a fresh LibreELEC install as well to see if that makes any difference but I get the same error.

    Could you please help to find a solution?

    Thank you.

    • Illegal instruction means that you are trying to use binaries from another architecture. What hardware do you have? You need to pick right architecture during opkg bootstrap.

      • Thank you for your reply. Yes, I’ve tried to install on the wrong architecture, I’m using a Pi zero W, which is armv6.
        I could make it work on a RPi 3, however, I’m still struggling to make shairport-sync work and also I couldn’t make the mount of /opt persistent.

Leave a Reply

Your email address will not be published. Required fields are marked *