OpenWRT

Linux distribution for embedded devices

Installation

search for your router model in: http://wiki.openwrt.org to find specific instructions

Config

Install LUCI web interface

opkg update
opkg install luci
/etc/init.d/uhttpd enable
/etc/init.d/uhttpd start

reach the webiface at http://router_IP/

Install Bash & setup .bashrc

opkg update
opkg install bash

edit /etc/passwd and replace /bin/ash for /bin/bash in the line starting with root:

echo ". $HOME/.bashrc" > /root/.bash_profile

put your custom .bashrc in /root/.bashrc

SSH publickey authentication

you can do this in the webiface or manually:

copy your key from your desktop to the router's /tmp/ dir:

scp ~/.ssh/id_rsa.pub root@<router IP>:/tmp

log in to the router and move the key:

cat /tmp/id_rsa.pub >> /etc/dropbear/authorized_keys
chmod 0600 authorized_keys

Reverse SSH publickey authentication - from router to desktop

a private key is autogenerated by dropbear in /etc/dropbear/dropbear_rsa_host_key

extract id_rsa.pub public key on the router:

dropbearkey -y -f /etc/dropbear/dropbear_rsa_host_key | grep ssh-rsa > /tmp/dropbear_rsa_host_key.pub

add the content of this file to '~/.ssh/authorized_keys' on the remote box

log in with

ssh -i /etc/dropbear/dopbear_rsa_host_key user@remotebox

USB storage

USB2.0 kernel module installation:

http://wiki.openwrt.org/doc/howto/usb.essentials

opkg update
opkg install kmod-usb2
insmod ehci-hcd

package & filesystem modules installation:

http://wiki.openwrt.org/doc/howto/usb.storage#required.packages

opkg update
opkg install kmod-usb-storage kmod-usb-storage-extras kmod-scsi-generic e2fsprogs kmod-fs-ext4 kmod-fs-vfat 
opkg install block-mount block-extroot block-hotplug 

format usb drive:

FIXME testing ext4 options from https://blogofterje.wordpress.com/2012/01/14/optimizing-fs-on-sd-card/

“Ext4 with block size of 4k, without journaling, but with additional parameters to encourage Ext4 to do the right thing with respect to the erasure block:”

mkfs.ext4 -O ^has_journal -E stride=2,stripe-width=1024 -b 4096 -L usbdata /dev/sdXY

auto mount on boot:

http://wiki.openwrt.org/doc/howto/usb.storage#configuration

block-mount and block-hotplug will take care of boot and automount.

edit config in /etc/config/fstab - example with swap and data partition:

config global automount
      option from_fstab 1
      option anon_mount 1

config global autoswap
      option from_fstab 1
      option anon_swap 1

config mount
      option target   /mnt/sd
      option device   /dev/sdc2
      option fstype   ext4
      option options  rw,sync,noatime,nodiratime
      option enabled  1
      option enabled_fsck 1

config swap
      option device   /dev/sdc1
      option enabled  1
 
Back to top
communitycloud/freifunk/openwrt.txt · Last modified: 2012/09/09 19:04 by tkilla