What's new

[HOWTO]Debian Weezy for AC68 and AC56 + OwnCloud

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Xerxist

Regular Contributor
Debian Weezy for AC68/AC56 (ARM)

Preperation

Note: In this tutorial my mount point for the usb disk is /mnt/sda1 and can defer for you.
The easiest way to find out is to check when you create the share and what your disk is called there and replace "sda1" with what its called or run mount from the shell and check it there.


Have the Merlin firmware installed on your router.
Have a disk formatted in ext4 and attached to the router.
Have ssh shell running
Create a folder called "debian" and share it via Samba

Download the debian weezy environment and the chroot
https://www.dropbox.com/s/f8es9x1x6zuekgm/debian-wheezy-fullbase-arm.tgz
https://www.dropbox.com/s/i2fdsb437x3sm1l/chroot

Put the debian-wheezy-fullbase-arm.tgz on the debian share
Create a folder in the "debian" share called "utils" and put the chroot in there.

Now go into the shell of the router

Extracting the debian environment
Code:
cd /mnt/sda1/debian
tar -xvzf ./debian-wheezy-fullbase-arm.tgz

Create the startup script so the mounts are set at every boot
Code:
cd /jffs/scripts
vi services-start

Add the following lines

Code:
#!/bin/sh
sleep 10
mount -o bind /dev/ /mnt/sda1/debian/dev/
mount -o bind /proc/ /mnt/sda1/debian/proc/
mount -o bind /sys/ /mnt/sda1/debian/sys/

Save the file

Make the script executable
Code:
chmod +x services-start

Make chroot executable
Code:
chmod +x  /mnt/sda1/debian/utils/chroot

Reboot the router

Now your debian enviroment is setup and you can get in via this command from the shell.
Code:
/mnt/sda1/debian/utils/chroot /mnt/sda1/debian /bin/bash

If you want to get back into the Asus shell environment just type exit

Package example to run from the Debian environment

OwnCloud 6

Go into the Debian environment from the shell.

Code:
/mnt/sda1/debian/utils/chroot /mnt/sda1/debian /bin/bash

Install the following packages
Code:
apt-get install bzip2
apt-get install wget
apt-get install php5-cgi
apt-get install sqlite
apt-get install lighttpd
apt-get install php5-sqlite
apt-get install php5-gd
apt-get install openssl

Adjust the memory usage of php adjust the following lines
Code:
nano /etc/php5/cgi/php.ini
upload_max_filesize = 4000M
post_max_size = 4000M
memory_limit = 16M

Get OwnCloud 6
Code:
cd /var/www
rm index.lighttpd.html
wget http://download.owncloud.org/community/owncloud-6.0.2.tar.bz2
bzip2 -cd owncloud-6.0.2.tar.bz2 | tar -xv
chown -R www-data:www-data /var/www/owncloud
rm owncloud-6.0.2.tar.bz2


Generate the ssl certificates
Code:
cd /etc/lighttpd
mkdir certs
cd certs
openssl req -new -x509 -keyout lighttpd.pem -out lighttpd.pem -days 365 -nodes
chmod 400 lighttpd.pem

Adjust lighttpd for Owncloud and php to work
Code:
cd /etc/lighttpd/
nano lighttpd.conf

Replace the config with the config below

Code:
server.modules = (
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
#       "mod_rewrite",
        "mod_fastcgi",
)

server.document-root        = "/var/www/owncloud"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 6897


index-file.names            = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
fastcgi.server = (
  ".php" =>
    ( "localhost" =>
      ( "socket" => "/tmp/php-fcgi.sock",
        "bin-path" => "/usr/bin/php5-cgi",
        "max-procs" => 1,
        "bin-environment" =>
          ( "PHP_FCGI_CHILDREN" => "2",
            "PHP_FCGI_MAX_REQUESTS" => "1000"
          )
        )
     )
 )

$HTTP["url"] =~ "^/data/" {
  url.access-deny = ("")
}

$HTTP["url"] =~ "^/($|/)" {
  dir-listing.activate = "disable"
}

$SERVER["socket"] == ":443" {
  ssl.engine = "enable" 
  ssl.pemfile = "/etc/lighttpd/certs/lighttpd.pem" 
}

Restart lighttpd
Code:
service lighttpd stop
service lighttpd start

For Email from OwnCloud
Code:
nano /var/www/owncloud/config/config.php

Add the following lines and adjust to your needs
Code:
'mail_smtpmode' => 'smtp',
'mail_smtphost' => 'yoursmtpserver',
'mail_smtpport' => 587,
'mail_smtpsecure' => 'tls',
'mail_smtpauth' => true,
'mail_smtpauthtype' => 'LOGIN',
'mail_smtpname' => 'email@email.com',
'mail_smtppassword' => 'yourpassword',
'mail_smtptimeout' => 10,

Now open up your browser and goto https://yourroutersip

If you want to access OwnCloud also from the internet run the following command when you exit the Debian evironment.
Code:
iptables -I INPUT -p tcp --dport 443 -j ACCEPT

To make OwnCloud start automatically after a reboot
Code:
cd /jffs/scripts
vi services-start

Add the following lines
Code:
iptables -I INPUT -p tcp --dport 443 -j ACCEPT
/mnt/sda1/debian/utils/chroot /mnt/sda1/debian service lighttpd start

Reboot the router and in this case Owncloud (lighttpd) is started automatically after each reboot.

Extra note: If you have allot of pictures uploaded OwnCloud makes thumbnails and makes it very slow but you can disable that by disabling the thumbnail generation.

Add the following line to /var/www/owncloud/config/config.php in the Debian environment

Code:
'enable_previews' => false,

Because the router only has 256MB of ram it can be useful to have a swap file although it can be slow like on a normal computer when running out of memory.

If you want to use a swapfile you can do the following.

Create a swap file of 512MB

Goto a folder where you want to create a swap file (in this instance /mnt/sda1)

Code:
cd /mnt/sda1
dd if=/dev/zero of=swapfile bs=1024 count=524288
mkswap swapfile
chmod 0600 swapfile

Use the swapfile

Code:
swapon swapfile

If you want this at every boot

Code:
cd /jffs/scripts
vi services-start

add the following line

Code:
swapon /mnt/sda1/swapfile
 
Last edited:
...great stuff :cool:

I'd suggest to explain that the path to the ext4 disk "/dev/sda1" might vary, depending
on the individual user's hardware setup.
 
Create the startup script so the mounts are set at every boot
Code:
cd /jffs/scripts
vi services-start

Add the following lines

Code:
mount -o bind /dev/ /mnt/sda1/debian/dev/
mount -o bind /proc/ /mnt/sda1/debian/proc/
mount -o bind /sys/ /mnt/sda1/debian/sys/

Save the file

...my USB disks are always mounted on "/tmp/mnt/<sdX>"....not "/mnt/<sdX>".

...and the script will require the shebang "#!/bin/sh" in the first line.
 
Last edited:
Yes I've got the same with /tmp/mnt/sdX but /mnt/sdX works too must be a soft link or something like that.
Give it a try from the shell.

Yes I need to explain the mount point a bit better but not sure how yet. Allot of variables...

Thanks! adjusted the "#!/bin/sh"
Missed that one :)

Sent from my GT-I9505 using Tapatalk
 
Last edited:
Yes I've got the same with /tmp/mnt/sdX but /mnt/sdX works too must be a soft link or something like that.
Give it a try from the shell.

Ahh....ok.
Yes, it is a softlink indeed.
Code:
admin@RT-AC68U:/tmp/home/root# ls -la /
drwxr-xr-x   17 admin    root           320 Jan 31 06:52 .
drwxr-xr-x   17 admin    root           320 Jan 31 06:52 ..
drwxr-xr-x    2 admin    root           711 Jan 31 06:52 bin
drwxr-xr-x    2 admin    root             3 Jan 31 06:52 cifs1
drwxr-xr-x    2 admin    root             3 Jan 31 06:52 cifs2
drwxr-xr-x    6 admin    root          1800 Feb 14 23:55 dev
lrwxrwxrwx    1 admin    root             7 Jan 31 06:52 etc -> tmp/etc
lrwxrwxrwx    1 admin    root             8 Jan 31 06:52 home -> tmp/home
drwxr-xr-x    5 admin    root             0 Feb 15 10:19 jffs
drwxr-xr-x    3 admin    root           417 Jan 31 06:52 lib
lrwxrwxrwx    1 admin    root             9 Jan 31 06:52 media -> tmp/media
drwxr-xr-x    2 admin    root             3 Jan 31 06:52 mmc
lrwxrwxrwx    1 admin    root             7 Jan 31 06:52 mnt -> tmp/mnt
lrwxrwxrwx    1 admin    root             7 Jan 31 06:52 opt -> tmp/opt
dr-xr-xr-x   90 admin    root             0 Jan  1  1970 proc
drwxr-xr-x    6 admin    root           661 Jan 31 06:52 rom
lrwxrwxrwx    1 admin    root            13 Jan 31 06:52 root -> tmp/home/root
drwxr-xr-x    2 admin    root          1986 Jan 31 06:52 sbin
drwxr-xr-x   11 admin    root             0 Jan  1  1970 sys
drwxr-xr-x    2 admin    root             3 Jan 31 06:52 sysroot
drwxrwxrwx   11 admin    root           560 Feb 16 20:53 tmp
drwxr-xr-x    7 admin    root           126 Jan 31 06:52 usr
lrwxrwxrwx    1 admin    root             7 Jan 31 06:52 var -> tmp/var
drwxr-xr-x   11 admin    root          5667 Jan 31 06:52 www
 
How is this an improvement over AiCloud or isnt that service available for these models?
 
How is this an improvement over AiCloud or isnt that service available for these models?

Check the site for the features but some key ones.

Multi user
Dropbox a like clients
Android/ios clients

Also this is an example of what you could run.
Because the ARM based routers don't have entware you would need something like this to load other packages.
Choices are limetless with a full debian repository at your disposal.

Sent from my GT-I9505 using Tapatalk
 
Last edited:
Hi, great work!
But I have a question. When I tried to instal libc6, it showed
Code:
root@RT-AC68U:/dev# apt-get install libc6
Reading package lists... Done
Building dependency tree... Done
Suggested packages:
  glibc-doc locales
The following packages will be upgraded:
  libc6
1 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
Need to get 0 B/4201 kB of archives.
After this operation, 8192 B of additional disk space will be used.
sh: 1: cannot create /dev/null: Permission denied
sh: 1: cannot create /dev/null: Permission denied
dpkg-preconfigure: unable to re-open stdin: No such file or directory
Can not write log, openpty() failed (/dev/pts not mounted?)
(Reading database ... 9511 files and directories currently installed.)
Preparing to replace libc6:armel 2.13-38 (using .../libc6_2.13-38+deb7u1_armel.deb) ...
sh: 1: cannot create /dev/null: Permission denied
sh: 1: cannot create /dev/null: Permission denied
/var/lib/dpkg/tmp.ci/preinst: 10: /var/lib/dpkg/tmp.ci/preinst: cannot create /dev/null: Permission denied
/var/lib/dpkg/tmp.ci/preinst: 303: /var/lib/dpkg/tmp.ci/preinst: cannot create /dev/null: Permission denied
dpkg: error processing /var/cache/apt/archives/libc6_2.13-38+deb7u1_armel.deb (--unpack):
 subprocess new pre-installation script returned error exit status 2
Errors were encountered while processing:
 /var/cache/apt/archives/libc6_2.13-38+deb7u1_armel.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@RT-AC68U:/dev#

Could you please help me with this?
 
I just tried it on my install and works but got a couple of errors about /dev/pts not being mounted but installed fine.

From the log it seems you have allot of permission errors.
Did you extract the debian tar with all options from the shell or extracted from say winrar?

Also can you post the output when you run mount from the asus shell?

Sent from my GT-I9505 using Tapatalk
 
Last edited:
Here is the mount form asus shell:
Code:
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro,relatime)
devtmpfs on /dev type devtmpfs (rw,relatime,size=127720k,nr_inodes=31930,mode=755)
proc on /proc type proc (rw,relatime)
tmpfs on /tmp type tmpfs (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
/dev/mtdblock5 on /jffs type jffs2 (rw,noatime)
usbfs on /proc/bus/usb type usbfs (rw,relatime)
/dev/sda2 on /tmp/mnt/DATA type ext4 (rw,nodev,relatime,user_xattr,barrier=1,data=ordered)
/dev/sda3 on /tmp/mnt/sda3 type ufsd (rw,nodev,noatime,nls=utf8,nocase,force)
My /dev/sda1 is mounted as /mnt/DATA.
I used tar command to extract the files via ssh. But instead of putting the debian-wheezy-fullbase-arm.tgz under /mnt/DATA/debian/
I put it under /mnt/DATA/ because when I extract it with
Code:
tar -xvzf debian-wheezy-fullbase-arm.tgz
, it will automatically create directory "debian"
After that, I created utils directory and put chroot in it. Then,
Code:
chmod 777 /mnt/DATA/debian/
Well, I also met some permission problem when I tried to install aria2, and I found that those permission problem is related to /dev/null/
 
well. I succeeded in installing aria2 but seems I can't run it.
Code:
root@RT-AC68U:/dev# aria2c
Fatal: can't open /dev/urandom: Permission denied
Aborted

Seems I have met a lot of permission problem.
 
well. I succeeded in installing aria2 but seems I can't run it.
Code:
root@RT-AC68U:/dev# aria2c
Fatal: can't open /dev/urandom: Permission denied
Aborted

Seems I have met a lot of permission problem.

Have you ensured the appropriate mount commands etc. have been issued?

Code:
logger -t "($(basename $0))" $$ Debian virtualisation commencing....

MYROUTER=$(nvram get computer_name)

EXT_DIR="/tmp/mnt/$MYROUTER"
CHROOT_DIR="/tmp/mnt/$MYROUTER/debian"

mount -o bind /dev/    $CHROOT_DIR/dev/
mount -o bind /proc/   $CHROOT_DIR/proc/
mount -o bind /sys/    $CHROOT_DIR/sys/

logger -t "($(basename $0))" $$ Debian external mapping: $EXT_DIR ....
mount -o bind $EXT_DIR $CHROOT_DIR/mnt

logger -t "($(basename $0))" $$ Debian services being initiated....
/opt/etc/init.d/S99debian start

Regards,
 
It seems your script for mounting /dev /proc /sys isn't working.

In your case it would be.

cd /jffs/scripts
vi services-start

Not sure if you know the commands in vi

Press insert

Paste the following lines

#!/bin/sh
mount -o bind /dev/ /mnt/DATA/debian/dev/
mount -o bind /proc/ /mnt/DATA/debian/proc/
mount -o bind /sys/ /mnt/DATA/debian/sys

Press :

type wq and press enter

chmod +x services-start

Reboot the router

You should have these mounts.

devtmpfs on /tmp/mnt/Data/debian/dev type devtmpfs (rw,relatime,size=127720k,nr_inodes=31930,mode=755)
proc on /tmp/mnt/Data/debian/proc type proc (rw,relatime)
sysfs on /tmp/mnt/Data/debian/sys type sysfs (rw,relatime)
 
I will repack the debian-wheezy-fullbase-arm.tgz to have tree instead of the debian folder as it will lead to confusion.
 
Last edited:
Many thanks to Xerxist and Martineau. The permission problem is caused by improper mount. After I fixed those mount, it would work for me.
 
Got my aria2 under debian working.
But I have a question, can I use any other directory in my sda1 outside debian share via debian shell? I mean, am I limited within the debian folder?
 
Got my aria2 under debian working.
But I have a question, can I use any other directory in my sda1 outside debian share via debian shell? I mean, am I limited within the debian folder?

Yes, you are limited to what is accessible under that tree where you chroot-ed into.
However, you can "inject" other, external sub-trees of your filesystem into the chroot-tree.
Just do this the same way you did for the other mounts.
...like for an existing download folder on your /dev/sda2 you would issue:

Code:
mount -o bind /mnt/sda2/MyDownloads /mnt/sda1/debian/media/Downloads

...create the destination folder .../media/Downloads first if it does not exist.
 


Create the startup script so the mounts are set at every boot
Code:
cd /jffs/scripts
vi services-start

Add the following lines

Code:
#!/bin/sh
mount -o bind /dev/ /mnt/sda1/debian/dev/
mount -o bind /proc/ /mnt/sda1/debian/proc/
mount -o bind /sys/ /mnt/sda1/debian/sys/


OK, maybe I am over-reacting *but*, what is the exact order the user-scripts get triggered during boot?
For the mounts to work in "services-start", the external disk with debian-tree must already be mounted.

I noticed, in the Web-UI of my AC68, right after reboot the WAN and LAN was up, but my disks were not reported as mounted.
Can we ensure that everything the chroot depends on is available before we perform the steps above?
Edit: I *think* the reason for this, on my system, is that I employ a spinning disk, which usually is in sleep-mode to save energy...thus takes some time to spin-up when reboot occurs.
My debian-tree is on a flash-card, but this looks like the complete mount-trigger is affected by the slower disk.
 
Last edited:
OK, maybe I am over-reacting *but*, what is the exact order the user-scripts get triggered during boot?
For the mounts to work in "services-start", the external disk with debian-tree must already be mounted.

I noticed, in the Web-UI of my AC68, right after reboot the WAN and LAN was up, but my disks were not reported as mounted.
Can we ensure that everything the chroot depends on is available before we perform the steps above?
Edit: I *think* the reason for this, on my system, is that I employ a spinning disk, which usually is in sleep-mode to save energy...thus takes some time to spin-up when reboot occurs.
My debian-tree is on a flash-card, but this looks like the complete mount-trigger is affected by the slower disk.

Adjust the time if 15 secs isn't sufficient:

Code:
#!/bin/sh

logger -t "($(basename $0))" $$ Martineau custom SERVICES being started....

MYROUTER=$(nvram get computer_name)

EXT_DIR="/tmp/mnt/$MYROUTER"
CHROOT_DIR="/tmp/mnt/$MYROUTER/debian"

# Wait up to 15 seconds to make sure STORAGE partition is mounted

I=1

while [ $I -le 15 ]; do

    if [ -d  $CHROOT_DIR ]; then

       logger -t "($(basename $0))" $$ Debian is mounted after $I attempts ....

       break
    fi

    sleep 1

    I=`expr $I + 1`

done


logger -t "($(basename $0))" $$ Debian virtualisation commencing....
mount -o bind /dev/    $CHROOT_DIR/dev/
mount -o bind /proc/   $CHROOT_DIR/proc/
mount -o bind /sys/    $CHROOT_DIR/sys/

logger -t "($(basename $0))" $$ Debian external mapping: $EXT_DIR ....
mount -o bind $EXT_DIR $CHROOT_DIR/mnt

NOTE: This is for services-start, although not sure if post-mount script would be more appropriate.

Regards,
 

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top