Volumio : Home Streaming solution using Raspberry Pi 2 & iQaudio Pi DAC+

I wanted to have multi-room streamed audio setup at home but didn't want to pay for a pre-built system such as Sonos. I'd already purchased a Raspberry Pi2, but then on TheMixingBowl.org forum where I post one user, Paranoid Jack, posted a very enticing HowTo for using a Raspberry Pi2 with a dedicated Digital Audio Converter to produce a cheap, home-brew streaming solution. Since TheMixingBowl.org forums are for registered users I figured I'd write up my version of instructions which are heavily based on Paranoid Jacks with tweaks for Volumio rather than Rune Audio for others should they wish to do the same.

Preliminary

You will be installing GNU/Linux on the Raspberry Pi2 since Volumio is based on the Debian GNU/Linux distribution. I use Gentoo GNU/Linux on all of my computers and am very comfortable using the Command Line Interface to execute commands. I have where possible attempted to make all steps as clear and simple as possible to aid those unfamiliar with using GNU/Linux to work through these steps.

Hardware

You will need the following hardware

Conventions

The Raspberry Pi2 and Volumio run GNU/Linux so even if you use M$-Windows or OSX as the operating system on your own computer you will need to learn a little of how to use the Bash shell at the Command Line Interface (CLI) on GNU/Linux systems, hopefully what follows is useful.

''root'' user''

Throughout this document many of the commands require you to be the root 'superuser' on the GNU/Linux system (which definitely includes Volumio on the Raspberry Pi!). I have tried to state this where relevant, and also the commands that you have to type in code sections will have the commonly used # symbol to denote that they are being performed by the root user, commands executed from normal user accounts are denoted by $ at the start in code sections. A command you have to execute as root will look like…

# ls -lha

…whilst a command you execute as a normal user will look like…

$ ls -lha

If you are ever told that a command can not be found check whether what you are doing requires you to be root first.

Within code sections there are some comments, these always start with a ## (double hash) and are highlighted in italic grey…

## Text that looks like this in code sections are comments and should not be typed

Editing Files

On the vast majority of GNU/Linux systems you can use nano [path/to/file] at the Command Line Interface (CLI) to edit files. Generally once done editing you can save the file with Ctrl-o and then exit back to the command line with Ctrl-x.

Volumio Defaults

Normal User

The default, 'normal' user account on Volumio distributions has the username volumio and password volumio. This account is limited in the commands it can execute. This is a deliberate design and restricts the 'normal' user account from messing up the system, you have to switch to root user to do that.

root User

On UNIX-like systems (i.e. GNU/Linux such as Volumio) you have a regular user account and an all-powerful root user account that can do absolutely anything, including installing malicious software and deleting the whole operating system from disk. Be very careful when executing commands as root if you do something wrong you can potentially completely screw up your system.

Construction

Once you have your components follow the instructions in the iQaudio Documentation to put everything together.

Volumio

I opted for Volumio as my operating system. You should download the latest Raspberry Pi2 image from here.

Flash Volumio to microSD

Once downloaded you need to flash the image (i.e. the operating system) to a microSD this can be done under GNU/Linux using the following command assuming that your microSD is detected as /dev/sde when you plug it into your computer. You can check what this is by using ls /dev/sd* when the disk is not plugged in and then again when it is, the /dev/sd[#] that appears when connected is your microSD card.

## Uncompress the zip file you have downloaded
$ unzip Volumio1.55PI.img.zip
## Flash the image to /dev/sde (NB - Change this to whatever your device your microSD is detected as)
## [img_file_path] will be the same directory that you extracted the zip in
## You may need to be the 'root' user to do this, on some system this can be achieved by 
## preceeding the command with 'sudo '
$ dd bs=1M if=[img_file_path] of=/dev/sde

For instructions on flashing the microSD with the Volumio image on other operating systems please refer to the documentation at here (scroll down to find it).

Format the Remaining Space on microSD (Optional)

Depending on what size microSD card you have used there may be a considerable amount of space that has not been formatted and will therefore not be available when booting. If you want you can format this remaining space to make it available to the operating system for daily use (I opted to make mine the /home/ partition).

Make sure your microSD card is not mounted. As root used cfdisk /dev/sde to edit the partition table of your device. Once its started scroll down to the free partition and Create New go with the default size (which is all of the remaining space) and ensure the Type is 83 Linux.

Boot the Raspberry Pi 2

Plug the microSD into your Raspberry Pi2, plug in the ethernet cable (we switch to WiFi later) and finally plug-in the power supply. Lights should come on and start flashing. Go to the administration page for your router and look at the DHCP page that lists the attached devices and look for the IP address of a device called volumio, if your router supports reserving IP addresses for devices save the current assigned one for the volumio device. To make life easier add the IP address to /etc/hosts, so if the device volumio has been assigned IP address 192.168.0.48 add the following to /etc/hosts (you will need to be root to do this)…

192.168.0.48 volumio

…and after exiting from the root user on your computer create an alias for your normal user account by adding the following to ~/.bashrc

alias volumio='ssh volumio@volumio'

…save the file then at the command prompt $ source ~/.bashrc to ensure the alias works at the current command prompt (it gets sourced at each subsequent command prompt so you won't ever need to do this again, its purely because you want to now use the alias, but the current shell doesn't know it exists).

SSH to Volumio/Raspberry Pi2

Now connect to your Volumio/Raspberry Pi2 using the password volumio, the first time you'll be asked if you trust the RSA certificate, say yes…

$ volumio

Change Default Passwords

For security the first thing you should do is change the default password using passwd so that anyone who might gain access to your device can not login using the default passwords which are readily available on the internet.

$ passwd
Changing password for volumio.
(current) UNIX password: 
Enter new UNIX password: 
Retype new UNIX password: 

The second thing you should do is change your root password by su to the root user (password volumio) and then using passwd, again for the security of your system.

$ su
# passwd
Enter new UNIX password: 
Retype new UNIX password: 

Finally, I prefer to not allow users much access to what only the root account should be able to do so, this also means you have to conciously su into being root and will hopefully be thinking a little more about the commands you are using. I revoke sudo permissions for the accounts that have it enabled (i.e. pi and volumio) by commenting out their entries in the file /etc/sudoers.

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d
#pi ALL=(ALL) NOPASSWD: ALL
#volumio ALL=(ALL) NOPASSWD: ALL

It is advisable to disable root from being able to ssh into your machine, so su to root and edit the file /etc/ssh/sshd_config and make sure the line that contains the option (line 27 in my distribution) has…

PermitRootLogin no

ToDo

  • Check pi account and why its in sudo group. Will revoking sudo access for this account cause problems?
  • ToDo Check whether root is allowed to ssh in, if so disable since its a security risk!

Utilise free space on the microSD card

You'll likely have some free space on your microSD which might come in useful. To enable it follow these instructions from the Volumio FAQ : Increase the partition size

$ su
# fdisk /dev/mmcblk0
Command (m for help): d
Partition number (1-4): 3

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (1-4, default 2): 3
First sector (155648-30703615, default 155648): 
Using default value 155648
Last sector, +sectors or +size{K,M,G} (155648-30703615, default 30703615): 
Using default value 30703615

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
# reboot

Your device will reboot and you will now have a larger partition, the final step is to resize the file system to use all of this partition.

$ su
# resize2fs /dev/root

You can check that all of your micorSD card space is now being used with df -h

Install useful programs

Not all programs that I use are installed by default so next install them.

ProgramFunction
keychainAllows password-less login using pre-shared keys
lshwLists hardware
locateBuilds database of files on the system for easy searching
$ su
# apt-get update
# apt-get install lshw locate keychain 

Enable WiFi support

The USB WiFi that you have may be different from mine to find out what you have using lshw.

## List the hardware
# lshw
volumio                   
    description: Computer
    product: Raspberry Pi 2 Model B
    width: 32 bits
  *-core
       description: Motherboard
       physical id: 0
       capabilities: brcm_bcm2709
     *-cpu:0
          description: CPU
          product: cpu
          physical id: 0
          bus info: cpu@0
          size: 900MHz
          capacity: 900MHz
          capabilities: cpufreq
     *-cpu:1 DISABLED
          description: CPU
          product: cpu
          physical id: 1
          bus info: cpu@1
          size: 900MHz
          capacity: 900MHz
          capabilities: cpufreq
     *-cpu:2 DISABLED
          description: CPU
          product: cpu
          physical id: 2
          bus info: cpu@2
          size: 900MHz
          capacity: 900MHz
          capabilities: cpufreq
     *-cpu:3 DISABLED
          description: CPU
          product: cpu
          physical id: 3
          bus info: cpu@3
          size: 900MHz
          capacity: 900MHz
          capabilities: cpufreq
     *-memory
          description: System memory
          physical id: 4
          size: 974MiB
  *-network:0 DISABLED
       description: Wireless interface
       physical id: 1
       bus info: usb@1:1.3
       logical name: wlan0
       serial: 64:70:02:24:19:a6
       capabilities: ethernet physical wireless
       configuration: broadcast=yes driver=rtl8192cu multicast=yes wireless=unassociated
  *-network:1
       description: Ethernet interface
       physical id: 2
       logical name: eth0
       serial: b8:27:eb:20:ee:8f
       size: 100Mbit/s
       capacity: 100Mbit/s
       capabilities: ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=smsc95xx driverversion=22-Aug-2005 duplex=full firmware=smsc95xx USB 2.0 Ethernet ip=192.168.0.21 link=yes multicast=yes port=MII speed=100Mbit/s

As you can see I have two network devices listed network:0 DISABLED, the wireless interface and network:1 the wired interface. I want to enable the first device so that I can use the device wirelessly. The next steps may differ if you do not have the exact same USB WiFi dongle as I do, it may be that your wireless device is automatically detected and the relevant modules loaded so you won't have to do anything.

In my case the TP-Link USB WiFi dongle has been detected and the driver is loaded (look at the last line under that section). The problem is it doesn't know what WiFi network to connect to, nor any passwords. To find out what the details are of your WiFi network either look at your routers configuration page or use iwlist scan which returns detailed information on the WiFi networks it finds, have a look for yours. You then need to configure this manually so edit the file /etc/network/interfaces so that it looks like the following (obviously substituting the SSID for your own, this is the name of your wireless network). By placing the entry for wlan0 before eth0 it means this interface will be loaded first and you won't have to wait around for loading of the eth0 interface to fail when you aren't using an ethernet cable.

auto lo
iface lo inet loopback

auto wlan0
iface wlan0 inet dhcp
wpa-ssid [YOUR SSID]
wpa-psk [YOUR NETWORK PASSWORD]

auto eth0
iface eth0 inet dhcp

Enable Password-less login with Keychain

As you might be sshing into your Raspberry Pi2 fairly regularly it can be a bit of a pain to have to enter your password each time. Since you installed Keychain in the above previous steps (Install Useful Programs) you can utilise this to provide password-less login from your main GNU/Linux computer to the Raspberry Pi2. The following instructions are based on Gentoo Wiki : Keychain

Generate RSA Keys

On your main computer as regular user generate RSA keys, use a long, yet easy to remember password…

$ ssh-keygen

Copy Keys & Add them to Authorised

You now copy your public RSA key (~/.ssh/id_rsa.pub) to the Raspberry Pi2 and add them to the list of authorised keys..

$ ssh volumio@volumio "mkdir ~/.ssh"
$ scp ~/.ssh/id_rsa.pub volumio@volumio:~/.ssh/my_rsa.pub
$ ssh volumio@volumio "cat ~/.ssh/my_rsa.pub >> ~/.ssh/authorized_keys"

Save your Key with ssh-agent

Now load your key into ssh-agent on your desktop/server.

$ ssh-add ~/.ssh/id_rsa
Enter passphrase for ~/.ssh/id_rsa: 
$

Load ssh-agent using Keychain

The last step to making this convenient is to use Keychain to reuse ssh-agent between sessions. This means that when you log into your desktop/server you will be asked for your RSA key once straight after you have logged in. This key is then loaded and managed by ssh-agent and you can simply ssh to the Raspberry Pi2 using pi (since we setup an alias for this above) and you won't be asked for a password. Add the following to your ~/.bash_profile

keychain ~/.ssh/id_rsa
. ~/.keychain/$HOSTNAME-sh
. ~/.keychain/$HOSTNAME-sh-gpg

Volumio WebUI Configuration

Once up and running point your browser at the IP address of your Raspberry Pi and you should have a page loading that allows you to control music playback, browse libraries and change settings.

System

From the settings using menu on the top right to select 'System'. The important thing to note is that you need to select IQaudIO DAC Plus for the I2S Driver. Since I don't use Apples AirPlay, nor Spotify I turned these off, but I do have UPnP/DLNA services so I turned these on. If you wish to take advantage of the tags your music files have then you must enable Library View under the Miscellaneous section. Once you have chosen your settings and hit Apply under each section click Apply Settings at the bottom of the page, it should refresh and there should now be an additional section for Compatability Fixes.

SettingsOptionStatus
Services ManagementAirPlayOff
Services ManagementUPnP ControlOn
Services ManagementUPnP/DLNA IndexingOn
Services ManagementDLNAOff
Streaming ServicesSpotify ServiceOff
I2S DriverI2S DACIQaudIO DAC Plus
MiscellaneousStartup SoundOn
MiscellaneousLibrary ViewOn
Sound Quality TweaksKernel ProfileDefault

Playback

You can configure some MPD settings from here.

SettingsOptionStatus
Audio OutputAudio OutputALSA
Volume Control MixerMixer TypeHardware
General Music Daemon OptionsGapless mp3 playbackYes
General Music Daemon OptionsDSD over PCMNo
General Music Daemon OptionsVolume normalisationYes
General Music Daemon OptionsAudio Buffer Size2048
General Music Daemon OptionsBuffer Before Play20%
General Music Daemon OptionsAuto UpdateYes
ResamplingAudio Output Format (resampling)Dsiabled
ResamplingSample Rate ConverterFastest Sinc Interpolater

Adding your Music

There are a couple of different methods of adding music to the service depending on the type of music and how you want to make it available to Volumio.

Your Own Music

You can add your own music either by plugging in an external USB Hard Disc Drive (HDD) or you can make a Network File Share (NFS) available from another computer and mount it under Volumio and all music under that directory will then be available.

USB Drive

I didn't want to do this as I don't want to have to have another hard disk attached to this particular Pi to play my music back since I have all of my music on my main computer, and a Raspberry Pi B (Original) setup with external HDDs for backing up. If you do, plug it in, go to the Volumio WebUI and under Menu > Library select Update Library. This will start MPD in the background scanning for new mp3 files on your system. It might take a while if you've lots of music, so be patient. Once complete you should be able to Browse your music.

Adding NFS Shares

Instead I have a Network File Server (NFS) running on my main computer which makes the directories with my music in available for other devices such as Raspberry Pi2/Volumio to mount and read the music from and then make available through its front end.

Setting up NFS Server

You will need to configure your GNU/Linux server to share certain directories using NFS. The following are instructions for NFSv4 on Gentoo. If you are using a different GNU/Linux distribution you will have to do things slightly different, consult your distributions documentation. If you use M$-Windows then you will have to look into setting up file sharing but I've no idea how to do that.

# emerge -av nfs-utils

Make sure your kernel supports NFSv4, if you have to recompile your kernel, you will obviously have to reboot into it.

# cd /usr/src/linux
# make menuconfig
File systems  --->
   Network File Systems  --->
      <*>   NFS client support
      [*]     NFS client support for NFS version 4
      <*>   NFS server support
      [*]     NFS server support for NFS version 4 (EXPERIMENTAL)

Create an /export directory and mount point for your shares, then bind the directory you wish to share (in my case /mnt/music) to this location.

# mkdir -p /export/music
# mount --bind /mnt/music /export/music

To ensure that you can still mount the source location when you reboot you must make an additional entry to /etc/fstab

/mnt/music      /export/music    none    bind  0 0

Configure your NFS exports using the file /etc/exports, you need two entries (see the NFSv4 on Gentoo Wiki entry for details of the options available, using the below is safe). The IP address should be the subnet for your network, so if all of your devices get IP address' starting with 192.168.0. then a unique number your subnet is 192.168.0.0.

export                 192.168.0.0/24(ro,fsid=0,no_subtree_check)
/export/music          192.168.0.0/24(ro,sync,no_subtree_check)

Mounting your NFS to Volumio

Go to the WebUI of Volumio and navigate to Menu > Library and select Add New Mount. Enter the details of your NFS shares, note that at present I have not described how to set a Username and Password, so you can leave these blank.

OptionValue
Source name[your server name]
Fileshare ProtocolNFS
IP Address[your server IP address]
Remote Directory/exports/music/
Username
Password

Once you Save your options Volumio should indicate that its updating (on the bottom left the Library panel should have Update showing).

Keeping your Library Up-to-date

When you add music to your library on your server MPD on Volumio won't know its there. You can Update Library for the whole directory or specific directories, but it would be far more convenient if it automatically detected new files and updated them. Thankfully this feature is available by setting Auto Update to Yes under the Playback option. However the depth of nested folders that are to be searched is not set. You can do this manually.

SSH to Volumio, su to root and open /etc/mpd.conf for editing (using nano /etc/mpd.conf). Find the line that has auto_update “yes” and afterwards add the line auto_update_depth “20” which means it will look up to 20 nested directories for changes.

auto_update         "yes"
auto_update_depth   "20"

SoundCloud

I use Soundcloud to listen to all sorts of music and regularly create and add music to playlists within my account. Wouldn't it be neat if I can access these from Volumio? Fortuantely MPD already has SoundCloud playlists enables (see also posts on the developers mailing list).

Your SoundCloud API Key

You need to first create an API key so go to Soundcloud log-in and from the menu (icon on top left of page with three white dots) select Developer API. This opens a new tab, from the right-hand menu select Register Your App and enter the name mpd (since its technically MPD that will be connecting to your account). You will need to copy the Client ID that this page shows. Then SSH to Volumio, su to root and edit /etc/mpd.conf and add the following lines…

playlist_plugin {
        name "soundcloud"
        enabled "true"
        apikey "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}

Restart mpd (or reboot).

BBC Radio

Its possible to add BBC Radio streams to the list of radio stations that are listed. This is done using minimserver and huge thanks to paranoidjack on TMB for how to do this.

NB This used to be a lot easier as this post on the Volumio Forums shows.

Multi-room Audio

One of my aims of having this setup was to be able to have the music streaming in multiple locations so I could listen to music around the house. WHilst MPD can stream to http making it possible to set up a streaming server to have them synchronised it is easier to stream output to pulseaudio audio server. As usual I have not worked this out myself but relied heavily on someone else's work.

Installing PulseAudio

By deafuly Volumio (and the Raspbian distribution its based on) doesn't come with PulseAudio installed so you must first install it yourself. This is pretty straight-forward, ssh in, su to root and use apt-get to install…

# apt-get install pulseaudio

Configure MPD for Streaming

You need to edit the file /etc/mpd.conf on your Volumio install in order to enable http streaming. You will have two entries

audio_output {

                 type           "alsa"
                 name           "Output"
                 device         "hw:0,0"
                 mixer_control  "PCM"
                 mixer_device   "hw:0"
                 mixer_index    "0"
                 dop    "no"

}
audio_output {
                type            "httpd"
                name            "Volumio Stream"
                encoder         "vorbis"                # optional, vorbis or lame
                port            "8080"
                bind_to_address "192.168.0.21"          # optional, IPv4 or IPv6
                quality         "10.0"                  # do not define if bitrate is defined
                ## bitrate              "192"                   # do not define if quality is defined
                format          "44100:16:1"
                tags            "yes"
                max_clients     "5"                     # optional 0=no limit
                enabled         "yes"
                always_on       "yes"
}

Configure Second Volumio device

ToDo Awaiting purchase of a second system to set this up.

MultiMedia Centre

My wife liked some of the streaming features available under Kodi so rather than having a second Pi sat under the TV next to the Volumio one I opted to install Kodi under Volumio.

Install Kodi

Volumio is based on Raspbian but only includes the main tree of packages. Kodi isn't in the main tree though since it retains its old name XBMC (XBox Media Centre as it was first developed to run on XBox's). Kodi/XBMC is in the main Raspbian repositories so you could install it using…

apt-get update
apt-get install xbmc

I opted for an alternative as packages are provided here and are a bit more up-to-date and easier to configure. As per the instructions add the repository, get the signed key, update apt-get and then install

echo 'deb http://archive.mene.za.net/raspbian wheezy contrib' >> /etc/apt/source.list.d/mene.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-key 5243CDED
apt-get update
apt-get install kodi

Configure Kodi

You need to increase the amount of RAM available for the GPU and make sure the user Kodi will run as is a member of various groups. To ensure the GPU has sufficient RAM (128Mb should be plenty) edit /boot/config.txt to have the following line…

gpu_mem=128

Check that Kodi is configured to run as user kodi in the configuration file /etc/default/kodi and that this user is a member of groups audio, video, input, dialout. plugdev and tty

grep -B1 'USER' /etc/default/kodi 
# The user to run Kodi as
USER=kodi
grep 'kodi' /etc/group
tty:x:5:kodi
dialout:x:20:kodi
audio:x:29:pi,kodi
video:x:44:pi,kodi
plugdev:x:46:pi,kodi
input:x:114:kodi

To be able to use a keyboard and mouse you need to create a custom udev rule (which is slightly different to the one described). Add the following to /etc/udev/rules.d/99-input.rules

SUBSYSTEM=="input", GROUP="input", MODE="0660"
KERNEL=="mouse*|mice|event*", MODE="0777"

Kodi will run without the need for an X environment, this is a good thing since it means less overhead eating into performance. You need a GUI to use Kodi and it will run its own, but you need to configure it to do so, and ensure that it starts on boot. You can set Kodi to start on boot by modifying /etc/default/kodi

# Set this to 1 to enable startup
ENABLED=1

Links

Hardware

Software

Android Applications

Documentation

Kodi

Forum Posts

volumio/volumio.txt · Last modified: 2015/09/23 10:28 by neil
CC Attribution-Noncommercial 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0