Linux Freedom — Basis for Integrated Home Building on Open Source

Published by Tomas  Vitvar on January 3, 2008 in Ideas,Linux

I have recently purchased a Linksys WRTSL54GS router, and installed a third-party firmware called OpenWrt.

It is really amazing as I actually got almost a fully-fledged linux running in a very small box (see for example the packages available for white russian distribution of OpenWrt). In fact, I was always thinking about having a linux server for my home network management, however, I did not like the idea of having a big server (due to the power consumption, space and possibly noise). I have deliberately chosen WRTSL54GS as it is quite powerful (comparing to other devices in the area): 8MB of flash and 32MB of RAM, it has a USB port and is only around $100. The only drawback is that Linksys does not sell it in Europe so I had to get one on eBay from the US directly. With shipment costs it was something around 100€. An alternative would be for example ASUS, FREECOM, Siemens, etc., however they are usually more expensive, less powerful or they include HDD already. There is also an interesting book Linksys WRT54G: Ultimate Hacking describing various linux distributions for various Linksys devices as well as hardware hacking tips and tricks. This is a must have too if you plan to do more than just clicking on router’s management web interface.

So may hands are free to configure my SOHO network directly using iptables, cron, samba, and other great stuff which OpenWrt offers. With more devices on my network it will be even more fun to manage all…

With the need for integration of various data sources from various devices on the SOHO network, there is a joint initiative between DERI Galway and EPFL called semantic reality. The idea is to develop a technology for seamless integration of various devices (sensors) in ad-hoc networks. Although I am not personally involved in this project, I believe that linux-based firmware provides a great flexibility for functionality — the basis for integrated home building on open source software.

Auto Mount a Network File System in Ubuntu based on a Specific Network

Published by Tomas  Vitvar on October 20, 2007 in Linux

When you use different network file systems on different networks (e.g., you often move your laptop from work to home) you may want to mount them automatically depending on the network you are connected. You can do this with a script I introduce in this post.

I often take my laptop from work to home and thus change the networks. At work there are network file systems which I use to backup my data and share files with others. These are only accessible from my work’s private network. When I am at home, I need to mount my home network file system — the source for my video and music. The other situation might be that you want to mount file systems at certain network where you have a fast access to those file systems (e.g., file system in your linux server at work over ssh). To do this automatically depending on the network you are connected, just follow the steps below. This idea and the script are based on the idea and the script for auto mounting SSH file systems.

HOWTO
This howto works for Ubuntu Fiesty. Feel free to adjust it to your distribution and environment.

1: you need to specify valid networks for your fstab entries. For this the script uses the comment attribute of fstab entry options where in single quotas you list the network addresses that the file system should be mounted at. The individual network addresses are separated with commas as shown in the example below.

//srvname /mnt/somedir cifs comment='192.168.16.0,10.2.16.0', username=usr,password=pswd,domain=IE,noauto 0 0

You also should specify noauto attribute to prevent the file system to be mounted automatically by your system. The script will take care of it instead. Also, since network file systems are usually only accessible with proper username/password you should also specify those.

2: download the scripts mount-networks and umount-networks to the folder /etc/network/if-up.d and /etc/network/if-down.d respectively. You can do it using following commands:

sudo wget http://www.vitvar.com/misc/mount-networks --directory-prefix=/etc/network/if-up.d/

sudo wget http://www.vitvar.com/misc/umount-networks --directory-prefix=/etc/network/if-down.d/

3: set the rights for those scripts so that they can be executed:

sudo chmod 601 /etc/network/if-up.d/mount-networks sudo chmod 601 /etc/network/if-down.d/umount-networks

That’s it. You can now switch your networks and your file systems will be mounted as you define in your fstab.

How it works
The script mount-networks is executed whenever the network is on. It searches for all fstab entries with attribute comment. For each entry, it parses the comment attribute and gets all the networks. Then, it gets IP addresses and masks for all interfaces using the ifconfig shell command. For each IP address and using the mask, the script tests if the IP belongs to at least one of the neworks from the fstab entry. If yes, the script mounts the file system.

The script umount-networks is executed whenever the network gets down. The script just unmounts all file systems from the fstab which have the comment attribute defined with list of networks.

Blog

Archive