Friday, July 18, 2014

MK802+ as a home server (Part 8) : Scan Server for windows (32bit /64bit) based computers

Whoa , part 8 . Yes i've not published some of other parts yet but since this is done i will publish it first :D.

For this post , i need to set my all in one old scanner for use over the network . I actually found a lot of people doing this , so i thought why not do it with my MK802 as well , specially that I've been using it for almost a year now. I have an HP All-in-one F2280 and this is the model that i will test with through this post.

Installing the Scanner
At first , I couldn't get the scanner to be detected by debian , so i ran
hp-setup -i and still , it couldn't detect the scanner by itself.
Anyway , I installed the HPLip , with apt-get install Hplip
I did a test to check that the scanner is detected,  i used the command
scanimage -L
The result came out as follows

which basically means the scanner is now detected.

Next , i go setup the printer using the command
hp-setup -i

and then follow the wizard.

Configuring Sane-Utils
Because we need to enable the scanner remotely the Sane-utils should be run as a daemon (background server) . To do this we need to run saned. I got the how to from this guide . Please note that i'm using nano (a text editor) instead of gedit to configure the saned daemon.
So i will use the command
nano /etc/default/saned
and edit the line RUN=no to become RUN=yes next is configuring the access list by
nano /etc/sane.d/saned.conf

we'll continue with this guide here . There are no special remarks here except that , just like the last paragraph in the guide , we may have to a modify permissions of saned user and set reading permission on the /dev path of the scanner. You'll also notice that i commented a modification to the guide, please read and apply it or it won't work.
sudo adduser saned lp
sudo adduser saned saned
Note:  To find the /dev path we'll go to the /dev using the cd command. Now unplug and replug the scanner's usb and run command dmesg. Mine turned to be usblp0 under usb/lp0  This is done by running the command (i got it from here)
chown root:saned /dev/usb/lp0 && chmod g+rw /dev/usb/lp0 
The Windows Front End I'm using windows 8.1 64 bit , the only solution that worked was software published on sourceforge Please download , install and run. Press acquire then you'll get the host configuration Provided that everything was setup correctly the next dialog will bring you the available devices ,and your scanner should be listed. The program finally provides an interface for doing the actual scanning. Happy Scanning over the network !!!

The Linux (Ubuntu) Front End was a bit tricky to say the least. The general process entitles installing xsane, sane-utils and libsane (and hplip if you have an HP). we should also be adding the IP of the saned server to the end of a file gedit /etc/sane.d/net.conf .
For my HP all in one, things were a bit different
1- I copied the printer URL from CUPS server on the saned server , the URL will look something like that hp:/usb/MODEL_NAME?serial=sn . MODEL_NAME is to be copied for the next step
2- I added the printer in CUPS to the client (add printer --> HPLIP)  in following format
replacing MODEL_NAME and SANED_SERVER_IP with their respective values
3- It may also be worth to mention to re-download hplip from
4- starting Xsane found the scanner

SaneOverNetwork : Debian Wiki

Friday, January 3, 2014

MK802+ as a home server (Part 4) : a permanent mount and SMB server for the home network

So , If you've been following the other posts of the series , you'll know that now we've so far installed a debian server with a webmin web ui on it.

In this post, i intend to setup a permanent mount of a Flash Drive and a shared folder from inside this flash drive to be accessed by a windows client. The fixed drive is going to be also used as a scratch disk for the transmission-daemon later, in order not to use the SD that has the system for the same purpose.

I assume that you're connected to the device using SSH with the root account. I use putty for that purpose as i am working from a windows machine

Flash drive at a fixed Mount:

I. [Optional ] Formatting the flash drive as XFS

Since i intend to use the flash drive for samba , after some research , i found that XFS filesystem is the most recommended for file server. To format the flash drive with XFS , you can use webmin  or install the xfsprogs package and continue using ssh.

to list the connected devices use the command

fdisk -l

your flash disk should be shown as /dev/sda (can be also shown as /dev/sdb or sdc according to the number of usb connected drives)

of course to use xfs file format i will install xfsprogs package, if it wasn't already installed
apt-get install xfsProgs

and to create the xfs partition i used the command
mkfs.xfs -f /dev/sda

anyway , now I want to mount it. So,  I create a mount point (an empty folder which will be replaced by the disk content when the disk is mounted) :
mkdir /mnt/DownloadDisk

to test the mounting
mount /dev/sda /mnt/DownloadDisk

II. Choosing the fixed mount point

Now the most important part is making it a fixed mount

First of all , we ought to know that linux mounts are stored in the /etc/fstab file , we need to edit that file in order to have our mount work on each boot of the system. Before we do any editing we should have a backup. You can use the cp (copy) command to make a backup

cd /etc
cp fstab fstab.BAK

The next step is editing the fstab file. we do so by the following command:
vi /etc/fstab

Add this line at the end of the file (press "a" to enter the editing mode) . You should replace sda with identifier of your drive

/dev/sda     /mnt/DownloadDisk    auto     defaults            0       0   

When you're done, press , then ":" , then write "wq" (for write and quit) and finally . This will save the file.

Now that you've finished editing the fstab file , reboot the device , and make sure that you can access the drive by

cd /mnt/DownloadDisk

If you want to understand the fstab file structure , go here

SMB server setup:
In this part i intend to use samba server to enable a folder on the fixed mount to be available for reading by the windows machine. All i need is to setup a directory in which all the completed downloads will be moved and hence be shared to the other machines in my network.

considering you're the root , enter the following command from your ssh client

apt-get install samba 

Next step will be setting up a windows share. For this part , I will use webmin's module for samba management
1- Open the webmin interface 
2- Go next to webmin-> webmin configuration -> webmin modules
3- Choose "Standard module" , press the button and choose "samba"
4- Click on the "Install Module" button

If you did everything correctly you should have a similar interface (webmin => Unused modules => Samba Windows FileSharing):

before proceeding , i created a directory inside the mounted volume to work as the share
mkdir /mnt/DownloadDisk/Downloads
We need to create a user name to be used from the other windows machines , instead of using the root password.. All the following steps can be performed easily with webmin (users and groups module) , i just want to do it using the terminal as a personal preference.

To create a group
groupadd DownloadsAccess

so in the terminal , create a user , replace username by the name you user name you want to add:
adduser username

add the user to the group

so my command will look like

usermod -a -G DownloadsAccess username

We need to give access to the group on the created Donwloads directory
So i modify group ownership of the folder

chgrp DownloadsAccess Downloads

Then i assign the folder's group write and read access permission
chmod -R g+rw /mnt/DownloadDisk/Downloads/

now we have to make samba aware of our user:

smbpasswd -a username

It will prompt for a password , you can enter the password that you're going to use for this user name when connecting from other machines.

1- Next will be to add a share with the "Create a new file share" link

2- In the create file share window, add the user group to the valid user.

3- Up to now i have a read file access on whatever files put in \\MyServer\Downloads , which is the goal of this section.

Here is a test from my windows machine where i could connect to the drive:

This step actually concludes the post

Read more: