Wednesday, August 12, 2015

Linux FIle & Media Server

I had several external usb hardisk. I need to bring them along with my laptop when needed. I though why not create a file server, so that i can still access it anywhere at home. Utilizing one of the cubieboard, i create this file server.

Samba Server
sudo apt-get install samba cifs-utils ntfs-3g dosfstools

add these lines at the end of /etc/samba/smb.conf
 path = /media
 public = yes
 writable = yes
 comment = smb share
 printable = no
 guest ok = yes
 read only = no
 directory mask = 0777

Network File Server
sudo apt-get install nfs-kernel-server nfs-common

add these lines at the end of  /etc/exports

sudo apt-get install ftp ftpd tftp tftpd
for easy acces, lets create symlinks to share folder
sudo ln -s /media ~/.

Debian wheezy come up with rygel media server, a part of gnome project. This enable to share your media files trough UPnP/DLNA protocol. You can play it in UPnP/DLNA player such as XBOX, Playstation, Windows media player or other UPnP/DLNA player on your gadget.
sudo apt-get install rygel
Add your media folder (replace below path) in this line at /etc/rygel.conf,
Add rygel to rc.local to enable it at boot time, i use nohup to keep the application run and dump output to /tmp/rygel.log, change this log file path as you need
nohup rygel >> /tmp/rygel.log 2 >> /tmp/rygel.log & 

Create script to mount the disk catagorized as it's label
for i in /dev/disk/by-label/*

   #put your unmounted label disk list in this line
   if [ "$a" == "debian6" ] || [ "$a" == "debian7" ];then
     echo "not mounting $a"

     if ! [ -e "/media/$a" ];then
       echo "crate dir /media/$a"
       mkdir /media/$a -vp
       chmod 0777 /media/$a
     echo "checking media"
     fsck -vy $i
     echo "mount $a"
     mount $i /media/$a -v


Call The script from /etc/rc/local, and wait until finished before call others like rygel
./diskmount &&
nohup rygel >> /tmp/rygel.log 2 >> rygel.log &

Mount SMB
mount -t cifs // /media/data -o user=me,password=key,rw

Mount NFS
mount -t nfs /media/data

No comments:

Post a Comment