Previously I wrote an article on Dedicated server for downloading torrents and monitor over WiFi. It provides a deeper look into centralized downloading application however it would be good to have this application download files into a central repository that can be shared over the network. Samba can help provide that functionality.
In essence what we need is a Samba server such that once the files are downloaded they can be viewed from anywhere, on any computer, connected on the network running Samba service. One of the cheapest way to do this is using Pogoplug device.
Lets look at step by step on how to install Samba on Pogoplug SD card and usb hub. The Pogoplug mobile version has one USB port and one SD card slot.
There are various ways to set this up but most efficient way turned out to be using USB port for data drive and SD card slot for installing packages. This allows you to change or format USB drives as and when needed without affecting your packages installed. It also allows moving the USB drive to another computer to read if you are not on the network with Samba service (say traveling) and then placing it back when done.
What was used for this setup:
1. Pogoplug Mobile
2. 2GB SD card
3. 500 GB external USB drive
4. 4 GB usb drive
5. Powered USB Hub
Setup access into Pogoplug
Go to my.pogoplug.com and then enable SSH via their website. Take a note of your username and password. Connect USB drive and SD card to your Pogoplug.
Preparing the storage (USB and SD card)
Before we can make use of storage we will need to format appropriately. Following steps help with that.
Stop the Pogoplug service :
killall hbwd
Make two directories – /opt for packages and /data for all our data files in Samba storage :
mount -o remount,rw / mkdir /opt mkdir /data
Verify available disks as shown below. Note that this will not show the SD card but only USB disk :
[[email protected] /root]# fdisk -l Disk /dev/sda: 500.1 GB, 500107860480 bytes 255 heads, 63 sectors/track, 60801 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 1 60801 488384001 83 Linux
Mount the SD card:
/bin/mount /dev/mmcblk0p1 /opt Mount the USB disk based on results of fdisk command above: /bin/mount /dev/sda1 /data
Installing package manager on SD Card
Download and install Optware:
cd /opt wget http://www.teqlog.com/wp-content/custom/Optware.tar.gz tar -xzvf Optware.tar.gz rm Optware.tar.gz ipkg update
Configure and Install Samba on Pogoplug SD Card
ipkg install samba36 libnsl nano
[global] workgroup = WORKGROUP server string = POGOPLUG netbios name = POGOPLUG load printers = no printing = bsd printcap name = /dev/null disable spoolss = yes log file = /tmp/var/%m.log max log size = 50 socket options = IPTOS_LOWDELAY TCP_NODELAY SO_KEEPALIVE write cache size = 2097152 use sendfile = yes #unprotected share : Login not enforsed security = user map to guest = Bad User guest account = root [root$] path = / read only = no public = yes writable = yes #force user = root guest ok = yes [usb] path = /data read only = no public = yes writable = yes #force user = root guest ok = yes
Start SAMBA Service
/opt/etc/init.d/S08samba start
Making the process repeatable on Pogoplug restarts
Create a file (called “addon”) in directory /etc/init.d with above commands as follows :
/bin/sleep 30 killall hbwd /bin/sleep 30 /bin/mount /dev/mmcblk0p1 /opt /bin/sleep 30 /bin/mount /dev/sda1 /data /bin/sleep 30 #Check if external drives are ready count=`df|grep "/dev/sda1" |wc -l` if [ $count -ne 0 ] then echo "pattern match found" /opt/etc/init.d/S08samba start 2>&1 > /tmp/samba.log else echo "no match with the pattern" echo "led=msg" > /dev/xce exit fi #Change the led color to red to show Pogoplug is now running Samba. echo "led=dis" > /dev/xce
chmod 755 addon
/etc/init.d/addon
Adding the USB hub to add additional disks on Pogoplug
USB hub used in this test is Belkin 7-Port Powered Desktop Hub (F4U022tt). Being powered allows it to attach non powered external drives such as the 500 GB one that I was using.
All that needs to be done is to attach the hub to pogoplug and then add disks to it. Doing so will show second disk as below:
[[email protected] ]# fdisk -l
Disk /dev/sda: 500.1 GB, 500107860480 bytes 255 heads, 63 sectors/track, 60801 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 1 60801 488384001 83 Linux Disk /dev/sdb: 4009 MB, 4009754624 bytes 124 heads, 62 sectors/track, 1018 cylinders Units = cylinders of 7688 * 512 = 3936256 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 1018 3913161 83 Linux [[email protected] ]#
Now all that remains is to mount /dev/sdb1 in same manner as /dev/sda1 shown above in addon script file.
Create a new directory:
mkdir /data1
Mount the new disk (add following command to addon script)
/bin/mount /dev/sdb1 /data1
Modify Samba configuration (add following to smb.conf file above)
[usb] path = /data1 read only = no public = yes writable = yes #force user = root guest ok = yes