Insufficient disk space on WRT54G? Increase it through samba!

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
FilesystemSizeUsedAvailableUse%Mounted on
/dev/root896.0k896.0k0100%/rom
none7.0M24.0k7.0M0%/tmp
/dev/mtdblock/42.3M1000.0k1.3M42%/jffs
/jffs896.0k896.0k0100%/
//192.168.168.10/ddwrt$2.0G14.5M2.0G1%/tmp/samba

It is pretty simple to do all this.

Stuffs needed:

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
root@OpenWrt:~#

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
Package: bitchx
Version: 1.1-1
Depends: libncurses
Status: install user installed
Section: net
Architecture: mipsel
maintainer: OpenWrt Developers Team
MD5Sum: 5d48b3a20fe8bc8849371a84ee5aed30
Size: 719661
Filename: bitchx_1.1-1_mipsel.ipk
Source: packages/net/bitchx
Description: popular IRC client

Successfully terminated.

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!

 

Treat shadowandy!

If these step-by-step guides have been very helpful to you and saved you a lot of time, please consider treating shadowandy to a cup of Starbucks.