How to Install Debian Jessie - Arm

This version is for Arm routers: RT-AC56U, RT-AC68U, RT-AC87U, RT-AC88U, RT-AC3200, RT-AC5300...
Can't be installed on mipsel devices because kernel is too old, use debian wheezy instead from here

I setup a chrooted Debian Jessie v8.8 where you can compile and install any package you want, of course if routers memory permit it, ex. transmission, plexmediaserver, minidlna, lighttpd, rutorrent, owncloud...

Choose only one version to install from point 1a or 1b, Optware or Entware

1a - Install NEW GENERATION OPTWARE from here, to simplify things, debian will be installed in optware-ng.arm folder, in this case is /mnt/usb_disk/optware-ng.arm

ipkg install nano findutils

or

1b - Install NEW GENERATION ENTWARE from here, to simplify things, debian will be installed in entware-ng.arm folder, in this case is /mnt/usb_disk/entware-ng.arm

2 - Download and extract prepared archive

cd /opt
wget -c -O debian_jessie8.8-arm_clean.tgz http://goo.gl/J79LUb
tar -xvzf ./debian_jessie8.8-arm_clean.tgz

3 - Create startup script for installed services (thanks @ryzhov_al), this is usefull for minidlna, transmission or any other package...

nano /opt/etc/init.d/S99debian

Paste all this lines

#!/bin/sh
PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin
# Folder with Debian Jessie
CHROOT_DIR=/tmp/mnt/sda1/optware-ng.arm/debian
# Some folder outside of sandbox, 
# will be mounted to /mnt folder in Debian
# Uncommented next line if you need to mount a folder inside debian
# EXT_DIR=/tmp/mnt/sda1/Media/
CHROOT_SERVICES_LIST=/opt/etc/chroot-services.list
if [ ! -e "$CHROOT_SERVICES_LIST" ]; then
	echo "Please, define Debian services to start in 
$CHROOT_SERVICES_LIST first!"
	echo "One service per line. Hint: this is a script names from 
Debian's /etc/init.d/"
	exit 1
fi
MountedDirCount="$(mount | grep $CHROOT_DIR | wc -l)"
start() {
	if [ $MountedDirCount -gt 0 ]; then
		echo "Chroot'ed services seems to be already started, 
exiting..."
		exit 1
	fi
	echo "Starting chroot'ed Debian services..."
	for dir in dev proc sys; do
		mount -o bind /$dir $CHROOT_DIR/$dir
	done
	[ -z "$EXT_DIR" ] || mount -o bind $EXT_DIR $CHROOT_DIR/mnt
	for item in $(cat $CHROOT_SERVICES_LIST); do
		chroot $CHROOT_DIR /etc/init.d/$item start
	done
	}
stop() {
	if [ $MountedDirCount -eq 0 ]; then
		echo "Chroot'ed services seems to be already stopped, 
exiting..."
		exit 1
	fi
	echo "Stopping chroot'ed Debian services..."
	for item in $(cat $CHROOT_SERVICES_LIST); do
		chroot $CHROOT_DIR /etc/init.d/$item stop
		sleep 2
	done
	mount | grep $CHROOT_DIR | awk '{print $3}' | xargs umount -l
	}
restart() {
	if [ $MountedDirCount -eq 0 ]; then
		echo "Chroot'ed services seems to be already stopped"
		start
		else
		echo "Stopping chroot'ed Debian services..."
	for item in $(cat $CHROOT_SERVICES_LIST); do
		chroot $CHROOT_DIR /etc/init.d/$item stop
		sleep 2
	done
	mount | grep $CHROOT_DIR | awk '{print $3}' | xargs umount -l
		echo "Restarting chroot'ed Debian services..."
	for dir in dev proc sys; do
		mount -o bind /$dir $CHROOT_DIR/$dir
	done
	[ -z "$EXT_DIR" ] || mount -o bind $EXT_DIR $CHROOT_DIR/mnt
	for item in $(cat $CHROOT_SERVICES_LIST); do
		chroot $CHROOT_DIR /etc/init.d/$item start
	done
	fi
	}	
enter() {
	[ -z "$EXT_DIR" ] || mount -o bind $EXT_DIR $CHROOT_DIR/mnt
	mount -o bind /dev/ /opt/debian/dev/
	mount -o bind /dev/pts /opt/debian/dev/pts
	mount -o bind /proc/ /opt/debian/proc/
	mount -o bind /sys/ /opt/debian/sys/
	chroot /opt/debian /bin/bash
	}
status() {
	if [ $MountedDirCount -gt 0 ]; then
		echo "Chroot'ed services running..."
	else
		echo "Chroot'ed services not running!"
	fi
	}
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		restart
		;;
	enter)
		enter
		;;	
	status) status
		;;
	*)
		echo "Usage: (start|stop|restart|enter|status)"
		exit 1
		;;
esac
echo Done.
exit 0

Save with CTRL-O, press ENTER and exit nano with CTRL-X

Make script executable

chmod 755 /opt/etc/init.d/S99debian

In this script is a path EXT_DIR to your external media folder which will be mounted in debian as /mnt, default is /mnt/sda1/Media/ (must be a single folder not the whole partition), don't forget to uncomment if is used, inside Debian, EXT_DIR /mnt/sda1/Media/ will become /mnt (Ex. you need to set Transmission download path to /mnt/transmission or a new library in Plex Media Server path to /mnt

If your disk has a label change sda1 from CHROOT_DIR with your disk label, modify the script to match your settings with a text editor, use this command:

nano /opt/etc/init.d/S99debian

After editing EXT_DIR and CHROOT_DIR, save settings with CTRL-O, press ENTER and exit nano with CTRL-X

4 - Create symlink to start-stop services or enter debian easier
touch /opt/etc/chroot-services.list
ln -s /opt/etc/init.d/S99debian /opt/bin/debian

Every time you want to start installed services in debian without typing long command "/opt/etc/init.d/S99debian start/stop", type only

debian start
debian stop
debian restart
debian enter
debian status

But don't forget to add services name from /opt/debian/etc/init.d/ to /opt/etc/chroot-services.list

5 - Copy hosts file to debian (usefull for some debian packages)
cp /etc/hosts /opt/debian/etc/

6 - Enter chrooted debian, you will see in terminal username will change to root@RT-AC... from admin@RT-AC... or other name if changed previously in router menu (all terminals commands with purple border are inside debian)

debian enter

7 - Run update to see if some recent packages are available

apt update && apt upgrade -y

8 - Set your country time zone

dpkg-reconfigure tzdata

9 - Install some packages, ex. wget

apt install wget

Now you have a full Debian distro and may install any package from here but first we need a swap file
10 - To exit chrooted debian just type exit

exit

Create SWAP FILE, it's a must - NOW IS CREATED AUTOMATICALLY WITH LATEST OPTWARE / ENTWARE INSTALL SCRIPT

cd /opt
dd if=/dev/zero of=swap bs=1024 count=524288
mkswap swap
chmod 0600 swap
swapon swap

To enable swap file when router booting, create /jffs/scripts/post-mount script with

nano /jffs/scripts/post-mount

Paste this lines in terminal

#!/bin/sh

swapon /opt/swap

Save with CTRL-O / Enter / and exit with CTRL-X
To unmount swap create /jffs/scripts/services-stop script with
nano /jffs/scripts/services-stop

Paste this lines in terminal

#!/bin/sh

swapoff /opt/swap

Save with CTRL-O / Enter / and exit with CTRL-X
Make scripts executable
chmod a+rx /jffs/scripts/*
Enjoy...

HOW TO UNINSTALL DEBIAN

It's very important to unmount external folder before removing debian, if not - all content from that directory will be deleted: movies, music files, photos...

1 - Stop debian and unmount external folder
debian stop
2 - Remove entire debian directory
rm -r /opt/debian
3 - Remove startup script
rm /opt/etc/init.d/S99debian
rm /opt/bin/debian
3a - Remove post mount script, (only if is not used for another services)
rm /jffs/scripts/post-mount
4 - Reboot router
reboot

HOW TO BACKUP-RESTORE DEBIAN

After installing a lot of packages, it's better to make a backup, if something goes wrong just restore it without reconfigure all off your work.

   It's very important to unmount external folder before backing up debian, if not - all content from that directory will be included in archive and may become huge...

Stop debian and unmount external folder
debian stop
BackUp debian
cd /opt
tar -cvzf ./chosen_debian_name.tgz ./debian/
Restore debian when needed
cd /opt
tar -xvzf ./chosen_debian_name.tgz

 

  • blackcatss

    Hi, thanks for Dedin 8.8!
    How to install MySql (or Mariadb)-server?
    apt install mysql-server mysql-client
    ........
    A newer kernel is required to run this binary. (__kernel_cmpxchg64 helper)
    ........

  • Updated to Debian v8.8 and fixed sources list

    • geffa

      Thank you very much.

  • Calcipher

    Hello,
    Thank you for this great job. I have a question.

    Is it possible to modifiy router parameters at debian level, using linux tools (dhclient, /etc/network/interfaces , etc) replacing router setup interface?

    Thank you

  • Jelle

    I have tried several times but still...;

    hilljoh@ASUS:/tmp/mnt/sda1/optware-ng.arm# touch /opt/etc/chroot-services.list
    hilljoh@ASUS:/tmp/mnt/sda1/optware-ng.arm# ln -s /opt/etc/init.d/S99debian /opt/bin/debian
    hilljoh@ASUS:/tmp/mnt/sda1/optware-ng.arm# cp /etc/hosts /opt/debian/etc/
    hilljoh@ASUS:/tmp/mnt/sda1/optware-ng.arm# debian enter
    /opt/bin/debian: line 7: if: not found
    /opt/bin/debian: line 8: syntax error: unexpected "then"
    hilljoh@ASUS:/tmp/mnt/sda1/optware-ng.arm# apt update && apt upgrade -y
    -sh: apt: not found
    hilljoh@ASUS:/tmp/mnt/sda1/optware-ng.arm#

    • You have to copy/paste entire script from point 3
      #!/bin/sh
      PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin
      ...
      ...
      ...
      esac
      echo Done.
      exit 0

      But first remove it
      rm /opt/etc/init.d/S99debian

      If you can't do it, I can assist you through team viewer, send me ID and temp password by contact form hqt.ro/contact

  • Jelle

    Tried 7 timer but still;
    hilljoh@ASUS:/tmp/mnt/sda1/optware-ng.arm# touch /opt/etc/chroot-services.list
    hilljoh@ASUS:/tmp/mnt/sda1/optware-ng.arm# ln -s /opt/etc/init.d/S99debian /opt/bin/debian
    hilljoh@ASUS:/tmp/mnt/sda1/optware-ng.arm# cp /etc/hosts /opt/debian/etc/
    hilljoh@ASUS:/tmp/mnt/sda1/optware-ng.arm# debian enter
    /opt/bin/debian: line 7: if: not found
    /opt/bin/debian: line 8: syntax error: unexpected "then"
    hilljoh@ASUS:/tmp/mnt/sda1/optware-ng.arm# apt update && apt upgrade -y
    -sh: apt: not found
    hilljoh@ASUS:/tmp/mnt/sda1/optware-ng.arm#

  • Jelle

    Hi, thank you for this tutorial, I have below error, can someone help me? Regards, Jelle

    hilljoh@ASUS:/tmp/home/root# debian start
    /opt/bin/debian: line 8: if: not found
    /opt/bin/debian: line 9: syntax error: unexpected "then"

    • Sorry for late reply, you did a wrong edit to /opt/etc/init.d/S99debian file, delete S99debian and redo step 3

  • Keerati Manasatitpong

    Hi, thank you for the tutorial.
    I just successfully installed jessie on my android box (armv8, android 6) with entware. Everything seem to work fine as it is on my AC87U. But I just wonder, is it possible to get debian arm64 on my android box. Could you point me to the information on how to build the debian like your prepared archive? Thank you.

  • Matthew

    hello. Thank you for this tutorial. Unfortunately, I can't seem to install or run mysql on jessie for arm7 in optware on my Asus rt-ac87u as it's saying that I need a newer kernel. Will I simply need to downgrade to wheezy? Thank you.

  • Updated to Debian v8.6

  • Toufiq Ibna Mustafiz
    • You are not paying attention :(
      Your partition has label optware and debian script is for sda1
      Replace
      CHROOT_DIR=/tmp/mnt/sda1/optware-ng.arm/debian
      with
      CHROOT_DIR=/tmp/mnt/optware/optware-ng.arm/debian
      in /opt/etc/init.d/S99debian

      PS.
      Why are you taking screenshots? Just copy/paste code here :)

      • Toufiq Ibna Mustafiz

        ops! thanks man. i am new in linus :P

  • Cooper

    It's the most wonderful guide for my entware.arm asus router.(rt-ac68u)
    It's perfectly work. Great!

    Now i'm trying to install tvheadend package with below site.
    (http://lintut.com/how-to-install-tvheadend-open-source-tv-streaming-server-on-ubuntu/)

    But it's a little bit hard I'm a beginner for linux.

    it just says,
    root@RT-AC68R:/# apt install tvheadend
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package tvheadend

    Could you give me a simple guide with this? TeHashX.
    Thank you very much.

    • TeHashX

      You should add package repository to /etc/apt/sources.list
      I will try to see if is possible to install tvheadend in about a week when returning from holidays.

      • Cooper

        Thank you for your kindness
        TeHashX

  • LukeH

    Moving to a bigger HD...
    Hi,
    I'm thinking to replace the disk on my router and already have Jessie and a handful of things under it. Do you think it will work to just prepare the new disk and entware/optware and then copy everything under the debian folder from the old one?
    Thanks

    • TeHashX

      Yes,
      BackUp debian
      cd /opt
      tar -cvzf ./chosen_debian_name.tgz ./debian/
      Restore debian when needed
      cd /opt
      tar -xvzf ./chosen_debian_name.tgz

  • Kleancho

    Hi: I just have install Debian over Optware because I want to use incron & rsync. I am setting up a NAS with Asus AC3200 and a WD My Cloud and I want to get folders synchronized between both of them.
    First of all, i can't get debian mounting a folder outside debian. When I start debian I get this error : mount: mounting /tmp/mnt/Dwnldsrver/optware-ng.arm/ on /tmp/mnt/Lnxsrver/optware-ng.arm/debian/mnt failed: No such file or directory
    Also I put this entries in incontab, but i can't get any results:
    /tmp/mnt/USB/Transmission/Ready/ IN_CREATE,IN_CLOSE_WRITE /usr/bin/rsync -a "ssh -i /Keys/ASKeyD" /tmp/mnt/USB/Transmission/Ready/ root@IP:/shares/Transmission/Ready $@/$#

    Any ideas?

    Thanks in advance.

    • TeHashX

      /tmp/mnt/Dwnldsrver/optware-ng.arm/ is the optware folder and you can't mount it :)
      Which is your external folder, complete path? like /tmp/mnt/sda1/Media/

  • David

    How would you recommend I set up Debian to run a script every day at 1? Do cronjobs work corrected in a chroot'd Debian install? Or should I use some other way? I'd like to set up my router to transcode a movie or two a night starting at midnight to aac and mp4 to give best chance of direct play on Plex. Thank you!

    • TeHashX

      I didn't tried cron on chroot debian but should work, just need to add "cron" to /opt/etc/chroot-services.list after installing in debian with:
      apt install cron
      exit
      debian restart

      • David

        Am I adding it to that list so it simply starts on reboot or is there a performance reason to start chroot'd services outside of debian chroot?

      • TeHashX

        No, only to start at reboot :)

  • Nikitossss

    Hi =) Maybe you can help me with this:

    /opt/bin/debian: line 8: inside: not found
    /opt/bin/debian: line 114: /tmp/mnt/sda1/optware-ng.arm/debian/mnt: Permission denied

    Thx

    • TeHashX

      ln -s /opt/etc/init.d/S99debian /opt/bin/debian

      • Nikitossss

        Got this:

        @RT-AC56U:/tmp/home/root# debian enter
        /opt/bin/debian: line 8: inside: not found
        /opt/bin/debian: line 114: /tmp/mnt/sda1/optware-ng.arm/debian/mnt: Permission denied
        root@RT-AC56U:/# ln -s /opt/etc/init.d/S99debian /opt/bin/debian
        ln: failed to create symbolic link '/opt/bin/debian': No such file or directory

      • TeHashX

        Remove S99debian script
        rm /opt/etc/init.d/S99debian
        Now continue from step 3

  • Leandro

    Hi,

    admin@RT-AC66R-B1A0:/tmp/mnt/Flash_Disk/optware-ng# debian start
    Starting chroot'ed Debian services...
    Done.
    admin@RT-AC66R-B1A0:/tmp/mnt/Flash_Disk/optware-ng# debian status
    Chroot'ed services running...
    Done.
    admin@RT-AC66R-B1A0:/tmp/mnt/Flash_Disk/optware-ng# debian enter
    chroot: can't execute '/bin/bash': Exec format error
    Done.

    could u help?

    • TeHashX

      Jessie is only for Arm devices, your router is mipsel arch, install Wheezy https://www.hqt.ro/how-to-install-debian-wheezy-mipsel/

      • Leandro

        thx for quick response.
        Can i run plex on this router?

      • TeHashX

        On mipsel no, sorry...

      • Leandro

        Ok, but now cpu router is at 100% and i cant connect to ssh to uninstall.
        can u help?

      • TeHashX

        1 - Reboot router from wan ui
        2 - unplug usb
        3 - take off power cord then replug

  • elradix

    download url is broken, can you update it pls

  • Csaba Benesch

    how can I add more then one EXT_DIR?

    • TeHashX

      You can mount multiple folders by adding lines:
      09,
      10,

      31,
      32,

      33,
      34,

      68,
      69,

      70,
      71,

      79,
      80,

      81,
      82,

      https://paste.ee/p/MsrNY

      • David

        Hello, how can I add /jffs as an external folder? The example you gave above is blank and the URL is broken. I'm having a hell of a time with getting the drives to mount the same way every time with dd-wrt. I'd like to try mount my data usb drive to jffs so that the name stops changing between sda1 to sbd1 randomly. dd-wrt doesn't seem to have a completely working mount command because I am also unable to mount by label or uuid so i'm thinking the jffs mount is the only way. Thank you!

      • TeHashX

        It's better to label the disk and will be mounted always by that label
        tune2fs -L "desired_label" /dev/sda1
        reboot
        Now reinstall optware / entware
        https://paste.ee/p/MsrNY has expired and I don't have a copy :( but I will recreate it and send you instructions

      • David

        Is that different than labeling the partitions themselves when they are formatted? The partitions were already named when I formatted them with ext4. I made one partition calld entware which shows up as /dev/sdb1 most of the time and then is mounted to /opt. The data drive is also labeled 'media' and shows up as /dev/sda1 regardless of the label. Is there another step I am missing?

        I even tried labeling again with tune2fs and it sees the label on the partitions but doesn't change the naming scheming from sda1 or sdb1 when they are mounted.

      • dr_eme

        I modified a bit the script in order to mount-bind automatically every mounted partition preserving its label. Just change your chrooted path if not on /opt/debian

        #!/bin/sh
        PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin
        # Folder with Chrooted Debian
        CHROOT_DIR=/opt/debian
        CHROOT_SERVICES_LIST=/opt/etc/chroot-services.list
        if [ ! -e "$CHROOT_SERVICES_LIST" ]; then
        echo "Please, define Debian services to start in $CHROOT_SERVICES_LIST first!"
        echo "One service per line. Hint: this is a script names from Debian's /etc/init.d/"
        exit 1
        fi
        MountedDirCount="$(mount | grep $CHROOT_DIR | wc -l)"
        start() {
        if [ $MountedDirCount -gt 0 ]; then
        echo "Chroot'ed services seems to be already started, exiting..."
        exit 1
        fi
        echo "Starting chroot'ed Debian services..."
        for dir in dev proc sys; do
        mount -o bind /$dir $CHROOT_DIR/$dir
        done
        for dir in /mnt/*; do
        if [ "$dir" != "/mnt${CHROOT_DIR%/*}" ]; then
        mkdir -p ${CHROOT_DIR}${dir}
        mount -o bind $dir ${CHROOT_DIR}${dir}
        fi
        done
        for item in $(cat $CHROOT_SERVICES_LIST); do
        chroot $CHROOT_DIR /etc/init.d/$item start
        done
        }
        stop() {
        if [ $MountedDirCount -eq 0 ]; then
        echo "Chroot'ed services seems to be already stopped, exiting..."
        exit 1
        fi
        echo "Stopping chroot'ed Debian services..."
        for item in $(cat $CHROOT_SERVICES_LIST); do
        chroot $CHROOT_DIR /etc/init.d/$item stop
        sleep 2
        done
        mount | grep $CHROOT_DIR | awk '{print $3}' | xargs umount -l
        for dir in $CHROOT_DIR/mnt/*; do
        rmdir -p $dir
        done
        }
        restart() {
        if [ $MountedDirCount -eq 0 ]; then
        echo "Chroot'ed services seems to be already stopped"
        start
        else
        # echo "Stopping chroot'ed Debian services..."
        for item in $(cat $CHROOT_SERVICES_LIST); do
        chroot $CHROOT_DIR /etc/init.d/$item stop
        sleep 2
        done
        mount | grep $CHROOT_DIR | awk '{print $3}' | xargs umount -l
        echo "Restarting chroot'ed Debian services..."
        for dir in dev proc sys; do
        mount -o bind /$dir $CHROOT_DIR/$dir
        done
        for dir in /mnt/*; do
        if [ "$dir" != "/mnt${CHROOT_DIR%/*}" ]; then
        mkdir -p ${CHROOT_DIR}${dir}
        mount -o bind $dir ${CHROOT_DIR}${dir}
        fi
        done
        for item in $(cat $CHROOT_SERVICES_LIST); do
        chroot $CHROOT_DIR /etc/init.d/$item start
        done
        fi
        }
        enter() {
        mount -o bind /dev/ /opt/debian/dev/
        mount -o bind /dev/pts /opt/debian/dev/pts
        mount -o bind /proc/ /opt/debian/proc/
        mount -o bind /sys/ /opt/debian/sys/
        chroot /opt/debian /bin/bash
        }
        status() {
        if [ $MountedDirCount -gt 0 ]; then
        echo "Chroot'ed services running..."
        else
        echo "Chroot'ed services not running!"
        fi
        }
        case "$1" in
        start)
        start
        ;;
        stop)
        stop
        ;;
        restart)
        restart
        ;;
        enter)
        enter
        ;;
        status) status
        ;;
        *)
        echo "Usage: (start|stop|restart|enter|status)"
        exit 1
        ;;
        esac
        echo Done.
        exit 0

      • Thanks for this, I will take a look.
        I tried in the past to set CHROOT_DIR as /opt/debian but for some reason didn't always work and I had to set full path like now, maybe was on mipsel or some old firmware.

      • Can you please post your modified script in sh format on pastebin.com?
        Also, you should mount exernal dir when entering debian, thanks

      • David

        Hi again TeHashX,

        I don't mean to rush you but I was wondering if you would be able to send me those instructions in the near future? I would still like to use jffs because my two USB drives are still changing between sda1 and sdb1. I've tried startup scripts in dd-wrt, run a script on mount and in the startup sript folder of jffs and a bunch of other ways but nothing seems to change how they are mounted.

        Thank you!

      • TeHashX

        Ok, I modified the S99debian script for you ;) http://pastebin.com/9PLJjMms
        I added 3 external folders, just in case...

        Modify lines: 10, 11, 32, 33, 67, 68

        Here is a copy in case pastebin will expire

        #!/bin/sh
        PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin
        # Folder with Chrooted Debian
        CHROOT_DIR=/tmp/mnt/sda1/optware-ng.arm/debian
        # Some folder/folders outside of sandbox,
        # will be mounted to /mnt, /mnt2... folders inside Debian
        # Uncommented next 1-3 lines starting with "EXT_DIR" if you need
        # to mount a folder or more inside chrooted debian
        # EXT_DIR=/tmp/mnt/sda1/Media/
        # EXT_DIR2=/tmp/mnt/sda1/Media2/
        # EXT_DIR3=/jffs/
        CHROOT_SERVICES_LIST=/opt/etc/chroot-services.list
        if [ ! -e "$CHROOT_SERVICES_LIST" ]; then
        echo "Please, define Debian services to start in
        $CHROOT_SERVICES_LIST first!"
        echo "One service per line. Hint: this is a script names from
        Debian's /etc/init.d/"
        exit 1
        fi
        MountedDirCount="$(mount | grep $CHROOT_DIR | wc -l)"
        start() {
        if [ $MountedDirCount -gt 0 ]; then
        echo "Chroot'ed services seems to be already started,
        exiting..."
        exit 1
        fi
        echo "Starting chroot'ed Debian services..."
        for dir in dev proc sys; do
        mount -o bind /$dir $CHROOT_DIR/$dir
        done
        [ -z "$EXT_DIR" ] || mount -o bind $EXT_DIR $CHROOT_DIR/mnt
        [ -z "$EXT_DIR2" ] || mkdir -p $CHROOT_DIR/mnt2 && mount -o bind $EXT_DIR2 $CHROOT_DIR/mnt2
        [ -z "$EXT_DIR3" ] || mkdir -p $CHROOT_DIR/jffs && mount -o bind $EXT_DIR3 $CHROOT_DIR/jffs
        for item in $(cat $CHROOT_SERVICES_LIST); do
        chroot $CHROOT_DIR /etc/init.d/$item start
        done
        }
        stop() {
        if [ $MountedDirCount -eq 0 ]; then
        echo "Chroot'ed services seems to be already stopped,
        exiting..."
        exit 1
        fi
        echo "Stopping chroot'ed Debian services..."
        for item in $(cat $CHROOT_SERVICES_LIST); do
        chroot $CHROOT_DIR /etc/init.d/$item stop
        sleep 2
        done
        mount | grep $CHROOT_DIR | awk '{print $3}' | xargs umount -l
        }
        restart() {
        if [ $MountedDirCount -eq 0 ]; then
        echo "Chroot'ed services seems to be already stopped"
        start
        else
        # echo "Stopping chroot'ed Debian services..."
        for item in $(cat $CHROOT_SERVICES_LIST); do
        chroot $CHROOT_DIR /etc/init.d/$item stop
        sleep 2
        done
        mount | grep $CHROOT_DIR | awk '{print $3}' | xargs umount -l
        echo "Restarting chroot'ed Debian services..."
        for dir in dev proc sys; do
        mount -o bind /$dir $CHROOT_DIR/$dir
        done
        [ -z "$EXT_DIR" ] || mount -o bind $EXT_DIR $CHROOT_DIR/mnt
        [ -z "$EXT_DIR2" ] || mkdir -p $CHROOT_DIR/mnt2 && mount -o bind $EXT_DIR2 $CHROOT_DIR/mnt2
        [ -z "$EXT_DIR3" ] || mkdir -p $CHROOT_DIR/jffs && mount -o bind $EXT_DIR3 $CHROOT_DIR/jffs
        for item in $(cat $CHROOT_SERVICES_LIST); do
        chroot $CHROOT_DIR /etc/init.d/$item start
        done
        fi
        }
        enter() {
        [ -z "$EXT_DIR" ] || mount -o bind $EXT_DIR $CHROOT_DIR/mnt
        mount -o bind /dev/ /opt/debian/dev/
        mount -o bind /dev/pts /opt/debian/dev/pts
        mount -o bind /proc/ /opt/debian/proc/
        mount -o bind /sys/ /opt/debian/sys/
        chroot /opt/debian /bin/bash
        }
        status() {
        if [ $MountedDirCount -gt 0 ]; then
        echo "Chroot'ed services running..."
        else
        echo "Chroot'ed services not running!"
        fi
        }
        case "$1" in
        start)
        start
        ;;
        stop)
        stop
        ;;
        restart)
        restart
        ;;
        enter)
        enter
        ;;
        status) status
        ;;
        *)
        echo "Usage: (start|stop|restart|enter|status)"
        exit 1
        ;;
        esac
        echo Done.
        exit 0

      • David

        You're awesome! Thanks!

  • TeHashX

    Updated to Debian Jessie v8.5

  • Quiller101

    Installed debian Jessie for ARM, but I would like to know how to install minidlna for debian jessie.

  • TeHashX

    I modified S99debian script, now when enter chrooted debian external directory is mounted as /mnt not just when start debian

  • Lasse

    Hi, When I try to stop the chrooted debian, i get the following error:
    admin@RT-AC56U-B900:/tmp/mnt/USBDISK/asusware.arm# debian stop
    Stopping chroot'ed Debian services...
    /opt/bin/debian: line 100: xargs: not found
    Done.

    Unfortunately, debian does not stop due to this error.

    Thanks!!!!

    • TeHashX

      Because you didn't installed findutils, optware or entware?

      • Lasse

        Hi!
        I installed it on asusware.arm. This seems to cause the problem. Therefore, tried optware-ng. Now it works! Thx!!!

  • Adam

    MEMEME@My-Beach-Router:/tmp/mnt/ASUS-Drive/optware-ng# debian enter
    chroot: can't execute '/bin/bash': Exec format error
    Done.

    • TeHashX

      Which router, firmware...?

  • Alberto

    Hi, Can you make a version armhf instead armel of debian jessie for router ac87u, the cpu can run armhf, I want run node 0.12.4 for have homebridge in the router.

    Thanks

    • TeHashX

      I'm not sure if is possible to prepare armhf on armel but I will try, just not right now because I have some other things to do.

      • Alberto

        thanks!!!!!!

      • Alberto

        Please can you make a version chroot debian stretch armhf, in stretch nodejs is version 4.4.0. i believe that proccesor of asus rt87u is armv7a (is compatible with arch armhf).

        A lot of thanks.

      • TeHashX

        You can request packages here https://github.com/Optware/Optware-ng/issues until I will try to make a debian version

      • Alberto

        Thanks!!!!!

      • TeHashX

        Tried to create armhf version but I get Illegal instructions because rt-ac68u cpu which is armel, if you think your rt-ac87u is armhf, try this steps:

        cd /opt
        debian stop
        mv ./debian ./debian-armel
        wget -c -O wget -c -O debian-armhf.tgz http://goo.gl/WOh3N0
        tar -xvzf ./debian-armhf.tgz
        debian enter

        If you don't get "Illegal instructions" error you should continue with second stage, let me know, I will provide you the steps :)

      • Alberto

        you're right, my ac87u is armel, i have tried your debian armhf and i got ilegal instruction.

        Can you compile debian strecth armel, Please? Debian stretch have nodejs 4.4.0 in repository and we woud can install homebridge ( apple homekit server).

        Thanks for your effort!!!!!!!

      • TeHashX

        Setup a fresh installation of debian_jessie8.3, then replace /etc/apt/sources.list with stretch, try a google search
        Run
        apt-get update
        apt-get upgrade
        apt-get dist-upgrade
        Verify with
        cat /etc/debian_version

      • Alberto

        Ok, Thanks,

        I'm going to try it now.

        Thanks!!!!

      • Alberto

        when i execute apt-get dist-upgrade , i got en error in the procces:

        E: This installation run will require temporarily removing the essential package sysvinit-utils:armel due to a Conflicts/Pre-Depends loop. This is often bad, but if you really want to do it, activate the APT::Force-LoopBreak option.
        E: Internal Error, Could not early remove sysvinit-utils:armel (2)

        Thanks!!!!!!

      • Alberto

        i solve this, but apt-get dist-upgrade: kernel must be upgrade an then error:

        Kernel must be upgraded x
        x x
        x This version of the GNU libc requires kernel version 3.2 or later. x
        x Please upgrade your kernel before installing glibc.

        Thanks

      • TeHashX

        Contact Asus and tell them to update router kernel :)
        Try again from scratch but don't run apt-get dist-upgrade, should be enough to install nodejs
        root@RT-AC68U:/# js -v
        v4.3.1

      • Alberto

        :) Thanks!!!!!!!!!

        you 're a crack!!!!!!

        Tomorrow i will probe and will say you if works.

        Regards

      • Kevin

        Hey Alberto, were you able to get something to work for homebridge? i'm trying the same on mine 68u but same issue as you about nodejs.

      • kun

        Same here, trying to get homebridge running on my ac68u.

        Tried the above, i.e. installed and upgraded all necessary packages with sources.list in jessie first.
        Thereafter, edited sources.list to use stretch, and installed nodejs.

        Doesn't work - "illegal instruction" error.

        Not sure if building a new chroot archive based on "stretch" would actually help with this nodejs out-of-date problem that we're encountering?

        Or is it a router kernel issue? I'm using the Merlin fork from here: http://www.snbforums.com/threads/fork-update-for-374-43-available-v19e3-v20b7.18914/

      • kun

        Realized that Optware-NG package listing includes node v6.3.1, so went ahead and renamed the default asusware.arm folder and followed the Optware-NG installation instructions.

        After successful "ipkg install node", doing a "node -v" returns "v6.3.1"... hurray!
        However, doing a "npm -v" returns the dreaded "Illegal instruction" error... sigh!

  • TeHashX

    Fixed locales in Entware...

  • TeHashX

    Build from scratch Debian Jessie v8.3
    Enjoy...

  • eriks

    Great tutorial. Works great for me. Thank you so much.

    I may found a typo...

    5 - Copy hosts file to debian (usefull for some debian packages)

    cp /etc/hosts /opt/debian/etc/
    i guess you mean:

    cp /etc/hosts /opt/etc/

    -eriks

    • No, it's ok /opt/debian/etc
      You need hosts file inside debian for mail, just an example

      • eriks

        you are right ... it was just me getting confused ;)

        btw: I use the raspberry pi 2 as a travel router. I installed your prepared archive on a raspberry pi 2 running openwrt firmware to extent functionality and run extra deamons not directly on openwrt. should also work with banana pi etc...

  • Help Appreciated

    Hi there, thanks for the great guide, just wondering if you can help me, i'm running this via entware on a ac87u running dd-wrt and i'm trying to run an application but i'm running into errors i cant fix so thought it was best to ask here.

    I have installed the program and all dependencies but upon trying to run the service i get the following errors:

    Traceback (most recent call last):

    File "/usr/sbin/xxx", line 2469, in main

    socketfd=socketfd)

    File "/usr/sbin/xxx", line 2037, in __init__

    socketfd = socketfd)

    File "/usr/sbin/xxx", line 1963, in __init__

    RequestHandlerClass)

    File "/usr/lib/python2.7/SocketServer.py", line 417, in __init__

    self.socket_type)

    File "/usr/lib/python2.7/socket.py", line 191, in __init__

    _sock = _realsocket(family, type, proto)

    socket.error: [Errno 97] Address family not supported by protocol

    The relatng code in the file xxx is:

    socketfd = None

    if server_settings["socket"] != "":

    socketfd = server_settings["socket"]

    tcp_server = xxx((server_settings["address"],

    server_settings["port"]),

    ClientHandler,

    interface=(server_settings["interface"]

    or None),

    use_ipv6=use_ipv6,

    gnutls_priority=

    server_settings["priority"],

    use_dbus=use_dbus,

    socketfd=socketfd) - this is line 2469

    Then :

    def __init__(self, server_address, RequestHandlerClass,

    interface=None, use_ipv6=True, clients=None,

    gnutls_priority=None, use_dbus=True, socketfd=None):

    self.enabled = False

    self.clients = clients

    if self.clients is None:

    self.clients = {}

    self.use_dbus = use_dbus

    self.gnutls_priority = gnutls_priority

    IPv6_TCPServer.__init__(self, server_address,

    RequestHandlerClass,

    interface = interface,

    use_ipv6 = use_ipv6,

    socketfd = socketfd) - this is line 2037

    And Finally:

    socketserver.TCPServer.__init__(self, server_address,

    RequestHandlerClass) - this is line 1963

    The corresponding code in SocketServer.py is:

    def __init__(self, server_address, RequestHandlerClass, bind_and_activate=True):

    """Constructor. May be extended, do not override."""

    BaseServer.__init__(self, server_address, RequestHandlerClass)

    self.socket = socket.socket(self.address_family,

    self.socket_type) - this is line 417

    And in socket.py:

    def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None):

    if _sock is None:

    _sock = _realsocket(family, type, proto) - this is line 191

    self._sock = _sock

    for method in _delegate_methods:

    setattr(self, method, getattr(_sock, method))

    I've tried everything i can think of and now i'm lost, if you can help in any way it will be much appreciated. I'm assuming something somewhere needs to be linked/installed/set up correctly but i have no idea what. As i said all help will be much appreciated and if you require any more information to assist you in helping me please don't hesitate to ask. I await your reply and thanks again :)

    Oh i have the following in my chroot-services.list file if it helps any

    avahi-daemon

    dbus

    inetutils-syslogd

    xxx

    • Hmm, I'm not sure but I guess it's just a configuration issue if all dependencies are installed fine.

      Try with debian wheezy https://www.hqt.ro/how-to-install-debian-wheezy-arm/

      cd /opt
      debian stop
      mv debian debian-jessie
      And continue with wheezy installation...

      • Help Appreciated

        Same error i'm afraid

  • Krumbs

    How do I autostart Transmission? the update-rc.d method does not seem to work. I also installed systemctl, but when I try to check status I get "running in chroot, ignoring request" error.

  • jerrm

    This is awesome.

    Any tips on re-creating the initial tarball from a debian.org install resource?

    Nothing wrong with yours at all, but hate to depend on something if I can't re-create it.

    • This was a long time before and I don't remember exactly but should be something like:
      sudo apt-get install debootstrap
      sudo debootstrap --arch armel --foreign --variant=minbase --exclude=yaboot,udev,dbus --include=mc,aptitude stable ./debian ftp://ftp.debian.org/debian
      sudo tar -cvzf ./debian-armel.tgz ./debian/

      Then enter debian and run second stage
      /debootstrap/debootstrap --second-stage

      • jerrm

        Thanks. This is a huge help getting started.
        Hopefully can try it out soon.

  • Incognito Psytrancer

    Help me pleace! No work MySQL

    Error: .A newer kernel is required to run this binary. (__kernel_cmpxchg64 helper)

    • Unfortunately, router has an old kernel and cannot be changed, use debian wheezy

  • Skello

    Hi,

    I have a folder on my external drive mounted as EXT_DIR in Debian. However, whenever I do debian stop or restart it unmounts my external drive from the router completely. This is the drive that contains Entware and Debian as well and the only way to recover is to reboot the router. Is this normal behavior or what's the problem here? Shouldn't debian stop just unmount EXT_DIR from inside debian? Why unmount my drive completely?

    • This is very odd, give me some more details: which router, firmware, where is entware installed, where is debian installed, where is mounted folder...

      • Skello

        The router is AC68U running latest Merlin fw. My external drive is /tmp/mnt/New_Volume/ . Entware (opt) is /tmp/mnt/New_Volume/entware.arm . Debian is inside entware.arm and ext_dir /tmp/mnt/New_Volume/TORRENTS. It's worth mentioning that I also get those unmount errors on debian stop that Incognito mentioned below.

  • Incognito Psytrancer

    Pleace help me pleace!

    If enter the command - debian stop - these error appear:

    Stopping chroot'ed Debian services...
    umount: can't forcibly umount devtmpfs: No such file or directory
    umount: can't forcibly umount on: No such file or directory
    umount: can't forcibly umount type: No such file or directory
    umount: can't forcibly umount devtmpfs: No such file or directory
    umount: can't forcibly umount (rw,relatime,size=127764k,nr_inodes=31941,mode=755): No such file or directory
    umount: can't forcibly umount proc: No such file or directory
    umount: can't forcibly umount on: No such file or directory
    umount: can't forcibly umount type: No such file or directory
    umount: can't forcibly umount proc: No such file or directory
    umount: can't forcibly umount (rw,relatime): No such file or directory
    umount: can't forcibly umount sysfs: No such file or directory
    umount: can't forcibly umount on: No such file or directory
    umount: can't forcibly umount type: No such file or directory
    umount: can't forcibly umount sysfs: No such file or directory
    umount: can't forcibly umount (rw,relatime): No such file or directory
    Done.

    Please tell me what is this error and how to solve them!

    • Incognito Psytrancer

      All the problem is resolved, you need to place in the script s99debian :
      mount | grep $CHROOT_DIR | awk "{print $3}" | xargs umount -l
      replaced by
      mount | grep $CHROOT_DIR | awk '{print $3}' | xargs umount -l

  • Incognito Psytrancer

    Thank you my dear and my dear friend!

  • Thegizmo

    How can I get MySQL Server going? Everything I have tried always ends up with. "[....] Stopping MySQL database server: mysqldA newer kernel is required to run this binary. (__kernel_cmpxchg64 helper) A newer kernel is required to run this binary. (__kernel_cmpxchg64 helper) " The project I am currently working is going to require MySQL-Server. (Project - I want to install WeeWX on my Asus Router) Any suggestions will be greatly appreciated.

    • TeHashX

      Sorry for delay, I will look in to this

  • Василий Нуштакин

    Hi!

    I have a question: in debian I type "exit", I get answer "There are stopped jobs". and no exit

SoftEther VPN Running on AsusWRT Routers
Minidlna UPnP Media Server through Debian Jessie Arm
How to Mount Samba Shares inside Chrooted Debian
Nginx Web Server with PHP Support through Optware-NG
Minidlna UPnP Media Server through Debian Jessie Arm
How to Mount Samba Shares inside Chrooted Debian
Spreed WebRTC server and web client
Asterisk VoIP Server running on AsusWRT Routers
SoftEther VPN Running on AsusWRT Routers
NZBGet through Entware
Minidlna UPnP Media Server through Debian Jessie Arm
NetData System Monitor Entware

SUBSCRIBE

To be notified by email when a new tutorial is posted :)

Thanks for Subscribing! I'll keeping you up-to-date with latest tutorials!

Something went wrong, try again...