How to Install Debian Wheezy - Mipsel

This version is for Mipsel routers: RT-N16, RT-N66U, RT-AC66U...
Arm version here
I setup a chrooted Debian Wheezy where you can compile and install any package you want, of course if routers memory permit it, ex. transmission, 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 folder, in this case is /mnt/usb_disk/optware-ng


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

2 - Download and extract prepared archive

cd /opt
wget -c -O debian-wheezy7.9-clean-mipsel.tgz
tar -xvzf ./debian-wheezy7.9-clean-mipsel.tgz

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

ipkg install nano
nano /opt/etc/init.d/S99debian

Paste all this lines

# Folder with Debian Wheezy
# 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
if [ ! -e "$CHROOT_SERVICES_LIST" ]; then
	echo "Please, define Debian services to start in 
	echo "One service per line. Hint: this is a script names from 
Debian's /etc/init.d/"
	exit 1
MountedDirCount="$(mount | grep $CHROOT_DIR | wc -l)"
start() {
	if [ $MountedDirCount -gt 0 ]; then
		echo "Chroot'ed services seems to be already started, 
		exit 1
	echo "Starting chroot'ed Debian services..."
	for dir in dev proc sys; do
		mount -o bind /$dir $CHROOT_DIR/$dir
	[ -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
stop() {
	if [ $MountedDirCount -eq 0 ]; then
		echo "Chroot'ed services seems to be already stopped, 
		exit 1
	echo "Stopping chroot'ed Debian services..."
	for item in $(cat $CHROOT_SERVICES_LIST); do
		chroot $CHROOT_DIR /etc/init.d/$item stop
		sleep 2
	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"
		echo "Stopping chroot'ed Debian services..."
	for item in $(cat $CHROOT_SERVICES_LIST); do
		chroot $CHROOT_DIR /etc/init.d/$item stop
		sleep 2
	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
	[ -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
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..."
		echo "Chroot'ed services not running!"
case "$1" in
	status) status
		echo "Usage: (start|stop|restart|enter|status)"
		exit 1
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.

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
cp /etc/hosts /opt/debian/etc/

6 - Enter chrooted debian, you will see in terminal username will change to root@RT-N... from admin@RT-N... 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-get update && apt-get upgrade -y

8 - Set your country time zone

dpkg-reconfigure tzdata

9 - Install some packages, ex. wget

apt-get 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


11 - Create SWAP FILE, it's a must (In Optware-NG is created automatically)

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


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


swapoff /opt/swap

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


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
 4 - Reboot router


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
  • Galbeida

    Thank you very much for the guide, but I have stayed in point 6: "debian enter" since it shows me the following message:

    admin@RT-AC66U_B1-EBE0:/tmp/mnt/ASUS/optware-ng.arm# debian enter
    mount: mounting /tmp/mnt/ASUS/Media on /tmp/mnt/ASUS/optware-ng/debian/mnt failed: No such file or directory
    chroot: can't execute '/bin/bash': Exec format error

    Can you help me?

    • You are trying to install a mipsel version on an arm cpu.
      Use this tutorial

      • Galbeida

        Ok, thx you, i saw this: "This version is for Mipsel routers: RT-N16, RT-N66U, RT-AC66U..." and i think that my router is mipsel, i have a ac66u b1.

        • I saw you installed optware-arm on RT-AC66U, how did you do it?

          • Galbeida
          • TeHashX

            Please post output from:
            uname -m

          • Galbeida



          • Strange, the installer script is looking for cpu type and installing the right version, I see your mipsel router is detected as arm, are you sure it's RT-AC66U?
            Try to install this arm version, just for testing

          • Galbeida

            I have a ac66u b1, tomorrow I will do the test that you indicate, today I dont can, thx

          • TeHashX

            One more output please
            cat /proc/sys/kernel/hostname

          • Galbeida

            Of course:
            admin@RT-AC66U_B1-EBE0:/tmp/home/root# cat "/proc/sys/kerne

          • Galbeida

            Something happens to your web page? regards

          • Thx for feedback, up again.
            Regarding ac66u b1, you are lucky, it's the same hardware as RT-AC68U, use any arm tutorial

          • Galbeida

            thanks to you for your work, I am learning a lot. I have started over again, I had problems with guest permissions, tomorrow I will continue testing. a greeting.

  • Matt S

    And I sometimes get these- Sorry for not posting them together (or even here), formatting was getting screwed up for some reason because of these.

  • Matt S

    I get these errors whenever I do anything in Debian.

    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = "en_US.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
    perl: warning: Falling back to the standard locale ("C").

    • TeHashX

      apt install locales

      • Matt S

        bash: apt: command not found

        • TeHashX

          apt-get install locales

          • Matt S

            The following packages have unmet dependencies:
            locales : Depends: glibc-2.13-1
            E: Unable to correct problems, you have held broken packages.

          • TeHashX

            Mipsel kernel on asuswrt routers is very old 2.6.22 and some packages can't be updated anymore, try
            dpkg-reconfigure locales
            and choose US.UTF-8

  • Que

    Can i install to Debian VNC, eg RealVNC, server on the router and have routers virtual desktop on my remote PC?

    • I don't think 256MB ram are enough for such a task, sorry.

  • Skatewarp

    There wil be a updated tutorial for Debian Jessie?
    P.S (And somewhat unrelated): This Debian installation has the ALSA drivers? ;)

  • Updated to Debian Wheezy v7.9
    Changed sources.list to

  • Ali

    Thanks for this great tutorial TheHashx,

    I'm planning to use this as a container for transmission and openvpn on RT-N66U. However it seems that tun module is not compiled in this kernal and openvpn is not able to connect. I tried to create a new distro using debootstrap but no success. Is there any way to achieve this?


    • James

      I'm also interested

      • Unfortunately, kernel v2.6.22 is to old and nothing I can do about.

    • Can you elaborate a little bit? Do you want to connect through openvpn to rt-n66u and use transmission download manager?

  • Zikiro

    Thanks, TheHashx. I followed step by step instructions but the file seems to be down
    admin@RT-N66U:/tmp/mnt/Mediadb/entware# wget -c -O debian-wheezy7.8-clean-mipsel

    --2015-07-09 14:45:59--
    Resolving 2a00:1450:4003:807::200e,
    Connecting to|2a00:1450:4003:807::200e|:80... failed: Network is unreachable.
    Connecting to||:80... connected.
    HTTP request sent, awaiting response... 301 Moved Permanently
    Location: [following]
    --2015-07-09 14:46:03--

  • mirac53

    Where can I find download Chroot script?

    • That was an old script, user the new one from point 3-4

      • mirac53


        I get error(One service per line. Hint: this is a script names from Debian's /etc/init.d/) in the absence of chroot-services.list file.
        How can I prevent this error?

        thank you..

  • I made an unified S99debian start/stop/restart/enter/status script to simplify usage :)

  • Craig Brigley

    Thank-you for all this ! I have a question. Can you help me ?

    In Step 9, when I try to save the script to enable swap at boot, Nano gives me the following error :

    [ Error writing /jffs/scripts/post-mount: No such file or directory ]

    • Do you mean point 10?
      a) You didn't exit debian with "exit"
      b) You didn't enabled jffs partition before installing optware or entware

      • Craig Brigley

        Oh, yes, didn't enable jffs partition. Thank-you !

  • Alexey Tsapko

    Hi! Thank for the manual! After all i have 2 questions:

    1. In step 9 how can i PASTE line in terminal?
    I have some symbols in script, than i go to the last line, delete excess symbols and write new, like in manual. Right?
    2. After all i cant see swap partition when i do an fdisk -I command? When i try to repeat step 9 (create swap) i have "swapon invalid argument" error

    • In putty terminal, paste with right mouse click
      To see if swap is mounted, type free in terminal
      And should look like this:
      admin@RT-AC56U:/tmp/home/root# free
      total used free shared buffers
      Mem: 255752 125224 130528 0 1180
      -/+ buffers: 124044 131708
      Swap: 524284 9996 514288

  • Updated to Debian v7.8

  • Skatewarp

    This may be a stupid question... I'm a bit curious...
    What are the advantages installing Debian in these routers?

    • Not stupid at all, on debian you can install and compile any other package not available through optware or optware

  • pascal

    sorry to bother you again but i receive below error message:

    admin@RT-N66U-2A98:/tmp/mnt/mediaserver/entware# wget -c -O /opt/etc/init.d/S99d
    Connecting to (
    Connecting to (
    wget: server returned error: HTTP/1.1 416 Requested Range Not Satisfiable

    • Requested Range Not Satisfiable means the file is already there


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...