OrangePi: Installing Debian chroot into OpenELEC

Hi all,

I have an OrangePi running jernej’s OpenELEC build connected to my TV.  It works very well and stable, but on the other side, you can’t do much more with it because OE is very limited Linux distribution. This is a short guide how to run standard Debian services (nginx, samba, openvpn, … anything) in Debian chroot.

First we need to prepare chroot filesystem (run on Ubuntu machine).
If you are lazy to create it, you can download it here and skip this step.

my_pc:~$ apt install debootstrap
my_pc:~$ mkdir debian_armhf
my_pc:~$ sudo debootstrap --foreign --arch armhf stable debian_armhf http://ftp.cz.debian.org/debian
W: Cannot check Release signature; keyring file not available /usr/share/keyrings/debian-archive-keyring.gpg
I: Retrieving InRelease
I: Failed to retrieve InRelease
I: Retrieving Release
I: Retrieving Packages
I: Validating Packages
I: Resolving dependencies of required packages...
I: Resolving dependencies of base packages...
I: Found additional required dependencies: acl adduser dmsetup insserv libaudit1 libaudit-common libbz2-1.0 libcap2 libcap2-bin libcryptsetup4 libdb5.3 libdebconfclient0 libdevmapper1.02.1 libgcrypt20 libgpg-error0 libkmod2 libncursesw5 libprocps3 libsemanage1 libsemanage-common libslang2 libsystemd0 libudev1 libustr-1.0-1 procps systemd systemd-sysv udev
I: Found additional base dependencies: libdns-export100 libffi6 libgmp10 libgnutls-deb0-28 libgnutls-openssl27 libhogweed2 libicu52 libidn11 libirs-export91 libisccfg-export90 libisc-export95 libmnl0 libnetfilter-acct1 libnettle4 libnfnetlink0 libp11-kit0 libpsl0 libtasn1-6
I: Checking component main on http://ftp.cz.debian.org/debian...
I: Retrieving acl 2.2.52-2
I: Validating acl 2.2.52-2
I: Retrieving libacl1 2.2.52-2
I: Validating libacl1 2.2.52-2
I: Retrieving adduser 3.113+nmu3
I: Validating adduser 3.113+nmu3
I: Retrieving apt 1.0.9.8.4
I: Validating apt 1.0.9.8.4
I: Retrieving apt-utils 1.0.9.8.4
I: Validating apt-utils 1.0.9.8.4
I: Retrieving libapt-inst1.5 1.0.9.8.4
I: Validating libapt-inst1.5 1.0.9.8.4
I: Retrieving libapt-pkg4.12 1.0.9.8.4
I: Validating libapt-pkg4.12 1.0.9.8.4
I: Retrieving libattr1 1:2.4.47-2
I: Validating libattr1 1:2.4.47-2
I: Retrieving libaudit-common 1:2.4-1
I: Validating libaudit-common 1:2.4-1
I: Retrieving libaudit1 1:2.4-1+b1
I: Validating libaudit1 1:2.4-1+b1
I: Retrieving base-files 8+deb8u7
I: Validating base-files 8+deb8u7
I: Retrieving base-passwd 3.5.37
I: Validating base-passwd 3.5.37
I: Retrieving bash 4.3-11+deb8u1
I: Validating bash 4.3-11+deb8u1
I: Retrieving libdns-export100 1:9.9.5.dfsg-9+deb8u8
I: Validating libdns-export100 1:9.9.5.dfsg-9+deb8u8
I: Retrieving libirs-export91 1:9.9.5.dfsg-9+deb8u8
I: Validating libirs-export91 1:9.9.5.dfsg-9+deb8u8
I: Retrieving libisc-export95 1:9.9.5.dfsg-9+deb8u8
I: Validating libisc-export95 1:9.9.5.dfsg-9+deb8u8
I: Retrieving libisccfg-export90 1:9.9.5.dfsg-9+deb8u8
I: Validating libisccfg-export90 1:9.9.5.dfsg-9+deb8u8
I: Retrieving libboost-iostreams1.55.0 1.55.0+dfsg-3
I: Validating libboost-iostreams1.55.0 1.55.0+dfsg-3
I: Retrieving bsdmainutils 9.0.6
I: Validating bsdmainutils 9.0.6
I: Retrieving libbz2-1.0 1.0.6-7+b3
I: Validating libbz2-1.0 1.0.6-7+b3
I: Retrieving libdebconfclient0 0.192
I: Validating libdebconfclient0 0.192
I: Retrieving coreutils 8.23-4
I: Validating coreutils 8.23-4
I: Retrieving cpio 2.11+dfsg-4.1+deb8u1
I: Validating cpio 2.11+dfsg-4.1+deb8u1
I: Retrieving cron 3.0pl1-127+deb8u1
I: Validating cron 3.0pl1-127+deb8u1
I: Retrieving libcryptsetup4 2:1.6.6-5
I: Validating libcryptsetup4 2:1.6.6-5
I: Retrieving dash 0.5.7-4+b1
I: Validating dash 0.5.7-4+b1
I: Retrieving libdb5.3 5.3.28-9
I: Validating libdb5.3 5.3.28-9
I: Retrieving debconf 1.5.56
I: Validating debconf 1.5.56
I: Retrieving debconf-i18n 1.5.56
I: Validating debconf-i18n 1.5.56
I: Retrieving debian-archive-keyring 2014.3
I: Validating debian-archive-keyring 2014.3
I: Retrieving debianutils 4.4+b1
I: Validating debianutils 4.4+b1
I: Retrieving diffutils 1:3.3-1+b1
I: Validating diffutils 1:3.3-1+b1
I: Retrieving dmidecode 2.12-3
I: Validating dmidecode 2.12-3
I: Retrieving dpkg 1.17.27
I: Validating dpkg 1.17.27
I: Retrieving e2fslibs 1.42.12-2+b1
I: Validating e2fslibs 1.42.12-2+b1
I: Retrieving e2fsprogs 1.42.12-2+b1
I: Validating e2fsprogs 1.42.12-2+b1
I: Retrieving libcomerr2 1.42.12-2+b1
I: Validating libcomerr2 1.42.12-2+b1
I: Retrieving libss2 1.42.12-2+b1
I: Validating libss2 1.42.12-2+b1
I: Retrieving findutils 4.4.2-9+b1
I: Validating findutils 4.4.2-9+b1
I: Retrieving gcc-4.8-base 4.8.4-1
I: Validating gcc-4.8-base 4.8.4-1
I: Retrieving gcc-4.9-base 4.9.2-10
I: Validating gcc-4.9-base 4.9.2-10
I: Retrieving libgcc1 1:4.9.2-10
I: Validating libgcc1 1:4.9.2-10
I: Retrieving libstdc++6 4.9.2-10
I: Validating libstdc++6 4.9.2-10
I: Retrieving libgdbm3 1.8.3-13.1
I: Validating libgdbm3 1.8.3-13.1
I: Retrieving libc-bin 2.19-18+deb8u7
I: Validating libc-bin 2.19-18+deb8u7
I: Retrieving libc6 2.19-18+deb8u7
I: Validating libc6 2.19-18+deb8u7
I: Retrieving multiarch-support 2.19-18+deb8u7
I: Validating multiarch-support 2.19-18+deb8u7
I: Retrieving libgmp10 2:6.0.0+dfsg-6
I: Validating libgmp10 2:6.0.0+dfsg-6
I: Retrieving gnupg 1.4.18-7+deb8u3
I: Validating gnupg 1.4.18-7+deb8u3
I: Retrieving gpgv 1.4.18-7+deb8u3
I: Validating gpgv 1.4.18-7+deb8u3
I: Retrieving libgnutls-deb0-28 3.3.8-6+deb8u4
I: Validating libgnutls-deb0-28 3.3.8-6+deb8u4
I: Retrieving libgnutls-openssl27 3.3.8-6+deb8u4
I: Validating libgnutls-openssl27 3.3.8-6+deb8u4
I: Retrieving grep 2.20-4.1
I: Validating grep 2.20-4.1
I: Retrieving groff-base 1.22.2-8
I: Validating groff-base 1.22.2-8
I: Retrieving gzip 1.6-4
I: Validating gzip 1.6-4
I: Retrieving hostname 3.15
I: Validating hostname 3.15
I: Retrieving libicu52 52.1-8+deb8u4
I: Validating libicu52 52.1-8+deb8u4
I: Retrieving ifupdown 0.7.53.1
I: Validating ifupdown 0.7.53.1
I: Retrieving init 1.22
I: Validating init 1.22
I: Retrieving init-system-helpers 1.22
I: Validating init-system-helpers 1.22
I: Retrieving insserv 1.14.0-5
I: Validating insserv 1.14.0-5
I: Retrieving iproute2 3.16.0-2
I: Validating iproute2 3.16.0-2
I: Retrieving iptables 1.4.21-2+b1
I: Validating iptables 1.4.21-2+b1
I: Retrieving libxtables10 1.4.21-2+b1
I: Validating libxtables10 1.4.21-2+b1
I: Retrieving iputils-ping 3:20121221-5+b2
I: Validating iputils-ping 3:20121221-5+b2
I: Retrieving isc-dhcp-client 4.3.1-6+deb8u2
I: Validating isc-dhcp-client 4.3.1-6+deb8u2
I: Retrieving isc-dhcp-common 4.3.1-6+deb8u2
I: Validating isc-dhcp-common 4.3.1-6+deb8u2
I: Retrieving libjson-c2 0.11-4
I: Validating libjson-c2 0.11-4
I: Retrieving kmod 18-3
I: Validating kmod 18-3
I: Retrieving libkmod2 18-3
I: Validating libkmod2 18-3
I: Retrieving less 458-3
I: Validating less 458-3
I: Retrieving libcap2 1:2.24-8
I: Validating libcap2 1:2.24-8
I: Retrieving libcap2-bin 1:2.24-8
I: Validating libcap2-bin 1:2.24-8
I: Retrieving libestr0 0.1.9-1.1
I: Validating libestr0 0.1.9-1.1
I: Retrieving libffi6 3.1-2+b2
I: Validating libffi6 3.1-2+b2
I: Retrieving libgcrypt20 1.6.3-2+deb8u2
I: Validating libgcrypt20 1.6.3-2+deb8u2
I: Retrieving libgpg-error0 1.17-3
I: Validating libgpg-error0 1.17-3
I: Retrieving libidn11 1.29-1+deb8u2
I: Validating libidn11 1.29-1+deb8u2
I: Retrieving liblocale-gettext-perl 1.05-8+b1
I: Validating liblocale-gettext-perl 1.05-8+b1
I: Retrieving liblogging-stdlog0 1.0.4-1
I: Validating liblogging-stdlog0 1.0.4-1
I: Retrieving liblognorm1 1.0.1-3
I: Validating liblognorm1 1.0.1-3
I: Retrieving libmnl0 1.0.3-5
I: Validating libmnl0 1.0.3-5
I: Retrieving libnetfilter-acct1 1.0.2-1.1
I: Validating libnetfilter-acct1 1.0.2-1.1
I: Retrieving libnfnetlink0 1.0.1-3
I: Validating libnfnetlink0 1.0.1-3
I: Retrieving libpipeline1 1.4.0-1
I: Validating libpipeline1 1.4.0-1
I: Retrieving libpsl0 0.5.1-1
I: Validating libpsl0 0.5.1-1
I: Retrieving libselinux1 2.3-2
I: Validating libselinux1 2.3-2
I: Retrieving libsemanage-common 2.3-1
I: Validating libsemanage-common 2.3-1
I: Retrieving libsemanage1 2.3-1+b1
I: Validating libsemanage1 2.3-1+b1
I: Retrieving libsepol1 2.3-2
I: Validating libsepol1 2.3-2
I: Retrieving libsigc++-2.0-0c2a 2.4.0-1
I: Validating libsigc++-2.0-0c2a 2.4.0-1
I: Retrieving libtasn1-6 4.2-3+deb8u2
I: Validating libtasn1-6 4.2-3+deb8u2
I: Retrieving libtext-charwidth-perl 0.04-7+b4
I: Validating libtext-charwidth-perl 0.04-7+b4
I: Retrieving libtext-iconv-perl 1.7-5+b2
I: Validating libtext-iconv-perl 1.7-5+b2
I: Retrieving libtext-wrapi18n-perl 0.06-7
I: Validating libtext-wrapi18n-perl 0.06-7
I: Retrieving libusb-0.1-4 2:0.1.12-25
I: Validating libusb-0.1-4 2:0.1.12-25
I: Retrieving logrotate 3.8.7-1+b1
I: Validating logrotate 3.8.7-1+b1
I: Retrieving lsb-base 4.1+Debian13+nmu1
I: Validating lsb-base 4.1+Debian13+nmu1
I: Retrieving dmsetup 2:1.02.90-2.2+deb8u1
I: Validating dmsetup 2:1.02.90-2.2+deb8u1
I: Retrieving libdevmapper1.02.1 2:1.02.90-2.2+deb8u1
I: Validating libdevmapper1.02.1 2:1.02.90-2.2+deb8u1
I: Retrieving man-db 2.7.0.2-5
I: Validating man-db 2.7.0.2-5
I: Retrieving manpages 3.74-1
I: Validating manpages 3.74-1
I: Retrieving mawk 1.3.3-17
I: Validating mawk 1.3.3-17
I: Retrieving nano 2.2.6-3
I: Validating nano 2.2.6-3
I: Retrieving libncurses5 5.9+20140913-1+b1
I: Validating libncurses5 5.9+20140913-1+b1
I: Retrieving libncursesw5 5.9+20140913-1+b1
I: Validating libncursesw5 5.9+20140913-1+b1
I: Retrieving libtinfo5 5.9+20140913-1+b1
I: Validating libtinfo5 5.9+20140913-1+b1
I: Retrieving ncurses-base 5.9+20140913-1
I: Validating ncurses-base 5.9+20140913-1
I: Retrieving ncurses-bin 5.9+20140913-1+b1
I: Validating ncurses-bin 5.9+20140913-1+b1
I: Retrieving net-tools 1.60-26+b1
I: Validating net-tools 1.60-26+b1
I: Retrieving netbase 5.3
I: Validating netbase 5.3
I: Retrieving netcat-traditional 1.10-41
I: Validating netcat-traditional 1.10-41
I: Retrieving libhogweed2 2.7.1-5+deb8u2
I: Validating libhogweed2 2.7.1-5+deb8u2
I: Retrieving libnettle4 2.7.1-5+deb8u2
I: Validating libnettle4 2.7.1-5+deb8u2
I: Retrieving libnewt0.52 0.52.17-1+b1
I: Validating libnewt0.52 0.52.17-1+b1
I: Retrieving whiptail 0.52.17-1+b1
I: Validating whiptail 0.52.17-1+b1
I: Retrieving nfacct 1.0.1-1.1
I: Validating nfacct 1.0.1-1.1
I: Retrieving libssl1.0.0 1.0.1t-1+deb8u5
I: Validating libssl1.0.0 1.0.1t-1+deb8u5
I: Retrieving libp11-kit0 0.20.7-1
I: Validating libp11-kit0 0.20.7-1
I: Retrieving libpam-modules 1.1.8-3.1+deb8u2
I: Validating libpam-modules 1.1.8-3.1+deb8u2
I: Retrieving libpam-modules-bin 1.1.8-3.1+deb8u2
I: Validating libpam-modules-bin 1.1.8-3.1+deb8u2
I: Retrieving libpam-runtime 1.1.8-3.1+deb8u2
I: Validating libpam-runtime 1.1.8-3.1+deb8u2
I: Retrieving libpam0g 1.1.8-3.1+deb8u2
I: Validating libpam0g 1.1.8-3.1+deb8u2
I: Retrieving libpcre3 2:8.35-3.3+deb8u4
I: Validating libpcre3 2:8.35-3.3+deb8u4
I: Retrieving perl-base 5.20.2-3+deb8u6
I: Validating perl-base 5.20.2-3+deb8u6
I: Retrieving libpopt0 1.16-10
I: Validating libpopt0 1.16-10
I: Retrieving libprocps3 2:3.3.9-9
I: Validating libprocps3 2:3.3.9-9
I: Retrieving procps 2:3.3.9-9
I: Validating procps 2:3.3.9-9
I: Retrieving libreadline6 6.3-8+b3
I: Validating libreadline6 6.3-8+b3
I: Retrieving readline-common 6.3-8
I: Validating readline-common 6.3-8
I: Retrieving rsyslog 8.4.2-1+deb8u2
I: Validating rsyslog 8.4.2-1+deb8u2
I: Retrieving sed 4.2.2-4+deb8u1
I: Validating sed 4.2.2-4+deb8u1
I: Retrieving sensible-utils 0.0.9
I: Validating sensible-utils 0.0.9
I: Retrieving login 1:4.2-3+deb8u1
I: Validating login 1:4.2-3+deb8u1
I: Retrieving passwd 1:4.2-3+deb8u1
I: Validating passwd 1:4.2-3+deb8u1
I: Retrieving libslang2 2.3.0-2
I: Validating libslang2 2.3.0-2
I: Retrieving startpar 0.59-3
I: Validating startpar 0.59-3
I: Retrieving libsystemd0 215-17+deb8u6
I: Validating libsystemd0 215-17+deb8u6
I: Retrieving libudev1 215-17+deb8u6
I: Validating libudev1 215-17+deb8u6
I: Retrieving systemd 215-17+deb8u6
I: Validating systemd 215-17+deb8u6
I: Retrieving systemd-sysv 215-17+deb8u6
I: Validating systemd-sysv 215-17+deb8u6
I: Retrieving udev 215-17+deb8u6
I: Validating udev 215-17+deb8u6
I: Retrieving initscripts 2.88dsf-59
I: Validating initscripts 2.88dsf-59
I: Retrieving sysv-rc 2.88dsf-59
I: Validating sysv-rc 2.88dsf-59
I: Retrieving sysvinit-utils 2.88dsf-59
I: Validating sysvinit-utils 2.88dsf-59
I: Retrieving tar 1.27.1-2+deb8u1
I: Validating tar 1.27.1-2+deb8u1
I: Retrieving tasksel 3.31+deb8u1
I: Validating tasksel 3.31+deb8u1
I: Retrieving tasksel-data 3.31+deb8u1
I: Validating tasksel-data 3.31+deb8u1
I: Retrieving traceroute 1:2.0.20-2+b1
I: Validating traceroute 1:2.0.20-2+b1
I: Retrieving tzdata 2016j-0+deb8u1
I: Validating tzdata 2016j-0+deb8u1
I: Retrieving libustr-1.0-1 1.0.4-3+b2
I: Validating libustr-1.0-1 1.0.4-3+b2
I: Retrieving bsdutils 1:2.25.2-6
I: Validating bsdutils 1:2.25.2-6
I: Retrieving libblkid1 2.25.2-6
I: Validating libblkid1 2.25.2-6
I: Retrieving libmount1 2.25.2-6
I: Validating libmount1 2.25.2-6
I: Retrieving libsmartcols1 2.25.2-6
I: Validating libsmartcols1 2.25.2-6
I: Retrieving libuuid1 2.25.2-6
I: Validating libuuid1 2.25.2-6
I: Retrieving mount 2.25.2-6
I: Validating mount 2.25.2-6
I: Retrieving util-linux 2.25.2-6
I: Validating util-linux 2.25.2-6
I: Retrieving vim-common 2:7.4.488-7+deb8u1
I: Validating vim-common 2:7.4.488-7+deb8u1
I: Retrieving vim-tiny 2:7.4.488-7+deb8u1
I: Validating vim-tiny 2:7.4.488-7+deb8u1
I: Retrieving wget 1.16-1+deb8u1
I: Validating wget 1.16-1+deb8u1
I: Retrieving liblzma5 5.1.1alpha+20120614-2+b3
I: Validating liblzma5 5.1.1alpha+20120614-2+b3
I: Retrieving zlib1g 1:1.2.8.dfsg-2+b1
I: Validating zlib1g 1:1.2.8.dfsg-2+b1
I: Chosen extractor for .deb packages: dpkg-deb
I: Extracting acl...
I: Extracting libacl1...
I: Extracting adduser...
I: Extracting libattr1...
I: Extracting libaudit-common...
I: Extracting libaudit1...
I: Extracting base-files...
I: Extracting base-passwd...
I: Extracting bash...
I: Extracting libbz2-1.0...
I: Extracting libdebconfclient0...
I: Extracting coreutils...
I: Extracting libcryptsetup4...
I: Extracting dash...
I: Extracting libdb5.3...
I: Extracting debconf...
I: Extracting debconf-i18n...
I: Extracting debianutils...
I: Extracting diffutils...
I: Extracting dpkg...
I: Extracting e2fslibs...
I: Extracting e2fsprogs...
I: Extracting libcomerr2...
I: Extracting libss2...
I: Extracting findutils...
I: Extracting gcc-4.8-base...
I: Extracting gcc-4.9-base...
I: Extracting libgcc1...
I: Extracting libc-bin...
I: Extracting libc6...
I: Extracting multiarch-support...
I: Extracting grep...
I: Extracting gzip...
I: Extracting hostname...
I: Extracting init...
I: Extracting insserv...
I: Extracting libkmod2...
I: Extracting libcap2...
I: Extracting libcap2-bin...
I: Extracting libgcrypt20...
I: Extracting libgpg-error0...
I: Extracting liblocale-gettext-perl...
I: Extracting libselinux1...
I: Extracting libsemanage-common...
I: Extracting libsemanage1...
I: Extracting libsepol1...
I: Extracting libtext-charwidth-perl...
I: Extracting libtext-iconv-perl...
I: Extracting libtext-wrapi18n-perl...
I: Extracting lsb-base...
I: Extracting dmsetup...
I: Extracting libdevmapper1.02.1...
I: Extracting mawk...
I: Extracting libncurses5...
I: Extracting libncursesw5...
I: Extracting libtinfo5...
I: Extracting ncurses-base...
I: Extracting ncurses-bin...
I: Extracting libpam-modules...
I: Extracting libpam-modules-bin...
I: Extracting libpam-runtime...
I: Extracting libpam0g...
I: Extracting libpcre3...
I: Extracting perl-base...
I: Extracting libprocps3...
I: Extracting procps...
I: Extracting sed...
I: Extracting sensible-utils...
I: Extracting login...
I: Extracting passwd...
I: Extracting libslang2...
I: Extracting startpar...
I: Extracting libsystemd0...
I: Extracting libudev1...
I: Extracting systemd...
I: Extracting systemd-sysv...
I: Extracting udev...
I: Extracting initscripts...
I: Extracting sysv-rc...
I: Extracting sysvinit-utils...
I: Extracting tar...
I: Extracting tzdata...
I: Extracting libustr-1.0-1...
I: Extracting bsdutils...
I: Extracting libblkid1...
I: Extracting libmount1...
I: Extracting libsmartcols1...
I: Extracting libuuid1...
I: Extracting mount...
I: Extracting util-linux...
I: Extracting liblzma5...
I: Extracting zlib1g...
my_pc~$ sudo tar -zcf debian_armhf.tgz debian_armhf
my_pc~$ scp debian_armhf.tgz  root@<OE_IP>:/storage/

Now ssh into your OE and run:

OE~# tar -zxf debian_armhf.tgz
OE~# env -i /sbin/chroot debian_armhf /bin/bash
#### now you should be in chroot ####
chroot~# /debootstrap/debootstrap --second-stage
I: Keyring file not available at /usr/share/keyrings/debian-archive-keyring.gpg; switching to https mirror https://mirrors.kernel.org/debian
I: Installing core packages...
I: Unpacking required packages...
I: Unpacking acl...
I: Unpacking libacl1:armhf...
I: Unpacking adduser...
I: Unpacking libattr1:armhf...
I: Unpacking libaudit-common...
I: Unpacking libaudit1:armhf...
I: Unpacking base-files...
I: Unpacking base-passwd...
I: Unpacking bash...
I: Unpacking libbz2-1.0:armhf...
I: Unpacking libdebconfclient0:armhf...
I: Unpacking coreutils...
I: Unpacking libcryptsetup4:armhf...
I: Unpacking dash...
I: Unpacking libdb5.3:armhf...
I: Unpacking debconf...
I: Unpacking debconf-i18n...
I: Unpacking debianutils...
I: Unpacking diffutils...
I: Unpacking dpkg...
I: Unpacking e2fslibs:armhf...
I: Unpacking e2fsprogs...
I: Unpacking libcomerr2:armhf...
I: Unpacking libss2:armhf...
I: Unpacking findutils...
I: Unpacking gcc-4.8-base:armhf...
I: Unpacking gcc-4.9-base:armhf...
I: Unpacking libgcc1:armhf...
I: Unpacking libc-bin...
I: Unpacking libc6:armhf...
I: Unpacking multiarch-support...
I: Unpacking grep...
I: Unpacking gzip...
I: Unpacking hostname...
I: Unpacking init...
I: Unpacking insserv...
I: Unpacking libkmod2:armhf...
I: Unpacking libcap2:armhf...
I: Unpacking libcap2-bin...
I: Unpacking libgcrypt20:armhf...
I: Unpacking libgpg-error0:armhf...
I: Unpacking liblocale-gettext-perl...
I: Unpacking libselinux1:armhf...
I: Unpacking libsemanage-common...
I: Unpacking libsemanage1:armhf...
I: Unpacking libsepol1:armhf...
I: Unpacking libtext-charwidth-perl...
I: Unpacking libtext-iconv-perl...
I: Unpacking libtext-wrapi18n-perl...
I: Unpacking lsb-base...
I: Unpacking dmsetup...
I: Unpacking libdevmapper1.02.1:armhf...
I: Unpacking mawk...
I: Unpacking libncurses5:armhf...
I: Unpacking libncursesw5:armhf...
I: Unpacking libtinfo5:armhf...
I: Unpacking ncurses-base...
I: Unpacking ncurses-bin...
I: Unpacking libpam-modules:armhf...
I: Unpacking libpam-modules-bin...
I: Unpacking libpam-runtime...
I: Unpacking libpam0g:armhf...
I: Unpacking libpcre3:armhf...
I: Unpacking perl-base...
I: Unpacking libprocps3:armhf...
I: Unpacking procps...
I: Unpacking sed...
I: Unpacking sensible-utils...
I: Unpacking login...
I: Unpacking passwd...
I: Unpacking libslang2:armhf...
I: Unpacking startpar...
I: Unpacking libsystemd0:armhf...
I: Unpacking libudev1:armhf...
I: Unpacking systemd...
I: Unpacking systemd-sysv...
I: Unpacking udev...
I: Unpacking initscripts...
I: Unpacking sysv-rc...
I: Unpacking sysvinit-utils...
I: Unpacking tar...
I: Unpacking tzdata...
I: Unpacking libustr-1.0-1:armhf...
I: Unpacking bsdutils...
I: Unpacking libblkid1:armhf...
I: Unpacking libmount1:armhf...
I: Unpacking libsmartcols1:armhf...
I: Unpacking libuuid1:armhf...
I: Unpacking mount...
I: Unpacking util-linux...
I: Unpacking liblzma5:armhf...
I: Unpacking zlib1g:armhf...
I: Configuring required packages...
I: Configuring gcc-4.8-base:armhf...
I: Configuring lsb-base...
I: Configuring sensible-utils...
I: Configuring ncurses-base...
I: Configuring libsemanage-common...
I: Configuring gcc-4.9-base:armhf...
I: Configuring libaudit-common...
I: Configuring libc6:armhf...
I: Configuring startpar...
I: Configuring libc-bin...
I: Configuring diffutils...
I: Configuring insserv...
I: Configuring findutils...
I: Configuring debianutils...
I: Configuring hostname...
I: Configuring multiarch-support...
I: Configuring mawk...
I: Configuring libprocps3:armhf...
I: Configuring libpcre3:armhf...
I: Configuring libbz2-1.0:armhf...
I: Configuring libkmod2:armhf...
I: Configuring libgpg-error0:armhf...
I: Configuring base-files...
I: Configuring libdebconfclient0:armhf...
I: Configuring libselinux1:armhf...
I: Configuring libcomerr2:armhf...
I: Configuring libslang2:armhf...
I: Configuring libsepol1:armhf...
I: Configuring libgcc1:armhf...
I: Configuring libustr-1.0-1:armhf...
I: Configuring libsmartcols1:armhf...
I: Configuring libaudit1:armhf...
I: Configuring libtinfo5:armhf...
I: Configuring libudev1:armhf...
I: Configuring libattr1:armhf...
I: Configuring libss2:armhf...
I: Configuring liblzma5:armhf...
I: Configuring base-passwd...
I: Configuring e2fslibs:armhf...
I: Configuring libgcrypt20:armhf...
I: Configuring libncursesw5:armhf...
I: Configuring libdb5.3:armhf...
I: Configuring zlib1g:armhf...
I: Configuring libcap2:armhf...
I: Configuring libsystemd0:armhf...
I: Configuring libdevmapper1.02.1:armhf...
I: Configuring libsemanage1:armhf...
I: Configuring sysvinit-utils...
I: Configuring libacl1:armhf...
I: Configuring ncurses-bin...
I: Configuring acl...
I: Configuring libncurses5:armhf...
I: Configuring libcap2-bin...
I: Configuring bsdutils...
I: Configuring coreutils...
I: Configuring tar...
I: Configuring dpkg...
I: Configuring sed...
I: Configuring perl-base...
I: Configuring grep...
I: Configuring debconf...
I: Configuring tzdata...
I: Configuring gzip...
I: Configuring dash...
I: Configuring libtext-iconv-perl...
I: Configuring sysv-rc...
I: Configuring liblocale-gettext-perl...
I: Configuring libtext-charwidth-perl...
I: Configuring libpam0g:armhf...
I: Configuring initscripts...
I: Configuring libpam-modules-bin...
I: Configuring bash...
I: Configuring procps...
I: Configuring libtext-wrapi18n-perl...
I: Configuring libpam-modules:armhf...
I: Configuring libpam-runtime...
I: Configuring debconf-i18n...
I: Configuring passwd...
I: Configuring login...
I: Configuring adduser...
I: Configuring libuuid1:armhf...
I: Configuring libblkid1:armhf...
I: Configuring libmount1:armhf...
I: Configuring util-linux...
I: Configuring libcryptsetup4:armhf...
I: Configuring mount...
I: Configuring e2fsprogs...
I: Configuring udev...
I: Configuring systemd...
I: Configuring dmsetup...
I: Configuring systemd-sysv...
I: Configuring init...
I: Configuring libc-bin...
I: Unpacking the base system...
I: Unpacking apt...
I: Unpacking apt-utils...
I: Unpacking libapt-inst1.5:armhf...
I: Unpacking libapt-pkg4.12:armhf...
I: Unpacking libdns-export100...
I: Unpacking libirs-export91...
I: Unpacking libisc-export95...
I: Unpacking libisccfg-export90...
I: Unpacking libboost-iostreams1.55.0:armhf...
I: Unpacking bsdmainutils...
I: Unpacking cpio...
I: Unpacking cron...
I: Unpacking debian-archive-keyring...
I: Unpacking dmidecode...
I: Unpacking libstdc++6:armhf...
I: Unpacking libgdbm3:armhf...
I: Unpacking libgmp10:armhf...
I: Unpacking gnupg...
I: Unpacking gpgv...
I: Unpacking libgnutls-deb0-28:armhf...
I: Unpacking libgnutls-openssl27:armhf...
I: Unpacking groff-base...
I: Unpacking libicu52:armhf...
I: Unpacking ifupdown...
I: Unpacking init-system-helpers...
I: Unpacking iproute2...
I: Unpacking iptables...
I: Unpacking libxtables10...
I: Unpacking iputils-ping...
I: Unpacking isc-dhcp-client...
I: Unpacking isc-dhcp-common...
I: Unpacking libjson-c2:armhf...
I: Unpacking kmod...
I: Unpacking less...
I: Unpacking libestr0...
I: Unpacking libffi6:armhf...
I: Unpacking libidn11:armhf...
I: Unpacking liblogging-stdlog0:armhf...
I: Unpacking liblognorm1:armhf...
I: Unpacking libmnl0:armhf...
I: Unpacking libnetfilter-acct1:armhf...
I: Unpacking libnfnetlink0:armhf...
I: Unpacking libpipeline1:armhf...
I: Unpacking libpsl0:armhf...
I: Unpacking libsigc++-2.0-0c2a:armhf...
I: Unpacking libtasn1-6:armhf...
I: Unpacking libusb-0.1-4:armhf...
I: Unpacking logrotate...
I: Unpacking man-db...
I: Unpacking manpages...
I: Unpacking nano...
I: Unpacking net-tools...
I: Unpacking netbase...
I: Unpacking netcat-traditional...
I: Unpacking libhogweed2:armhf...
I: Unpacking libnettle4:armhf...
I: Unpacking libnewt0.52:armhf...
I: Unpacking whiptail...
I: Unpacking nfacct...
I: Unpacking libssl1.0.0:armhf...
I: Unpacking libp11-kit0:armhf...
I: Unpacking libpopt0:armhf...
I: Unpacking libreadline6:armhf...
I: Unpacking readline-common...
I: Unpacking rsyslog...
I: Unpacking tasksel...
I: Unpacking tasksel-data...
I: Unpacking traceroute...
I: Unpacking vim-common...
I: Unpacking vim-tiny...
I: Unpacking wget...
I: Configuring the base system...
I: Configuring readline-common...
I: Configuring libgdbm3:armhf...
I: Configuring manpages...
I: Configuring libxtables10...
I: Configuring cpio...
I: Configuring libpopt0:armhf...
I: Configuring kmod...
I: Configuring libestr0...
I: Configuring less...
I: Configuring libssl1.0.0:armhf...
I: Configuring dmidecode...
I: Configuring gpgv...
I: Configuring liblogging-stdlog0:armhf...
I: Configuring netcat-traditional...
I: Configuring libpipeline1:armhf...
I: Configuring iproute2...
I: Configuring libtasn1-6:armhf...
I: Configuring nano...
I: Configuring libgmp10:armhf...
I: Configuring libisc-export95...
I: Configuring init-system-helpers...
I: Configuring libnettle4:armhf...
I: Configuring debian-archive-keyring...
I: Configuring vim-common...
I: Configuring libnfnetlink0:armhf...
I: Configuring libstdc++6:armhf...
I: Configuring libffi6:armhf...
I: Configuring libnewt0.52:armhf...
I: Configuring bsdmainutils...
I: Configuring net-tools...
I: Configuring cron...
I: Configuring libmnl0:armhf...
I: Configuring libapt-pkg4.12:armhf...
I: Configuring libusb-0.1-4:armhf...
I: Configuring traceroute...
I: Configuring logrotate...
I: Configuring libidn11:armhf...
I: Configuring libreadline6:armhf...
I: Configuring libjson-c2:armhf...
I: Configuring libicu52:armhf...
I: Configuring netbase...
I: Configuring vim-tiny...
I: Configuring libhogweed2:armhf...
I: Configuring ifupdown...
I: Configuring libisccfg-export90...
I: Configuring libsigc++-2.0-0c2a:armhf...
I: Configuring groff-base...
I: Configuring liblognorm1:armhf...
I: Configuring whiptail...
I: Configuring gnupg...
I: Configuring libpsl0:armhf...
I: Configuring libboost-iostreams1.55.0:armhf...
I: Configuring libdns-export100...
I: Configuring iptables...
I: Configuring libapt-inst1.5:armhf...
I: Configuring libp11-kit0:armhf...
I: Configuring libgnutls-deb0-28:armhf...
I: Configuring wget...
I: Configuring apt...
I: Configuring man-db...
I: Configuring libnetfilter-acct1:armhf...
I: Configuring rsyslog...
I: Configuring nfacct...
I: Configuring apt-utils...
I: Configuring libirs-export91...
I: Configuring libgnutls-openssl27:armhf...
I: Configuring iputils-ping...
I: Configuring isc-dhcp-common...
I: Configuring isc-dhcp-client...
I: Configuring tasksel...
I: Configuring tasksel-data...
I: Configuring libc-bin...
I: Configuring systemd...
I: Base system installed successfully.
#### exit chroot ####
chroot~# exit

Now our chroot is ready, we need to bind proc, sys, dev from OE inside and prepare some scripts.

Create file /storage/.config/autostart.sh with content:

/storage/chroot.sh

Make it executable:

# chmod +x /storage/.config/autostart.sh

Create file /storage/chroot.sh with content:

DST=/storage/debian_armhf

mount -o bind /dev $DST/dev
mount -o bind /sys $DST/sys
mount -t proc proc-chroot $DST/proc/
mount -t devpts devpts-chroot $DST/dev/pts
mount -o bind / /storage/debian_armhf/openelec

sleep 1

chroot $DST /start.sh

Make it executable and run it:

OE~# chmod +x /storage/chroot.sh
OE~# /storage/chroot.sh

Now we should have fully working chroot, so let’s setup some services:

OE~# chroot /storage/debian_armhf/ /bin/bash
#### now we are in chroot ####
chroot~# apt-get install openssh-server
...
chroot~# sed -i 's/Port 22/Port 2222/g' /etc/ssh/sshd_config
chroot~# sed -i 's/^PermitRootLogin.*$/PermitRootLogin yes/g' /etc/ssh/sshd_config
chroot~# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
chroot~# vi /start.sh

/start.sh should include all commands you want to run after boot because we don’t have init running inside chroot. Mine looks like this:

mount -t tmpfs /tmp/ /tmp/
mount LABEL="backup" /mnt/backup/

sysctl net.ipv4.ip_forward=1

service ssh start
service nginx start
service openvpn start
fswebcam -l 1 --resolution 640x480 /tmp/image.jpeg -b

don’t forget to chmod +x /start.sh

Now run start.sh or reboot OpenELEC and you should have ssh started on port 2222 in chroot with set password. As you can see, I have several services installed and started inside as in any other regular Debian OS.

Feel free to comment and share.

Bye!

My inspiration:

4 thoughts on “OrangePi: Installing Debian chroot into OpenELEC”

  1. Great job,

    One comment, “second-stage” doesn’t have to be made on OpenELEC, it can be done on your host using /usr/bin/qemu-arm-static

    apt install qemu-user-static
    host:# cp /usr/bin/qemu-arm-static debian_armhf/usr/bin/ && chroot debian_armhf && rm debian_armhf/usr/bin/qemu-arm-static
    I have no name!@host:/# ./debootstrap/debootstrap –second-stage

    1. I tried it now but the kernel is missing some features:

      OpenELEC:~# lxc-checkconfig
      — Namespaces —
      Namespaces: enabled
      Utsname namespace: enabled
      Ipc namespace: enabled
      Pid namespace: enabled
      User namespace: enabled
      Network namespace: enabled
      Multiple /dev/pts instances: missing

      — Control groups —
      Cgroup: enabled
      Cgroup namespace: required
      Cgroup device: enabled
      Cgroup sched: enabled
      Cgroup cpu account: enabled
      Cgroup memory controller: enabled
      Cgroup cpuset: enabled

      — Misc —
      Veth pair device: missing
      Macvlan: enabled
      Vlan: enabled
      File capabilities: enabled

      Note : Before booting a new kernel, you can check its configuration
      usage : CONFIG=/path/to/config /usr/bin/lxc-checkconfig

      It would require custom kernel compilation.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.