8) As of every new version of Ubuntu, there are some minor bugs in the system. This time again is the sound card volume control. If you find you have a gray out speaker in your Indicator Plugin, you may try this.

0) Briefing

As my Scan Button on my scanner is not working with OpenWRT/Linux, I am going to use the QSS button on my TP-Link TL-WR1043ND to act as my scan button.
When I press the QSS button, OpenWRT will instruct my scanner to scan an image, save it to the share folder, so I can access it through Samba.

2) Setup SANE as a network enable service

This part involve quite some effort to get SANE network enable. Personally, I think SANE in OpenWRT is not very complete. But don’t worry, all you need to do is to create and edit some config files.

2.1) Get around the check_host error in SANE

This is the most important step to get around the check host problem of SANE. You must get this done first. Otherwise even you got all the below settings right, you will still unable to get SANE work over the network. The problem is SANE wants to know the router own host name but SANE could not find it.

Edit the following file:

vim /etc/host

Add the following line:

192.168.1.1 OpenWRT

IP_address = your_router_IP host_name = any_name_of_your_choice

2.2) Allow who can use your scanner from your network

Edit the following file:

vim /etc/sane.d/saned.conf

To allow only a subnet of computers to use your scanner, add the following line:

192.168.1.0/24

To allow all computer, add the following line, just a “+” sign:

+

Start SANE in debug mode, so we can do some test after setting up the client software

saned -d 128

——————————————————————————–

3) Setup client side softwares

3.1) In Ubuntu:

Install the following software:

sudo apt-get install sane-utils

If you also want graphical interface, install this as well:

sudo apt-get install simple-scan

Edit the following file, to tell SANE where the network enabled scanner is:

sudo vim /etc/sane.d/net.conf

Add the following line:

192.168.1.1

We can test the connectivity from client to server now, from your computer:

0) Briefing

USB external storage (Visit Ch05 to see how). Router has limited internal memory, so not much fun to have a share such a small space. But of course, I cannot stop you!

What next

Install Samba server ( 1992 Byte in size )

(Optional) Install luci-app-samba webpage app ( 92 Byte in size )

——————————————————————————–

1) Install Samba server software

Open up your favorite terminal and login into the router

ssh root@192.168.1.1

These commands will update database:

opkg update

Install Samba server (1992 Byte in size):

opkg install samba36-server

If you want to set your Samba via web interface, install (92 Byte in size):

opkg install luci-app-samba

——————————————————————————–

2) Add a user

You do not want everyone connected to your network will be able to see your files, so you need some kind of security to Samba. To have Samba secure, you need to have Samba User Account. To have Samba User Account, you need to have Linux system user account.

2.1) Setup new Linux system group for users account

To add new group, edit the following file:

vim /etc/group

Add the following line

john:x:1001

First field : group_name = john

Second field : group_password = x (I don’t think you can setup any)

Third field : group_id = assign a unique number between 1000 & 65534

2.2) Setup new Linux system user account

To add new user account, edit the following file:

vim /etc/passwd

Add the following line

john:x:1001:1001:John Watson:/var:/bin/false

First field : user_name = john

Second field : user_password = x (Password store in somewhere else)

Third field : user_id = assign a unique number between 1000 & 65534

Forth field : group_id = the group id you have set above

Fifth field : user_info = can be lots of things, Google yourself.

Sixth field : user_home_directory

Seventh field : user_login_startup_program = first program auto startup when login. Usually is a command shell, now we don’t start anything

2.3) Setup user password:

To setup user password:

passwd john

2.4) Setup a Samba user:

To setup a Samba user:

smbpasswd -a john

——————————————————————————–

3) Samba config

Please note :

Do NOT edit /etc/samba/smb.conf , it is a automatically generated file

3.1) Samba global config

Edit the following file:

vi /etc/samba/smb.conf.template

Do not change anything between “|”

The only settings I changed:

null passwords = no

3.2) Add a share folder:

I have setup two type of share folders, one is public read/write allowed, the other one is user login required.

0) Briefing

You should have already done

USB external storage (Visit Ch05 to see how). It is because you router is going to act as a printing server. When you press “Print” on you computer, the printing data will be buffered in the router first before send off to the printer, which usually you router will not have enough memory to buffer those huge printing data and result in strange problems.

2.2) Mounting

Now plug in your USB external storage to the router

Create a location for you share folder and mount it

mkdir /mnt/shares && mount /dev/sda1 /mnt/shares

To mount your swap partition:

swapon /dev/sda3

To config your drives mount automatically at boot, first you have to find out the UUID of each partition. UUID is used is because Linux system cannot guaranty it will give the same sda or sdb or sdc to a drive. So when you write down the config file to mount sda1 it may not work because your drive may become sdb1 when next boot. Although it is very rare to be happened, now Linux system use UUID. UUID only change when you format your drive.To find out the UUID of your drive:

3) rootfs on external storage ( extroot )

In Linux file system, Root ( / ) is the mother of all folders and files. Every folder and file structure start building from there, just like C: drive in MS Windows.

Additionally, Linux link a USB external storage to a folder when it is plug in, so all other softwares in Linux will think it is just another normal folder rather than something special. They call this Mounting to a folder.

In OpenWRT, there are two main folders. One is /rom, which hold all pre-installed softwares. The other is /overlay, which hold every other data and settings, which included softwares that you manually installed.

What are we going to do now is to ask the system to mount our external drive to /overlay at boot. Imagine the original /overlay like a bin, you put things in it. Then what are we doing next is to put a plastic bag over the bin, which the bag represent the external drive. People still think they put thing into the bin, but actually the bag store everything, and when the bag is remove, it will expose the original stuffs inside the bin.

3.1) Partitioning and formating

If you have not partition and format your USB external storage, just follow the Step 2.1 above

3.3) Copy original /overlay data to external storage

As my Bin and Bag explanation above, if you put your new bag inside the bin, people will think it is a empty bin, however, the original stuffs inside the bin is needed. So we need to duplicate them to our bag.

First if your drive is not mount, mount it, in my case is sda2:

mkdir /mnt/sda2 && mount /dev/sda2 /mnt/sda2

Then copy the original data to the external storage:

tar -C /overlay -cvf - . | tar -C /mnt/sda2 -xf -

Unmount the external drive then reboot:

umount /mnt/sda2 && rm -rf /mnt/sda2

——————————————————————————–

4) Quick tips

If you do not want to edit /etc/config/fstab, you can edit /etc/fstab: