Introduction: Raspberry Pi NAS/UPNP MP3 Streaming Torrent Box Headless
Raspberry pi NAS/UPNP MP3 Streaming Torrent Box headless
I have a Raspberry Pi model B and a desktop HDD and wanted to host all my music and videos,
Todo this I will be using raspbian wheezy for the Pi, mediatomb for the upnp streaming for the music and samba for videos to be shared with XBMC on your laptop or pc or even a second Raspberry Pi.
User requirements: to have the basic understanding of linux and how to run commands in a terminal as we will not be using a monitor plugged into the Pi
WARNING: I except no responsibility for any mistakes made with the programs and make sure that no other SD or USB flash drive is inserted and backup all your data before using
Step 1: Requirements
these are the items required to finish this project
1. Raspberry Pi (B)
2. power cable and power source
3. ethernet cable
4. USB HDD(any size portable or desktop)
5. SD card at least 4GB
6. case (if you want)
no monitor required
1. rasbian http://www.raspbian.org/
2. mediatomb http://mediatomb.cc/
3. XBMC(for your pc/laptop) http://xbmc.org/
4. image writer for linux https://launchpad.net/usb-imagewriter/+download
5. win32-diskimager http://sourceforge.net/projects/win32diskimager/
6. samba (from repo. see instructions)
Step 2: Install Rasbian and Flash It to Your SD Card
first you need to install Rasbian from http://raspbian.org and flash it to your SD card using
WARNING: I except no responsibility for any mistakes made with the program and make sure that no other SD or USB flash drive is inserted and backup all your data before using
1. windows option
download win32-diskimager from http://sourceforge.net/projects/win32diskimager/
select the image downloaded and the device to flash to and then press write.
2. linux option
download image writer from here: https://launchpad.net/usb-imagewriter/+download
and once installed, use imagewriter to flash the SD with the image downloaded from rasbian.org
Select the image to write and the location to write to and select write to device.
Step 3: Prepare Your HDD
to prepare your external storage that will hold all your music and videos, you will need to have it formatted in EXT4 (click here to learn about EXT4)
either NTFS or EXT4 will do if you cant format the HDD as its already got the files on it.
i have a desktop Hitachi HDD, you can leave it as NTFS if you want but for performance EXT4 is preferred.
you can format it using ubuntu or windows.
for Ubuntu open gparted or ubuntu disks
for windows use partition magic or alternative windows program but the installed partition manager will only format windows partitions
Step 4: Setup Pi and Connecting
plug in the SD card, Ethernet, and the external HDD then plug in the power.
because we are doing this without a monitor we require to find out the IP address of the Pi from your wireless router, or if you have an android phone you can use an ap called Fing, this app can search your wifi when connected for active computers and other devices connected to your wifi network, It will be called Pi or Raspbian pi or somewhere along these lines..
Once you have found your IP address you need to use SSH, you can do this from windows with a program called Putty or in linux in a terminal using the ssh command.
my IP address is 192.168.0.14 as i have forced the router to give the mac address of the Pi a predetermined IP address so i can connect over the internet also using Webmin.
so in putty or linux connect to the ip address the default user name is pi and the password is raspberry
in terminal run ssh firstname.lastname@example.org
in putty enter the IP address and connect then enter the username and password
username : pi
password ; raspberry
first thing you need to do after login is change the password but not only change the password create a non-admin/root user
first change the password of the user you have logged in as by typing:
then enter the new password then enter it again that will change the admin password
now create a new user:
follow the instructions to create a new user if you dont need to change any of the options just press enter through the options and defaults will be used
Step 5: Set Up the External Hard Drive
set up the external hard drive
first we need to set up the pi so that every time it starts it auto loads the external HDD if not then you would have to mount the HDD every time you start the Pi
first we need to make sure it connected so type in:
this will print out something like this :
chris@box-pi ~ $ sudo blkid
[sudo] password for chris:
/dev/mmcblk0p1: SEC_TYPE="msdos" LABEL="boot" UUID="5D2D-B09A" TYPE="vfat" this is the SD card
/dev/mmcblk0p2: UUID="41cd5baa-7a62-4706-b8e8-02c4#####8d9" TYPE="ext4" this is the root of the SD card
/dev/sda1: LABEL="external drive" UUID="0538a430-22d5-43a9-8c8e-7bfa1####b9c" TYPE="ext4" this is the external drive
highlight the uuid and copy it as we will need this
next type in
sudo mkdir /HDD
sudo nano /etc/fstab
will load this :
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 2
/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
might look like this but at the end of this file you need to add
UUID=0538a430-22d5-43a9-8c8e-7bfa1####b9c /HDD ext4 defaults 0 0
where it says ext4 you need to change that to ntfs and /HDD is the folder we made earlier
ctrl + W this will save the file
ctrl + X this will exit the file
Step 6: Install the Programs
first to install is the dependencies for the programs todo this follow these commands
sudo apt-get update && sudo apt-get upgrade -y
this checks for updates and installs them copy and paste this if need be
sudo apt-get install mysql-server libexpat1-dev zlib1g libmagickcore5 libmozjs185-1.0 curl ffmpeg -y
this should run with no errors and install everything mediatomb requires
then run this for samba
sudo apt-get install samba -y
this will install samba
to config samba we need to type this first to backup the stock config file just in case you break it
sudo cp /etc/samba/smb.conf smb.conf.bk
then to edit the config
sudo nano /etc/samba/smb.conf
then scroll all the way to the end of the file, it has to be the very end
this is my config for mine but you can make it read only if you want by changing writeable to no also add your username
writeable = yes
path = /HDD
force directory mode = 775
force group = users
force create mode = 775
force user = enter your username here
create mode = 775
public = yes
directory mode = 775
sudo service smbd restart
run this to install mediatomb
sudo apt-get install mediatomb -y
install torrent program
installing qbittorrent but if you look on the site its a program that needs a display but if you look harder there is a program called qbittorrent-nox. this program runs a website on your Pi so no need for a display.
to install run
sudo apt-get install qbittorrent-nox -y
to run it on startup (not recommended unless using timers)
visit this site https://github.com/qbittorrent/qBittorrent/wiki/Running-qBittorrent-without-X-server#how-to-run-qbittorrent-nox-on-startup
Step 7: Testing and Using
ok now that we have install these then you need to test and correct any problems
if done ok there should be no errors
first testing samba is easy
load your windows computer and go to file explorer and type in //192.168.0.14/ and you should have a folder in there called HDD and when opened should show all your files on your external hdd
as long as you dont reboot then you dont need to run it again but if you do then just type
to login to qbittorrent you need to goto http://192.168.0.14:8080
the username is admin
and password is adminadmin
once logged in you need to click on the spanner at the top left then go to downloads and change the location to /HDD including the first ' / '.
next go to webui in the setting still and scroll all the way down and change the password.
after doing this it may ask you to log back in again then test it by finding and downloading a torrent like the raspbian torrent here click the add link to torrent (picture of the link 2nd icon) then paste the link into there and it should download to the HDD folder
if this did not work you would need to configure your router to allow the ports listed in the setting on qbittorrent-nox to access the internet using port forwarding. settings are different depending on your router.
mediatomb should of been started automatically to check this go on to the internet like qbittorrent but to this instead go to this http://192.168.0.14:49152/ if it says "MediaTomb UI is disabled. Check your configuration." you need to edit the config file
go to terminal and type
sudo nano /etc/mediatomb/config.xml
and on the firts few lines you will see a line like this
<ui enabled="no" show-tooltips="yes">
change the enabled="no" to "yes"
press ctrl + o to save
and ctrl + w to exit
sudo service mediatomb restart
this should now work at that web address
select filesystem on the left select the /HDD folder then press furthest top right button on the page the + with an S around it this will add the dir to mediatomb and will auto scan the fold for new stuff added then press Inotify and recursive option then the set button that appears.
then go back to database and music should be there so now on your upnp player like bubbleUPnP for android and goto devices and it should be there listed as mediatomb.
plenty of people have made this easier than my instructable so here is a youtube vid of how to configure XBMC for samba share
any questions just ask