It's not difficult, but I've compiled my notes and written some English to link them together as someone may find them useful. I'm going to assume some basic Linux and home networking knowledge.
You will need
You'll also need some USB hard drives. The Pi (model B here) only has USB 2.0 ports so you can use older drives if you're not planning on plugging them in anywhere else. Also, the Pi runs on very low power so you really want powered drives or a powered USB hub to sit between them. If you want to back up your data, you're going to need two drives. If you don't, you can ignore all the stuff about rsync that comes up later.
Up and running
Sadly, the NOOBS install method requires the use of a screen so wont work for us.
install Raspbian onto the SD card
These are the instructions for prepping the card on a Windows machine.
- put the Pi in the case, plug in the ethernet cable and put in the SD card
- finally plug in the power cable and we're off
Connect and updateFind the IP address of your Pi, shell to it and log in (default username / password is pi / raspberry). You need to run:
Next update the operating system via:
sudo apt-get update sudo apt-get upgrade
Connect the drivesPlugging the drives in will auto-mount them, however if we are using one drive as a backup to the other we need to ensure they are always mounting the same way round on restart. To do this we will identify the drives via their UUID in /etc/fstab:
UUID=0AC4D607C4D5F543 /mount/location ntfs rw,defaults 0 0
blkid /dev/sda1 blkid /dev/sdb1
Install the softwareTime to install some useful software.
Samba shares specified parts of your filesystem on the network. It will allow you to mount the drive on another computer which will let you put files on your media server when it's ready. It is also the shared area that Sonos will be able to search for music files.
Minidlna shares an area of your filesystem via DLNA. This means a DLNA-ready device can locate the share and request any files in it. I use this for watching video on my iPad (my viewing program of choice being 8player).
# install samba sudo apt-get install samba samba-common-bin # install minidlna sudo apt-get install minidlna
sudo apt-get install tree locate chkconfig
Configure sambaTo configure samba you need to edit /etc/samba/smb.conf. You'll want something like this:
[global] netbios name = NETBIOS_NAME workgroup = WORKGROUP security = user encrypt passwords = yes smb passwd file = /etc/samba/smbpasswd [media] comment = My media path = /PATH/TO/SHARE writeable = yes create mask = 0770 force create mode = 0770 locking = yes
Then add the user to the samba password file:
sudo smbpasswd -L -a USERNAME
Configure minidlnaThe minidlna config file is found at /etc/minidlna.conf
Docs on configuring minidlna are available on the minidlna site. The important bits are:
media_dir=A,/home/user/Music # Music directory media_dir=P,/home/user/Pictures # Pictures directory media_dir=V,/home/user/Videos # Video directory friendly_name=Laptop # Name of the share db_dir=/var/cache/minidlna # Index files (make sure location is writeable) log_dir=/var/log # Log files (make sure location is writeable) inotify=yes # Index new files as they are added
When starting minidlna you may get an error message claiming to be exceeding the watch limit. To increase this limit, add to /etc/sysctl.d/90-inotify.conf
fs.inotify.max_user_watches = 100000
Note that there is a new version of minidlna on the way called ReadyMedia possibly rendering this completely obsolete.
Back up the drivesI wanted to keep a backup of my media on the second drive. I could have used RAID 1 but reading around suggested that the amount of read/write information going across the USB bus would cause a bottleneck and therefore problems serving the files. To get around this, I use rsync to copy everything across on a nightly basis.
Something like this in the crontab will sync the drives each night at 3am:
0 3 * * * rsync /mountpoint/maindrive /mountpoint/backupdrive >> ~/rsync_log.txt 2>&1