ARCH LINUX WITH LOGITECH MEDIA SERVER ON A RASPBERRY PI COMPUTER

DSC_0119a

This could be the most economical, audiophile quality music server you’ll ever hear.

What you need:

Raspberry Pi - $35
SD Card - 8gb recommended - $6
Charger with 1.5 amp output or higher - $10 maybe
HiFiMeDIY Digital to Analog Converter - $45
Wifi Dongle Edimax EW-7811Un (optional) $11

Ok. Here we go. First of all you have to know there are EASIER easier ways to do this. This isn’t about easy. This is about having a lean, mean operating system that is lightweight, fast, highly configurable and easy to update.

First we want to get and install Arch Linux for Raspberry Pi. The official Pi website has an Arch Download but it seemed like it was a couple months behind the official Arch ARM release, so I grabbed that. Get it here. Make sure to click the tab that says “Installation” on the page.

It’s really simple. You download the image (img) file and flash it to an SD card. No need to format the SD card or anything. Just insert. Follow the instruction on that page. I have a Mac and here’s how I did it.

Download the file and go to your Downloads folderScreen Shot 2014-03-14 at 8.59.34 AM

Double click the file to extract the zip.

Screen Shot 2014-03-14 at 8.58.56 AM

Now open a terminal and type

diskutil list

Determine which disk is your SD card. Just look for the one that is 8 gb in size or whatever size card you have.

Mine is /dev/disk3

now type

sudo dd if=

Now drag your file into the terminal. Keeps you from having to type the whole path

Screen Shot 2014-03-14 at 9.04.34 AM

Now add the following to the end of that:

of=/dev/rdisk3 bs=4m

Screen Shot 2014-03-14 at 9.03.13 AM

Hit enter, type in your password when prompted and wait 10 minutes or so. Nothing will happen in the terminal screen but it is writing to the SD card.

When it is done, just eject the card and you are ready to boot your Raspberry Pi to Arch Linux. It’s that simple.

But before we do that we’re going to expand the partition on your SD card to use the whole device. Right now you only have a 2gb partition. Not enough to install a whole bunch of stuff. Lets add a swap partition too to help with memory management. This will make things go smoother, especially if you have to compile your media server later in the tutorial.

Hopefully you have a computer that has some partition software. If you do not you can download a bootable CD ISO image of something called SystemRescueCD. You can boot your computer using this CD you made and it has a program called GNU Parted or what we call “gparted”. I have gparted on my linux laptop so we’ll use that. See all that empty space?

BE AWARE THAT YOUR SD CARD MAY NOT BE /dev/sdb AS IN MY EXAMPLE HERE. BE CAREFUL NOT TO ERASE THE HARDDRIVE ON YOUR COMPUTER. NOTICE MY DRIVE SAYS 7.46 GiB. I KNOW THIS IS MY SD CARD WITH ARCH ON IT.

-dev-sdb - GParted_008

Unmount your /dev/sdb5 partition

-dev-sdb - GParted_009

Resize your extended partition. Leave 1000 (1 GB) free to make a swap partition.

-dev-sdb - GParted_010

Right click your 1000 MiB partition and select “New” (My screenshot got chopped a bit but you can still see it)

-dev-sdb - GParted_012


Make a primary partition and select “linux-swap” as the file system.

Selection_015


Now lets stretch /dev/sdb5 to use all that previously empty space. Right click on it and select “Resize/Move”

-dev-sdb - GParted_016

Strech it out by grabbing the arrows again and hit “Resize/Move”

Resize-Move -dev-sdb5_017

Now go back to the main screen and hit “Apply” Probably take a minute or so and then you are done.

Now lets activate the swap partition.

Now hook your Pi up to ethernet, a monitor, keyboard and mouse. I use a wireless keyboard and mouse with a USB dongle.

Boot linux and get to a prompt.

user name = root
password = root

Lets do the swap partition first

type

blkid

Notice my swap partition is /dev/mmcblk0p3. Yours COULD be different.

Screen Shot 2014-03-15 at 8.58.27 AM

Now type

swapon /dev/mmcblk0p3

Now to make it work at every boot lets modify our /etc/fstab file.

add this

/dev/mmcblk0p3 none swap defaults 0 0

Screen Shot 2014-03-15 at 9.01.56 AM

CNTL key + X

Y to save

Enter to write the file to /etc/fstab

Time to move on to other things now.


Soon as you are logged in as root change your password. Security and all..........

passwd root

follow the prompts to type your new password twice.

now type

ifconfig

retrieve your IP address under eth0

Mine was 10.0.1.109

now type

systemctl start dhcpcd

systemctl enable dhcpcd.service

This starts ethernet and the second command enables it at boot.

Now ping something to make sure you are up. Google servers are always good and outside your network.

ping 8.8.8.8

If it says “Network is Unreachable” you need further help

If it returns ping data you are golden. Hit Ctrl + C to stop that and then type.

pacman -s openssh

If you have issues with pacman you may have to enable a mirror or establish a key. Should just work though. If it doesn’t,........email me.

OpenSSH is a program to operate a secure shell so you can control the pi from another computer. Say Y to install it. So if you are so inclined you can disconnect the monitor, keyboard and mouse or just keep going.

If you do go the openssh route go to another computer with a terminal on the same network and type

ssh 10.0.1.109 -l root (or whatever your IP address is from the ifconfig command above)

You can now log in as root and do all of the rest of this from the comfort of your laptop.

Now from your prompt lets do some housekeeping.

Okay time to set the time.

Type

timedatectl status

timedatectl list-timezones

timedatectl set-timezone Asia/Tokyo

Asia/Tokyo is me. Set yours to where you are.

Now set the time.

if you don’t have ntpd type

pacman -S ntp

now type

ntpd -qg

That should set your system time. Now you have to make sure it happens at boot. NTP that is.

timedatectl set-ntp 1

Time is set. Add a user.

Okay I’m adding the user John.

Type this:

useradd -m -g users -G wheel -s /bin/bash john

Now type

passwd john

And set your password.

Now if you want to log into a graphical interface do this. If you are content to operate your computer via ssh you DO NOT NEED a graphical interface and can ignore this. Most people will want this though I think. Note that I have chosen LXDE as my graphical environment. You can change that to XFCE or something if you want but we’re following my directions and I like LXDE.

pacman -Sy
pacman -Su
pacman -S lxde xf86-video-fbturbo xorg-xinit

so if you are hooked to a monitor you can type

xinit /usr/sbin/lxsession

to start your graphical environment.

Now comes the fun part. Time to add Logitech Media Server. This is going to take a while. Recommend doing this before going to bed so you can let it compile overnight. On a non over clocked pi it took me about 6 hours.

HOWEVER YOU CAN TRY TO USE MY COMPILED PACKAGE FIRST ........Go here and download my package file

Try installing it by typing.

pacman -U logitechmediaserver_armv6h.pkg.tar.xz

Then

systemctl start logitechmediaserver

If it works YOU ARE GOLDEN. Now enable it to start at boot. Then skip to the line below the asterisks a little further down the page *****************************

systemctl enable logitechmediaserver.service

If it doesn’t work you need to build it and follow the directions below.

NOTE: All pacman commands must be done as root or su. All other commands should be done as your user unless otherwise required.

First I had to install wget to get the source code.

pacman -S wget

Then

wget https://aur.archlinux.org/packages/lo/logitechmediaserver/logitechmediaserver.tar.gz

tar -xf logitechmediaserver.tar.gz

cd logitechmediaserver

Then it got tricky the next command was supposed to be

makepkg

Didn’t work. Failed and said this:

john@arlarmpi logitechmediaserver]$ makepkg
==> ERROR: Cannot find the fakeroot binary required for building as non-root user.
==> ERROR: Cannot find the strip binary required for object file stripping.
[john@alarmpi logitechmediaserver]$



So I had to go to the Arch Wiki page on makepkg and it said to first install base-devel

pacman -S base-devel

then I ran

makepkg -Asc --asroot

again and it told me there were four dependencies needed

==> Making package: logitechmediaserver 7.7.3-2 (Tue Feb 25 16:39:39 JST 2014)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Missing dependencies:
-> nasm
-> yasm
-> rsync
-> subversion
==> ERROR: Could not resolve all dependencies.

So then I did:

pacman -S nasm yasm rsync subversion

then

makepkg -Asc --asroot

It took a LONG time to compile. About SIX hours. Once compiled then you need to install. Makes a file called logitechmediaserver-7.7.3-2-armv6h.pkg.tar.xz

pacman -U logitechmediaserver-7.7.3-2-armv6h.pkg.tar.xz

Now you’ll want to start it and enable it at boot (as root)

systemctl start logitechmediaserver

and / or

systemctl enable logitechmediaserver.service

************************************************************* PICK UP HERE IF MY PACKAGE INSTALL WORKED

Now open a browser and type

youripaddress:9000 (10.0.1.109:9000)

if you are hooked directly to a monitor keyboard and mouse you can type

localhost:9000

I did notice that it took a full minute or so for LMS to become available. If you can’t connect type

top

and look for slimserver.pl

That means it is running. Give it another minute if you see slimserver.

Screen Shot 2014-03-13 at 7.08.40 PM

I should note that you need an account at
www.mysqueezebox.com

When you start LMS it will look like this


screen-shot-2014-03-15-at-5.20.47-pm


Okay. The Server is working now. Time to get the player going.


cd
mkdir squeezelite
cd squeezelite

wget
https://squeezelite.googlecode.com/files/squeezelite-armv6hf

Now do this:


mv ./squeezelite-armv6hf /usr/bin/squeezelite

This moves the file and renames it. Easier to call, easier to type.

Now this to change the permissions:

chmod ug+x /usr/bin/squeezelite


If you did everything right it will list your output devices when you type this at a terminal (make sure you sill super user):

squeezelite -l

Screen Shot 2014-03-14 at 4.52.21 PM

Notice I have my HiFimeDIY DAC plugged in. That’s the output source I want to use. Now we have to specify that device, give the player a name, and tell it where to find your Logitech Media Server. Easy money.

squeezelite -0 front:CARD=DAC,DEV=0 -n ArchRaspPi -s 127.0.0.1

squeezelite is the command, dash o is our output source, dash n is the name I gave it, and dash s is the server. The server resides on the same computer so you can use the localhost IP address of 127.0.0.1. If you have a server on another computer input that number. If you have one server somewhere you can even leave the dash s off completely and that puts it in auto discovery mode. It’ll find it provided it is on the same network.

Now that’s cool. Lets go to our server and see if we have a player.

Screen Shot 2014-03-14 at 4.58.14 PM

There it is. Upper right hand corner shows our player RaspArchPi. You did it. However it may or may not play correctly you may need to add some dependencies. This is the “official” dependencies list however it is from Debian Wheezy. This is Arch

libasound2 libflac-dev libfaad2 libmad0

********These SHOULD do the trick. If they don’t let me know and I’ll investigate further.********

pacman -S alsa-lib

pacman -S libmad



Now the last thing you’ll want to do is to make it start at boot so you don’t have to type that long squeezelite command every time. There’s a lot of different ways to do this and if you Google enough you’ll find a nice script to start and stop squeezelite.

Way too complicated for me. As long as the computer is on I want the server running and I want it up on every boot. No need to finesse this too much. Brute force works here.

Open a text editor and type

#! /bin/sh
echo "Squeezelite....."
sleep 10
/usr/bin/squeezelite -o front:CARD=DAC,DEV=0 -n RaspArchPi -s 127.0.0.1 &

Save this file anywhere you want to. I saved mine in my home directory in a folder called “Scripts”. And I named it squeezelite_start.sh

Now go to top

top

and find the squeezelite process and as root kill it. Or just reboot.

Screen Shot 2014-03-14 at 5.07.30 PM

See the top entry? To kill squeezelite (as root) type

kill 503

which is the process number.

Now go to a terminal and type (remembering to use your path)

/home/john/Scripts/squeezelite_start.sh

The terminal should say

Squeezelite.....

As that was the echo command I gave it. Notice in the script I told it to sleep for 10 seconds too. For some reason it just would not stay running if immediately launched. So I gave it a delay.

Now lets set this to start at boot.

Type

VISUAL=nano crontab -e

Add the following line

@reboot /home/john/Scripts/squeezelite_start.sh

hit

CNTL key + X

Y (to save)

Hit Enter to write to crontab

reboot

YER DONE. TEST IT.

ADDENDUM

I had some issues with wifi that I finally resolved.

Basically to set up wifi you type

wifi-menu -o

it will scan your networks and then make a profile after you put your password in. I named my profile “wlan0”

So then you enable it by typing

netctl enable wlan0

and sometimes it would work at boot and sometimes it wouldn’t. I put the wifi dongle on a powered hub and it worked better but not completely

Then after an exhaustive search I figured out two network services running at once is bad for business. Early in the tutorial I enabled dhcpcd.

So I turned it off

systemctl disable dhcpcd.service

And then I rebooted and it was fine. Then I shut down and put the wifi dongle back in the Raspberry Pi along with the DAC and then rebooted. Worked perfect. Did it three more times just to make sure it persisted. It did. Working perfectly.

So now what I have is a free standing Raspberry Pi with an Edimax Wifi dongle in the upper port and the USB DAC in the lower port. I use a 2.1 amp generic iPhone 5 brick for a power source and use a Y cable 3.5mm to RCA to connect it to my stereo. I primarily use the services Spotify, Pandora, and TuneIn Radio to output to my stereo.