After changing the firmware to OpenWRT (WhiteRussians), I was overwhelmed by the number of modified linux packages available for the system! I started installing lots of stuffs (using IPKG) and soon meet a deadend to my exploration. Insufficient disk space on the ‘/jffs’ mount. With some basic knowledge of Linux (knowledge courtesy of CS2106 – Operating Systems), I fiddled with samba and soon was on my way to explore more packages for the system. Below is my current disk status.
root@OpenWrt:~# df -h Filesystem Size Used Available Use% Mounted on /dev/root 896.0k 896.0k 0 100% /rom none 7.0M 24.0k 7.0M 0% /tmp /dev/mtdblock/4 2.3M 1000.0k 1.3M 42% /jffs /jffs 896.0k 896.0k 0 100% / //192.168.168.10/ddwrt$ 2.0G 14.5M 2.0G 1% /tmp/samba
It is pretty simple to do all this.
1. Basic Linux knowledge (for SSH, editing of files and typing of commands) 2. An available network share (full permission) with known username and password, server ip of the share and share name 3. A WRT54G router with dd-wrt or openwrt firmware
Firstly, ensure that the needed packages for mapping network shares are installed
root@OpenWrt:~# ipkg list_installed | grep ^kmod-cifs
kmod-cifs – 2.4.30-brcm-5 – Kernel modules for CIFS support
If nothing is returned, install it
root@OpenWrt:~# ipkg install kmod-cifs
Try mapping the network share over,
root@OpenWrt:~# mkdir /tmp/samba
root@OpenWrt:~# mount -t cifs //<server ip>/<share name> /tmp/samba -o unc=\\\\<server ip>\\<share name>,user=<username>,pass=<password>
Now try writing to /tmp/samba and see if everything works fine. If you can write to and read from a file in /tmp/samba means that everything is working fine for you.
Bad news: stuffs on /tmp get wiped out every reboot. Means that samba folder would be gone and you would to type the two commands above everytime you reboot your router.
Good news: Custom startup script to the rescue!
You can either edit the startup script through the webif (web management) or through SSH. Add the following entries
1. mkdir /tmp/samba & 2. mount -t cifs //<server ip>/<share name> /tmp/samba -o unc=\\\\<server ip>\\<share name>,user=<username>,pass=<password> & 3. echo dest smbfs /tmp/samba >> /etc/ipkg.conf &
Then type the following commands in the shell, just setting the PATH and LD_LIBRARY_PATH locations.
1. root@OpenWrt:~# echo export PATH=$PATH:/tmp/samba/bin:/tmp/samba/sbin:/tmp/samba/usr/bin:/tmp/samba/usr/sbin >> /etc/profile 2. root@OpenWrt:~# echo export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:/usr/lib:/tmp/samba/lib:/tmp/samba/usr/lib >> /etc/profile
Remember to fill in the the required file denoted by < and > symbols. The last three commands is to allow you to install to your new samba drive as well as running applications off the samba drive. The startup script would help you run these everytime you reboot! Good news isn’t it?
Things to take note though, library files are best installed to jffs while others you can install onto your new samba (destination smbfs).
What do I meant by installing library files onto jffs? An example of installing a package (bitchx – IRC Client)
root@OpenWrt:~# ipkg info bitchx
Status: install user installed
maintainer: OpenWrt Developers Team
Description: popular IRC client
Library packages starts with lib. Rule of (shadowandy’s) thumb, install libncurses (in this case) before installing bitchx package.
root@OpenWrt:~# ipkg install libncurses
root@OpenWrt:~# ipkg -d smbfs install bitchx
The first line without specifying the -d argument will install to /jffs by default. The second line has got ‘-d smbfs’ specified. Hence installation of the bitchx package will be onto /tmp/samba. Don’t understand why I do it this way? Try it yourself. Install everything onto smbfs will cause library linking problems. For simple packages, simply renaming works. For bigger ones, more stuffs need to be done inorder to make it work.
Time to explore more packages!