Skip to content

OpenWRT on TP-Link MR3020 as infopoint with local webserver

Howto install OpenWRT on an TP-Link MR3020 mini router with external filesystem on a USB stick running a local webserver (lighttpd) to serve up webpages to act as an info point e.g. in a exhibition.

Inspired by the Piratebox Project: http://wiki.daviddarts.com/PirateBox_DIY_OpenWrt

Basic Install of OpenWRT

download OpenWRT firmware

open MR3020 webinterface on http://192.168.1.254/ , username “admin”, password empty

flash OpenWrt firmware like a regular firmware update

wait for progress bar to finish twice

from now on the OpenWrt router can be reached at http://192.168.1.1/

$ telnet 192.168.1.1
root@OpenWrt:~# passwd

set a password for root user, now telnet gets disabled an ssh enabled

root@OpenWrt:~# reboot

Network configuration

$ ssh -l root 192.168.1.1

Edit the network file with vi (vi cheat sheet):

NOTE: As most gateway (e.g. your home network) router’s IP address are 192.168.1.1, we will use 192.168.1.11 for the TP-Link MR3020.

root@OpenWrt:~# vi /etc/config/network

The modified file should look like this:

config interface 'loopback'
	option ifname 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config interface 'lan'
	option ifname 'eth0'
	option type 'bridge'
	option proto 'static'
	option ipaddr '192.168.1.11'
	option netmask '255.255.255.0'
	option gateway '192.168.1.1'
	list dns '192.168.1.1'
	list dns '8.8.8.8'

config interface 'wan'
	option ifname 'eth0.1'
	option proto 'dhcp'
	option gateway '192.168.1.1'
	option netmask '255.255.255.0'
	list dns '192.168.1.1'
	list dns '8.8.8.8'

config interface 'wifi'
	option proto 'static'
	option ipaddr '192.168.2.1'
	option netmask '255.255.255.0'

Firewall settings

Backup firewall config file:

root@OpenWrt:~# cp /etc/config/firewall /etc/config/firewall.bak

Open the firewall config file:

root@OpenWrt:~# vi /etc/config/firewall

Modify first 23 lines to look like this. Leave the rest of the file alone.

config defaults                                                                       
        option syn_flood        '1'                                                   
        option input            'ACCEPT'                                              
        option output           'ACCEPT'                                              
        option forward          'ACCEPT'                                              
# Uncomment this line to disable ipv6 rules                                           
#       option disable_ipv6     1                                                     

config zone                                                                           
        option name             'lan'                                                 
        option network          'lan'                                                 
        option input            'ACCEPT'                                              
        option output           'ACCEPT'                                              
        option forward          'ACCEPT'                                              

config zone                                                                           
        option name             'wan'                                                 
        option network          'wan'                                                 
        option input            'ACCEPT'                                              
        option output           'ACCEPT'                                              
        option forward          'ACCEPT'                                              
        option masq             '1'                                                   
        option mtu_fix          '1'

config zone
	option name		'wifi'
	option input		'ACCEPT'
	option output		'ACCEPT'
	option forward		'REJECT'

config forwarding 
	option src      	'wifi'
	option dest     	'wan'

config forwarding
	option src		'wifi'
	option src		'lan'

# We need to accept udp packets on port 68,
# see https://dev.openwrt.org/ticket/4108

Wireless settings

Enable wireless by modifying the wireless config:

root@OpenWrt:~# vi /etc/config/wireless

Change Line 12 to:

# option disabled 0
config wifi-iface
	option device   radio0
	option network  wifi
	option mode     ap
	option ssid     OpenWrt
	option encryption none

Misc settings

Edit /etc/sysupgrade.conf to prevent system upgrades to overwrite your config files:

root@OpenWrt:~# vi /etc/sysupgrade.conf

should look like this

## This file contains files and directories that should
## be preserved during an upgrade.
# /etc/example.conf
# /etc/openvpn/
/etc/config/

Power cycle the router by unplugging the AC power.

Install additional packages

Connect the MR3020 to your gateway router (e.g. your home network router) with an ethernet cable and plug the power back in. Wait a couple of minutes until the router boots up. With your computer connected to your home network, try sshing into the router (Note: use the IP address you assigned in step 9):

$ ssh root@192.168.1.11

Ping google to ensure your firewall settings are correct:

root@OpenWrt:~# ping google.com

Add USB support to OpenWrt by installing and enabling the following packages:

root@OpenWrt:~# opkg update
root@OpenWrt:~# opkg install kmod-usb-uhci
root@OpenWrt:~# insmod uhci
root@OpenWrt:~# opkg install kmod-usb-ohci
root@OpenWrt:~# insmod usb-ohci

Filesystem on a USB stick (Rootfs on External Storage / extroot)

first we need to install basic USB support for EXT4 and FAT32 formatted USB sticks

root@OpenWrt:~# opkg update
root@OpenWrt:~# opkg install kmod-usb-storage block-mount kmod-fs-ext4 kmod-fs-vfat
kmod-nls-cp437 kmod-nls-cp850 kmod-nls-iso8859-1 kmod-nls-iso8859-15 kmod-scsi-core
e2fsprogs fdisk

[important]I had a lot of troubles trying to use a FAT32 formatted USB stick! The problem was that obviously FAT32 is not supported by the extroot pivot /overlay method! After using EXT4 for the USB stick, everything worked as described in the howto’s.[/important]

check if the USB stick was recognized

root@OpenWrt:~# ls /dev/sd*

you should see one or more devices like sda1, sdb1, sdb2, …

partition the USB stick

root@OpenWrt:~# fdisk
Command (m for help): m (displays actions)
Command (m for help): p (display partition table)
Command (m for help): d (delete partion - had only 1 on my stick)
Command (m for help): n (new partition)
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-621, default 1): RETURN
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-nnnn, default nnn):
Command (m for help): a (make partition bootable) RETURN
Partition number (1-4): 1 Command (m for help): w (write to disk)

format USB stick with ext4 filesystem

root@OpenWrt:~# mkfs.ext4 /dev/sda1

mount the USB stick and copy the flash /overlay to the USB stick

root@OpenWrt:~# mkdir -p /mnt/usb
root@OpenWrt:~# mount -t vfat /dev/sda1 /mnt/usb
root@OpenWrt:~# tar -C /overlay -cvf - . | tar -C /mnt/usb -xvf -
root@OpenWrt:~# vi /etc/config/fstab

the ‘config mount’ block should look like this

config 'mount'
        option target   /overlay
        option device   /dev/sda1
        option fstype   ext4
        option options  rw,sync
        option enabled  1
        option enabled_fsck 0

restart the router and check if everything’s ok

root@OpenWrt:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs                 1962212     65100   1798716   3% /
/dev/root                 1536      1536         0 100% /rom
tmpfs                    14600        72     14528   0% /tmp
tmpfs                      512         0       512   0% /dev
/dev/sda1              1962212     65100   1798716   3% /overlay
overlayfs:/overlay     1962212     65100   1798716   3% /

[warning]please double check that the rootfs has a very low Use% – if it’s still at 50% oder higher it’s likely that the extroot on /overlay is not working![/warning]

LuCI Webinterface and LightHTTPD webserver

Now we can proceed and install LuCI and LightHTTPD

root@OpenWrt:~# opkg update
root@OpenWrt:~# opkg install lighttpd lighttpd-mod-cgi luci-mod-admin-full
luci-theme-openwrt libiwinfo libwinfo-lua

edit /etc/lighttpd/lighttpd.conf

make the first block look like this (or change it to your taste when you know what you’re doing):

server.modules = (
#       "mod_rewrite",
#       "mod_redirect",
#       "mod_alias",
#       "mod_auth",
#       "mod_status",
#       "mod_setenv",
#       "mod_fastcgi",
#       "mod_proxy",
#       "mod_simple_vhost",
        "mod_cgi",
#       "mod_ssi",
#       "mod_usertrack",
#       "mod_expire",
#       "mod_webdav"
)

OLD:

#server.document-root = "/www/"

NEW:

server.document-root = "/website"

OLD:

#server.port = 81

NEW:

server.port = 80

At the end of the file add:

$SERVER["socket"] == ":88" {
    server.document-root = "/www/"
    cgi.assign = ( "luci" => "/usr/bin/lua" )
}

create the /website directory (/www is needed by LuCI) and add some test content

# mkdir /website
# echo "

It works!

” >> /website/index.html

enable lighttpd and start it

root@OpenWrt:~# /etc/init.d/lighttpd start
root@OpenWrt:~# /etc/init.d/lighttpd enable

[important]From now on you can reach the router’s webserver at http://192.168.1.11/ from your lan or http://192.168.2.1/ from your wireless clients[/important]

[important]The LuCI webinterface is at http://192.168.1.11:88/cgi-bin/luci from your lan or http://192.168.2.1:88/cgi-bin/luci from your wireless clients[/important]

[notice]TODO: Splashpage for free WLAN access[/notice]

[notice]TODO: reroute internet access to local website (firewall, dhcp settings[/notice]

[notice]TODO: whitelist for websites that should be accesible[/notice]

[notice]TODO: use a virtual disk on a FAT32 formatted USB stick instead of formatting the USB stick with ext4 filesystem[/notice]

[notice]TODO: next steps to do with this router after having lighttpd up and running[/notice]

If something’s getting messed up … fresh start

To start over you can emtpy the /overlay folder containing all your configurations, installed packages, etc.

# rm -rf /overlay/*

and upgrade the kernel / firmware

# cd /tmp
# wget http://downloads.openwrt.org/snapshots/trunk/ar71xx/openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-factory.bin
# sysupgrade -v /tmp/openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-factory.bin

Resources

TP-Link TL-MR3020 on OpenWRT: http://wiki.openwrt.org/toh/tp-link/tl-mr3020

Piratebox on MR3020 (useful links and tips): http://www.disk91.com/2012/technology/networks/piratebox-creation-based-on-tp-link-mr3020/

OpenWRT LuCI Webinterface install: http://wiki.openwrt.org/doc/howto/luci.essentials

OpenWRT LightHTTPD install: http://wiki.openwrt.org/doc/howto/http.lighttpd

OpenWRT first login: http://wiki.openwrt.org/doc/howto/firstlogin

OpenWRT extroot: http://wiki.openwrt.org/doc/howto/extroot

OpenWRT USB storage: http://wiki.openwrt.org/doc/howto/usb.storage

OpenWRT Routed AP: http://wiki.openwrt.org/doc/recipes/routedap

Kernel / firmware upgrade problems solved: http://forum.daviddarts.com/read.php?2,2988,2988

OpenWRT sysupgrade: http://wiki.openwrt.org/doc/howto/generic.sysupgrade

24 thoughts on “OpenWRT on TP-Link MR3020 as infopoint with local webserver”

  1. Hello,

    I have a issue with this command line :

    root@OpenWrt:~# tar -C /overlay -cvf – . | tar -C /mnt/usb -xvf –

    Some files are not copied ..;
    Are you any idea ?

    thank you

  2. hi,
    that’s normal i think because i had the same “problem” but it seems that it doesn’t matter because everything’s running fine – at least i couldn’t find any real problems.

  3. As you said about troubles trying to use a FAT32 formatted USB stick, I confim one more time.
    It’s mandatory to have ext4 format.
    root@OpenWrt:~# tar -C /overlay -cvf – . | tar -C /mnt/usb -xvf –
    Run without problem and it’s the same for /overlay mount.
    Thanks again.

  4. Pingback: OpenWrt on a TP-Link TL-MR3020 Router

  5. have anyone experienced usb 3g connection unstable ?
    3g connection disconnect after few minutes.

  6. Pingback: ????????????? TP-Link TL-MR3020 « Mac Mini Home

  7. Thanks for the nice instructions. While one can find this on a variety of pages from openwrt and piece it together its nice to have it organized in one place. Is this correct?

    mount -t vfat /dev/sda1 /mnt/usb

    seems like it should be

    mount -t ext4 /dev/sda1 /mnt/usb

  8. yes, vfat as format is right, because it’s a good idea that the USB Stick is FAT32 formatted. So it’s possible to mount the USB stick on Windows or Mac OS X to upload webpages or mediafiles to it – making it easier to add content to the webpage for non Linux Users.

  9. Pingback: OpenWrt on a TP-Link TL-MR3020 Router

  10. Hello,

    I’m trying to do something very similar, but use a loop mount /overlay to a .img file. I posted some more details about it on the OpenWrt forum. I’m trying to keep the USB drive readable on OS X (vfat), but then mount in a ext4 /overlay hosted *on* the vfat partition. I’m not too surprised it didn’t work the first time, but I’m wondering if this is even worth debugging further. Maybe it just doesn’t work the way I want it to.

    Thanks,
    Dan

  11. thanks for the great info. i thinks ‘libwinfo-lua’ should be ‘libiwinfo-lua’.

  12. Pingback: Central heating control on the cheap – 32leaves

  13. Pingback: From Cool to Useful: Incorporating hobby projects into library work « information. games.

  14. my pi currently have piratebox installed. so before starting this guide, i start with “If something’s getting messed up … fresh start” guide above.

    then, when i install package for usb drive support, i got errors. i cant see usb drive from ls /dev

    here are the errors.


    root@XPjUD1pe:/# opkg update
    Downloading http://stable.openwrt.piratebox.de/ar71xx/packages/Packages.gz.
    Updated list of available packages in /var/opkg-lists/attitude_adjustment.
    root@XPjUD1pe:/# opkg install kmod-usb-storage block-mount kmod-fs-ext4 kmod-fs-
    vfat kmod-nls-cp437 kmod-nls-cp850 kmod-nls-iso8859-1 kmod-nls-iso8859-15 kmod-s
    csi-core e2fsprogs fdisk
    Installing kmod-usb-storage (3.3.8-1) to root...
    Downloading http://stable.openwrt.piratebox.de/ar71xx/packages/kmod-usb-storage_
    3.3.8-1_ar71xx.ipk.
    Multiple packages (kmod-usb-core and kmod-usb-core) providing same name marked H
    OLD or PREFER. Using latest.
    Installing block-mount (0.2.0-8) to root...
    Downloading http://stable.openwrt.piratebox.de/ar71xx/packages/block-mount_0.2.0
    -8_ar71xx.ipk.
    Installing swap-utils (2.21.2-1) to root...
    Downloading http://stable.openwrt.piratebox.de/ar71xx/packages/swap-utils_2.21.2
    -1_ar71xx.ipk.
    Installing kmod-fs-ext4 (3.3.8-1) to root...
    Downloading http://stable.openwrt.piratebox.de/ar71xx/packages/kmod-fs-ext4_3.3.
    8-1_ar71xx.ipk.
    Installing kmod-fs-vfat (3.3.8-1) to root...
    Downloading http://stable.openwrt.piratebox.de/ar71xx/packages/kmod-fs-vfat_3.3.
    8-1_ar71xx.ipk.
    Multiple packages (kmod-nls-base and kmod-nls-base) providing same name marked H
    OLD or PREFER. Using latest.
    Installing kmod-nls-cp437 (3.3.8-1) to root...
    Downloading http://stable.openwrt.piratebox.de/ar71xx/packages/kmod-nls-cp437_3.
    3.8-1_ar71xx.ipk.
    Multiple packages (kmod-nls-base and kmod-nls-base) providing same name marked H
    OLD or PREFER. Using latest.
    Installing kmod-nls-cp850 (3.3.8-1) to root...
    Downloading http://stable.openwrt.piratebox.de/ar71xx/packages/kmod-nls-cp850_3.
    3.8-1_ar71xx.ipk.
    Multiple packages (kmod-nls-base and kmod-nls-base) providing same name marked H
    OLD or PREFER. Using latest.
    Installing kmod-nls-iso8859-1 (3.3.8-1) to root...
    Downloading http://stable.openwrt.piratebox.de/ar71xx/packages/kmod-nls-iso8859-
    1_3.3.8-1_ar71xx.ipk.
    Multiple packages (kmod-nls-base and kmod-nls-base) providing same name marked H
    OLD or PREFER. Using latest.
    Installing kmod-nls-iso8859-15 (3.3.8-1) to root...
    Downloading http://stable.openwrt.piratebox.de/ar71xx/packages/kmod-nls-iso8859-
    15_3.3.8-1_ar71xx.ipk.
    Multiple packages (kmod-nls-base and kmod-nls-base) providing same name marked H
    OLD or PREFER. Using latest.
    Package kmod-scsi-core (3.3.8-1) installed in root is up to date.
    Unknown package 'e2fsprogs'.
    Unknown package 'fdisk'.
    Configuring kmod-scsi-core.
    //usr/lib/opkg/info/kmod-scsi-core.postinst: .: line 3: can't open '/etc/functio
    ns.sh'
    Collected errors:
    * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-
    usb-storage:
    * kernel (= 3.3.8-1-4bddedb9576ac1ffd27ba9a0ff6d965d) *
    * opkg_install_cmd: Cannot install package kmod-usb-storage.
    * check_data_file_clashes: Package swap-utils wants to install file /sbin/swapo
    ff
    But that file is already provided by package * busybox
    * check_data_file_clashes: Package swap-utils wants to install file /sbin/swapo
    n
    But that file is already provided by package * busybox
    * check_data_file_clashes: Package swap-utils wants to install file /sbin/mkswa
    p
    But that file is already provided by package * busybox
    * opkg_install_cmd: Cannot install package block-mount.
    * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-
    fs-ext4:
    * kernel (= 3.3.8-1-4bddedb9576ac1ffd27ba9a0ff6d965d) * kernel (= 3.3.8-
    1-4bddedb9576ac1ffd27ba9a0ff6d965d) *
    * opkg_install_cmd: Cannot install package kmod-fs-ext4.
    * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-
    fs-vfat:
    * kernel (= 3.3.8-1-4bddedb9576ac1ffd27ba9a0ff6d965d) *
    * opkg_install_cmd: Cannot install package kmod-fs-vfat.
    * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-
    nls-cp437:
    * kernel (= 3.3.8-1-4bddedb9576ac1ffd27ba9a0ff6d965d) *
    * opkg_install_cmd: Cannot install package kmod-nls-cp437.
    * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-
    nls-cp850:
    * kernel (= 3.3.8-1-4bddedb9576ac1ffd27ba9a0ff6d965d) *
    * opkg_install_cmd: Cannot install package kmod-nls-cp850.
    * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-
    nls-iso8859-1:
    * kernel (= 3.3.8-1-4bddedb9576ac1ffd27ba9a0ff6d965d) *
    * opkg_install_cmd: Cannot install package kmod-nls-iso8859-1.
    * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-
    nls-iso8859-15:
    * kernel (= 3.3.8-1-4bddedb9576ac1ffd27ba9a0ff6d965d) *
    * opkg_install_cmd: Cannot install package kmod-nls-iso8859-15.
    * opkg_install_cmd: Cannot install package e2fsprogs.
    * opkg_install_cmd: Cannot install package fdisk.
    * pkg_run_script: package "kmod-scsi-core" postinst script returned status 2.
    * opkg_configure: kmod-scsi-core.postinst returned 2.
    root@XPjUD1pe:/#

    are there anything i should do before starting this? how do i remove piratebox/format my pi?

    thanks.

  15. i tried reinstalling original tplink firmware and installing openwrt based on this guide http://wiki.openwrt.org/toh/tp-link/tl-mr3020

    then i follow guide on this page up until filesystem on a usb stick where i get this error

    root@OpenWrt:~# opkg install kmod-usb-storage block-mount kmod-fs-ext4 kmod-fs-v
    fat kmod-nls-cp437 kmod-nls-cp850 kmod-nls-iso8859-1 kmod-nls-iso8859-15 kmod-sc
    si-core e2fsprogs fdisk
    Installing kmod-usb-storage (3.3.8-1) to root...
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-usb-storage_3.3.8-1_ar71xx.ipk.
    Installing kmod-scsi-core (3.3.8-1) to root...
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-scsi-core_3.3.8-1_ar71xx.ipk.
    Installing block-mount (0.2.0-9) to root...
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/block-mount_0.2.0-9_ar71xx.ipk.
    Installing blkid (2.21.2-1) to root...
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/blkid_2.21.2-1_ar71xx.ipk.
    Installing libblkid (2.21.2-1) to root...
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/libblkid_2.21.2-1_ar71xx.ipk.
    Installing libuuid (2.21.2-1) to root...
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/libuuid_2.21.2-1_ar71xx.ipk.
    Installing swap-utils (2.21.2-1) to root...
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/swap-utils_2.21.2-1_ar71xx.ipk.
    Installing kmod-fs-ext4 (3.3.8-1) to root...
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-fs-ext4_3.3.8-1_ar71xx.ipk.
    Installing kmod-lib-crc16 (3.3.8-1) to root...
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-lib-crc16_3.3.8-1_ar71xx.ipk.
    Installing kmod-fs-vfat (3.3.8-1) to root...
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-fs-vfat_3.3.8-1_ar71xx.ipk.
    Installing kmod-nls-cp437 (3.3.8-1) to root...
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-nls-cp437_3.3.8-1_ar71xx.ipk.
    Installing kmod-nls-cp850 (3.3.8-1) to root...
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-nls-cp850_3.3.8-1_ar71xx.ipk.
    Installing kmod-nls-iso8859-1 (3.3.8-1) to root...
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-nls-iso8859-1_3.3.8-1_ar71xx.ipk.
    Installing kmod-nls-iso8859-15 (3.3.8-1) to root...
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-nls-iso8859-15_3.3.8-1_ar71xx.ipk.
    Package kmod-scsi-core (3.3.8-1) installed in root is up to date.
    Installing e2fsprogs (1.42.4-1) to root...
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/e2fsprogs_1.42.4-1_ar71xx.ipk.
    Installing libext2fs (1.42.4-1) to root...
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/libext2fs_1.42.4-1_ar71xx.ipk.
    Installing libcom_err (1.42.4-1) to root...
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/libcom_err_1.42.4-1_ar71xx.ipk.
    Installing libpthread (0.9.33.2-1) to root...
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/libpthread_0.9.33.2-1_ar71xx.ipk.
    Installing fdisk (2.21.2-1) to root...
    Configuring kmod-scsi-core.
    Configuring kmod-usb-storage.
    Configuring libpthread.
    Configuring kmod-lib-crc16.
    Configuring libcom_err.
    Configuring libuuid.
    Configuring libblkid.
    Configuring blkid.
    Configuring swap-utils.
    Configuring block-mount.
    Configuring kmod-fs-vfat.
    Configuring kmod-fs-ext4.
    Configuring kmod-nls-cp437.
    Configuring kmod-nls-cp850.
    Configuring kmod-nls-iso8859-15.
    Configuring kmod-nls-iso8859-1.
    Configuring libext2fs.
    Collected errors:
    * extract_archive: Cannot create symlink from ./usr/sbin/mkfs.ext3 to 'mke2fs':
    No space left on device.
    * extract_archive: Cannot create symlink from ./usr/lib/libe2p.so.2 to 'libe2p.
    so.2.3': No space left on device.
    * wfopen: /usr/lib/libe2p.so.2.3: No space left on device.
    * wfopen: /etc/e2fsck.conf: No space left on device.
    * wfopen: /lib/functions/fsck/e2fsck.sh: No space left on device.
    * pkg_write_filelist: Failed to open //usr/lib/opkg/info/e2fsprogs.list: No spa
    ce left on device.
    * opkg_install_pkg: Failed to extract data files for e2fsprogs. Package debris
    may remain!
    * opkg_install_cmd: Cannot install package e2fsprogs.
    * verify_pkg_installable: Only have 44kb available on filesystem /overlay, pkg
    fdisk needs 47
    * opkg_install_cmd: Cannot install package fdisk.
    * opkg_conf_write_status_files: Can't open status file //usr/lib/opkg/status: N
    o space left on device.
    root@OpenWrt:~#
    root@OpenWrt:~#

    my usb thumbdrive is in its original formatting (i believe its fat32). do i have to format my thumbdrive to ext4 first? can i use usb hdd with ext3? i prefer ext3.

    thanks.

  16. @publicEnemy: i wrote this blog entry mainly to document for me how i setup the piratebox and startet to play with it. I’m no expert on the piratebox a so i’m afraid i can’t help you very much 🙁

    I made some notes in the article where i had problems and how i got around them. If this is not the right way for you (i used ext4 and it worked), i can’t help you much.

    but reading your errors, one that may cause a lot of your problems is the last one:
    opkg_conf_write_status_files: Can’t open status file //usr/lib/opkg/status: No space left on device.

    seems you ran out of space. As i mentioned:
    please double check that the rootfs has a very low Use% – if it’s still at 50% oder higher it’s likely that the extroot on /overlay is not working!
    I think you have the same problem, overlay is not working and as the tp-link has very limited “harddisk” space, you get errors trying to install packages when the drive is full.

    Another hint: i started with a fresh router, so factory default. Maybe you have to do the same: original firmeware, following the howto and use ext4 for the usb stick.

    wish you luck 😉

  17. i did openwrt factory reset by
    rm -r /overlay/*

    then i redo again from start.

    i got problem installing package

    root@OpenWrt:~# opkg install e2fsprogs
    Installing e2fsprogs (1.42.4-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/generic/packages/e2fsprogs_1.42.4-1_ar71xx.ipk.
    Installing libext2fs (1.42.4-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/generic/packages/libext2fs_1.42.4-1_ar71xx.ipk.
    Installing libcom_err (1.42.4-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/generic/packages/libcom_err_1.42.4-1_ar71xx.ipk.
    Installing libpthread (0.9.33.2-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/generic/packages/libpthread_0.9.33.2-1_ar71xx.ipk.
    Configuring libpthread.
    Configuring libcom_err.
    Configuring libext2fs.
    Collected errors:
    * extract_archive: Cannot create symlink from ./usr/sbin/mkfs.ext3 to ‘mke2fs’: No space left on device.
    * extract_archive: Cannot create symlink from ./usr/lib/libe2p.so.2 to ‘libe2p.so.2.3’: No space left on device.
    * wfopen: /usr/lib/libe2p.so.2.3: No space left on device.
    * wfopen: /etc/e2fsck.conf: No space left on device.
    * wfopen: /lib/functions/fsck/e2fsck.sh: No space left on device.
    * pkg_write_filelist: Failed to open //usr/lib/opkg/info/e2fsprogs.list: No space left on device.
    * opkg_install_pkg: Failed to extract data files for e2fsprogs. Package debris may remain!
    * opkg_install_cmd: Cannot install package e2fsprogs.
    * opkg_conf_write_status_files: Can’t open status file //usr/lib/opkg/status: No space left on device.

    then i check my file space usage

    root@OpenWrt:~# df
    Filesystem 1K-blocks Used Available Use% Mounted on
    rootfs 1088 1024 64 94% /
    /dev/root 2048 2048 0 100% /rom
    tmpfs 14612 1844 12768 13% /tmp
    tmpfs 512 0 512 0% /dev
    /dev/mtdblock3 1088 1024 64 94% /overlay
    overlayfs:/overlay 1088 1024 64 94% /

    it seems to me that i utilize almost all space on my router.

    how can i format/remove everything to start from scratch?

    thanks.

  18. i check rootfs before starting. its 19% use%.
    after installing package with no space left errors, i was left with rootfs 94% use%
    i formatted my usb hdd storage to ext4 and connect to router before starting and remove my usb hdd storage form router before starting. both time yield same error, no space left.

    here are the details

    root@OpenWrt:~# df
    Filesystem 1K-blocks Used Available Use% Mounted on
    rootfs 1088 212 876 19% /
    /dev/root 2048 2048 0 100% /rom
    tmpfs 14612 64 14548 0% /tmp
    tmpfs 512 0 512 0% /dev
    /dev/mtdblock3 1088 212 876 19% /overlay
    overlayfs:/overlay 1088 212 876 19% /

    root@OpenWrt:~# opkg update
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/Packages.gz.
    Inflating http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/gene
    ric/packages/Packages.gz.
    Updated list of available packages in /var/opkg-lists/attitude_adjustment.

    root@OpenWrt:~# opkg install kmod-usb-uhci
    Installing kmod-usb-uhci (3.3.8-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-usb-uhci_3.3.8-1_ar71xx.ipk.
    Configuring kmod-usb-uhci.

    root@OpenWrt:~# insmod uhci

    root@OpenWrt:~# opkg install kmod-usb-ohci
    Package kmod-usb-ohci (3.3.8-1) installed in root is up to date.

    root@OpenWrt:~# insmod usb-ohci

    root@OpenWrt:~# opkg update
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/Packages.gz.
    Inflating http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/gene
    ric/packages/Packages.gz.
    Updated list of available packages in /var/opkg-lists/attitude_adjustment.

    root@OpenWrt:~# opkg install kmod-usb-storage
    Installing kmod-usb-storage (3.3.8-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-usb-storage_3.3.8-1_ar71xx.ipk.
    Installing kmod-scsi-core (3.3.8-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-scsi-core_3.3.8-1_ar71xx.ipk.
    Configuring kmod-scsi-core.
    Configuring kmod-usb-storage.

    root@OpenWrt:~# opkg install block-mount
    Installing block-mount (0.2.0-9) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/block-mount_0.2.0-9_ar71xx.ipk.
    Installing blkid (2.21.2-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/blkid_2.21.2-1_ar71xx.ipk.
    Installing libblkid (2.21.2-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/libblkid_2.21.2-1_ar71xx.ipk.
    Installing libuuid (2.21.2-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/libuuid_2.21.2-1_ar71xx.ipk.
    Installing swap-utils (2.21.2-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/swap-utils_2.21.2-1_ar71xx.ipk.
    Configuring libuuid.
    Configuring libblkid.
    Configuring blkid.
    Configuring swap-utils.
    Configuring block-mount.

    root@OpenWrt:~# opkg install kmod-fs-ext4
    Installing kmod-fs-ext4 (3.3.8-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-fs-ext4_3.3.8-1_ar71xx.ipk.
    Installing kmod-lib-crc16 (3.3.8-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-lib-crc16_3.3.8-1_ar71xx.ipk.
    Configuring kmod-lib-crc16.
    Configuring kmod-fs-ext4.

    root@OpenWrt:~# opkg install kmod-fs-vfat
    Installing kmod-fs-vfat (3.3.8-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-fs-vfat_3.3.8-1_ar71xx.ipk.
    Configuring kmod-fs-vfat.

    root@OpenWrt:~# opkg install kmod-nls-cp437
    Installing kmod-nls-cp437 (3.3.8-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-nls-cp437_3.3.8-1_ar71xx.ipk.
    Configuring kmod-nls-cp437.

    root@OpenWrt:~# opkg install kmod-nls-cp850
    Installing kmod-nls-cp850 (3.3.8-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-nls-cp850_3.3.8-1_ar71xx.ipk.
    Configuring kmod-nls-cp850.

    root@OpenWrt:~# opkg install kmod-nls-iso8859-1
    Installing kmod-nls-iso8859-1 (3.3.8-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-nls-iso8859-1_3.3.8-1_ar71xx.ipk.
    Configuring kmod-nls-iso8859-1.

    root@OpenWrt:~# opkg install kmod-nls-iso8859-15
    Installing kmod-nls-iso8859-15 (3.3.8-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/kmod-nls-iso8859-15_3.3.8-1_ar71xx.ipk.
    Configuring kmod-nls-iso8859-15.

    root@OpenWrt:~# opkg install kmod-scsi-core
    Package kmod-scsi-core (3.3.8-1) installed in root is up to date.

    root@OpenWrt:~# opkg install e2fsprogs
    Installing e2fsprogs (1.42.4-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/e2fsprogs_1.42.4-1_ar71xx.ipk.
    Installing libext2fs (1.42.4-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/libext2fs_1.42.4-1_ar71xx.ipk.
    Installing libcom_err (1.42.4-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/libcom_err_1.42.4-1_ar71xx.ipk.
    Installing libpthread (0.9.33.2-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/libpthread_0.9.33.2-1_ar71xx.ipk.
    Configuring libpthread.
    Configuring libcom_err.
    Configuring libext2fs.
    Collected errors:
    * extract_archive: Cannot create symlink from ./usr/sbin/mkfs.ext3 to ‘mke2fs’:
    No space left on device.
    * extract_archive: Cannot create symlink from ./usr/lib/libe2p.so.2 to ‘libe2p.
    so.2.3’: No space left on device.
    * wfopen: /usr/lib/libe2p.so.2.3: No space left on device.
    * wfopen: /etc/e2fsck.conf: No space left on device.
    * wfopen: /lib/functions/fsck/e2fsck.sh: No space left on device.
    * pkg_write_filelist: Failed to open //usr/lib/opkg/info/e2fsprogs.list: No spa
    ce left on device.
    * opkg_install_pkg: Failed to extract data files for e2fsprogs. Package debris
    may remain!
    * opkg_install_cmd: Cannot install package e2fsprogs.
    * opkg_conf_write_status_files: Can’t open status file //usr/lib/opkg/status: N
    o space left on device.
    root@OpenWrt:~# opkg install fdisk
    Installing fdisk (2.21.2-1) to root…
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/ge
    neric/packages/fdisk_2.21.2-1_ar71xx.ipk.
    Collected errors:
    * wfopen: //usr/lib/opkg/info/fdisk.control: No space left on device.
    * wfopen: /sbin/fdisk: No space left on device.
    * set_flags_from_control: Failed to open //usr/lib/opkg/info/fdisk.control: No
    such file or directory.
    * pkg_write_filelist: Failed to open //usr/lib/opkg/info/fdisk.list: No space l
    eft on device.
    * opkg_install_pkg: Failed to extract data files for fdisk. Package debris may
    remain!
    * opkg_install_cmd: Cannot install package fdisk.
    * opkg_conf_write_status_files: Can’t open status file //usr/lib/opkg/status: N
    o space left on device.

    root@OpenWrt:~# df
    Filesystem 1K-blocks Used Available Use% Mounted on
    rootfs 1088 1020 68 94% /
    /dev/root 2048 2048 0 100% /rom
    tmpfs 14612 1840 12772 13% /tmp
    tmpfs 512 0 512 0% /dev
    /dev/mtdblock3 1088 1020 68 94% /overlay
    overlayfs:/overlay 1088 1020 68 94% /
    root@OpenWrt:~#

    what can i do? any suggestion?

    thanks.

  19. I see Public Enemy’s complaint / problem. Box #16 (counting down through the instuctions from the top) is :

    >root@OpenWrt:~# opkg update
    >root@OpenWrt:~# opkg install kmod-usb-storage block-mount kmod-fs-ext4 kmod-fs-vfat
    >kmod-nls-cp437 kmod-nls-cp850 kmod-nls-iso8859-1 kmod-nls-iso8859-15 kmod-scsi-core
    >e2fsprogs fdisk

    During this install I get a disk full error on the TP-LINK MR3020 and that preceeds box #22:

    >config ‘mount’
    > option target /overlay
    > option device /dev/sda1
    > option fstype ext4
    > option options rw,sync
    > option enabled 1
    > option enabled_fsck 0

    Whereafter you warn to make sure the % used on the root FS is small.

    I am now stuck with a 95% disk and the system will not even let me vi /etc/config/fstab to get the overlay onto the USB stick to get past this.

    I am not saying the instructions are broken, but, if one could determine which packages of:

    >opkg install kmod-usb-storage block-mount kmod-fs-ext4 kmod-fs-vfat
    >kmod-nls-cp437 kmod-nls-cp850 kmod-nls-iso8859-1 kmod-nls-iso8859-15 kmod-scsi-core
    >e2fsprogs fdisk

    were not absolutely essential to mounting the USB stick in an overlay, then one might leave out some of this, get the overlay working, then install the rest.

    As for my current stuck position, I am looking around the rootfs for something I can delete / move into a save directory on the USB stick (I can mount it, I just can’t overlay it without being able to write to /etc/config/fstab) so that I can just edit the one file I need changed. Problem is, the install is so compact, I cannot see anything that is obvious to me as non-essential to assure the system will boot without the USB-stick and get back to the SSH-able safe state I am in now. I am afraid if I delete the wrong thing, I will brick it, won’t be able to get back in, and that will be that.

  20. Got my solution…. to make a little free space, I did this:

    >root@OpenWrt:~# opkg remote kmod-fs-vfat

    So in summary, after I got the out of space error at box 16, I took my USB stick to my Ubuntu computer and did a few of the steps after 16 to get it ready:

    Instead of:

    ls /dev/sd*

    on the TP-LINK MR3020, actually I did a ‘df’ on my Ubuntu computer to see where the stick was automounted on my Ubuntu computer, found it was auto-mounted as /dev/sdd1, so I:

    Ubuntu % umount /dev/sdd1
    Ubuntu % fdisk /dev/sdd (following instructions above)
    Ubuntu % mke2fs -t ext4 /dev/sdd1 (probably the same command as above, don’t make fs that often, so,
    I used what I know works)

    That got the USB ready. To check it, I mounted it:

    Ubuntu % mkdir /test
    Ubuntu % mount /dev/sdd1 /test
    Ubuntu % cd /test
    Ubuntu % ls
    lost+found <<<< this told me I had a new fs there
    Ubuntu % umount /dev/sdd1

    I de-powered the MR3020, unplugged the USB from the Ubuntu computer, plugged it into the MR3020, powered it, waited… ssh'ed back in as root,

    root@OpenWrt:~# mount /dev/sda1 /www

    I did this because there was no space to do mkdir /mnt/usb (gave error), and I was not going to be urgently using the /www right at this second.

    root@OpenWrt:~# tar -C /overlay -cvf – . | tar -C /www -xvf –
    root@OpenWrt:~# vi /www/etc/config/fstab (making changes as above)

    root@OpenWrt:~# rm /etc/config/fstab (I did it, not sure if needed)

    root@OpenWrt:~# opkg remote kmod-fs-vfat <<<<< to free up space

    root@OpenWrt:~# cp /www/etc/config/fstab /etc/config/fstab to put the edited fstab back

    root@OpenWrt:~# reboot

    Now after it reboots, ssh back in as root, with a 16G USB stick, I have:

    root@OpenWrt:~# df
    Filesystem 1K-blocks Used Available Use% Mounted on
    rootfs 15302156 358992 14175408 2% /
    /dev/root 2048 2048 0 100% /rom
    tmpfs 14608 88 14520 1% /tmp
    tmpfs 512 0 512 0% /dev
    /dev/sda1 15302156 358992 14175408 2% /overlay
    overlayfs:/overlay 15302156 358992 14175408 2% /

    I got past the no space left block that prevented me from getting past step 16. I think this would be a useful work-around, or edit the directions above to avoid the problem in the first place. I think anyone who can follow these directions either already has a Linux computer, or, already has a live boot CD so telling them to do a few steps with the USB on another computer would not be a problem.

  21. Hi Wolfgang, I’d like to set up something very simply. You see the wifi and the index page just links to content in the same folder. Would this work on your system – I was looking at the http://www.corsair.com/voyager-air but you need an app to browse content. Any advice?

  22. hi,
    the product you linked does a little more than just displaying a webpage. it’s a combined media server with fileserver and has apps to access the data on this device from a phone or tabled “increasing” the space you have on these devices virtually, as you can access the data over network without the need to store them physically on the mobile device.

    this article is about how to use a cheap wireless router as a webserver. in a simple way it’s comparable to the device, because you can put any data you want in the directory served by the webserver and access it over WIFI from a computer or mobile device. if the mobile device is capable of displaying the data (mp4 movies, mp3 files, documents, …) then it does the same as the corsair device.

  23. Thank you for putting all of this info together. Has anyone tested if PHP will work with this setup?

  24. HI!! Very nice tutorial…i found this only after i’ve already done it….
    I’m using a TP-LINK MR3220 and i’m routing all traffic on LAN and WiFi to my local website.

    But where is “TODO: reroute internet access to local website (firewall, dhcp settings”?

    I’ve done this with firewall rule and dnsmasq configuration. And if i type some site, ip or internet resource (on 80 and 443 ports) i’m redirected correctly to the websito on the router….the problem is when i tri to connecto to somesite url with HTTPS (like facebok, google search page, others..). The problem seems that DNSMASQ doesn’t resolve the DNS https url to my IP router!!!!
    https://forum.openwrt.org/viewtopic.php?pid=227693#p227693
    What can i do?
    Many thanx!
    Lorenzo

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.