Pogoplug Logitech Media Server & Time Capsule

This is a draft and work in progress (maybe not?). Regular updates might appear here. But as is=t seems at the moment, I split the different purposes to different machines. I will see.

1 Why I do this – again

I was running an oldish laptop as

  • Logitech Media Server (short LMS) – a very nice high quality (flac) music streaming server (download here)
  • Time Capsule for backups from my Mac
  • Déjà Dup server for backups from Ubuntu
  • a way of having a Linux box available when I needed it

The booting was temperamental (probably because of the strange HP SimpleSave 1TB with the integrated “virtual CD” HP Launcher) and the battery was dead (so no suspend over night), so I decided to revive an old Pogoplug V2 I still had lying around.

pogoplug_v2_front.jpg

I must say, pink is not my favourite color, but well – I can live with it.

Now I had a few days without family, which I decided to put to use and set this thing up.

DISCLAIMER: I write this from memory – so I hope that I don’t forget anything. If I do, please let me know and I will add it here.

2 Install Debian Wheezy

This is relatively straight forward (in theory) but can have many pitfalls.

The easiest way is to follow Unlocking your Dockstar, GoFlex, or Pogoplug by Jeff. The not so nice aspect is that the LED is not working as it shoiuld. This is solved by bodhi and documented in this topic.

I used the one by Jeff, but will try out the one by bodhi as soon as I get my second Pogoplug (which is on it’s way) …

I am using a 16GB JetFlash Transcend to iunstall the Debian on. I probably should put it on a hdd or SD drive, but I can do this later.

I partitioned it as follow (see e.g. Linux Partition HOWTO on how to do sthis with fdisk):

  • 7GB as ext3 and named it rootfs
  • 2GB as swap (this should definitely be enough!!!)
  • rest empty, as I want to use it as a backup for rootfs

Then set the label of the first partition to rootfs

e2label /dev/sda1

Gives you the actual name of the partitin, likely empty, and

e2label /dev/sda1 rootfs

sets the label to rootfs.

Check if it was successful by again issuing

e2label /dev/sda1

which should show you as result

rootfs

There are numerous websites which give the howtos for installing Debian on a Pogoplug, but the original one is Unlocking your Dockstar, GoFlex, or Pogoplug. Further ones (based on the original one) are for example:

Qui’s blog The This is a blog blog

And the very useful Doozan forum is absolutely indispensable.

They are much more knowledgeable then I am in regards to this.

2.1 Some settings for the uBoot environment:

On the booted pogoplug, set the following values to enable netconsole output from the pogoplug (192.168.1.100 in my case) to my notebook (192.168.1.201 in my case). See doozan forum for details:

fw_setenv serverip 192.168.1.201
fw_setenv ipaddr 192.168.1.100
fw_setenv if_netconsole 'ping $serverip'
fw_setenv start_netconsole 'setenv ncip $serverip; setenv bootdelay 10; setenv stdin nc; setenv stdout nc; setenv stderr nc; version;'
fw_setenv preboot 'run if_netconsole start_netconsole'

Also, set the boot file system to ext3:

usb_rootfstype=ext3

Now we can try to reboot the pogoplug into debian.

If it does not boot there is the very useful Doozan forum which is absolutely indispensable.

2.2 Finalisation after reboot

OK – so let’s consider Debian installed and the Pogoplug is booted into the new Debin Wheezy installation. So we can go on and install the rest.

To finalise the installation, you should change the default root password for “root” (password = root) to whatever you like by typing

passwd

after logging into the Pogoplug Debian installation.

2.3 TODO Troubleshooting

2.3.1 netconsole on server to interact

nc -klu 6666

3 Update installation

For the update, we install aptitude as it h=ndles certain situations and dependencies easier.

  apt-get update
  apt-get install aptitude
  aptitude upgrade
  apt-get autoremove

4 Install screen and psmiosc (killall)

We install screen first so that all other installations can be run under screen. This is only recommended, and not necessary.

  apt-get install screen psmisc
  # apt-get install gpt

5 Setup swap partition

mkswap /dev/sdX
sudo swapon -U UUID

Add to /etc/fstab

  UUID=xxx    none    swap    sw      0   0

6 DONE Configure backup

Due to its simplicity and elegance, I decided to use rsnapshot (which is based on rsync and available via apt-get) in combination with cron

6.1 Install

  apt-get install rsnapshot cron

6.2 rsnapshot.conf – changes from original example:

no_create_root  1
retain          daily   7
retain          weekly  4
retain          monthly 12
one_fs          1
link_dest       1
backup  /               pogoplug/
backup  /media/Music    pogoplug/

I would suggest to make one backup after this, as it will take some time:

  rsnapshot daily

6.3 Crontab for rsnapshot

Edit your crontab with the command

  crontab -e

and add the followig lines:

# Each day at 23:30
30 23 * * *       /usr/local/bin/rsnapshot daily

## Each Monday (1) at 01:00
00 01 * * 1       /usr/local/bin/rsnapshot weekly

## Each First day of the month at 03:00
00 03 1 * *       /usr/local/bin/rsnapshot monthly

I recommend to do backups via rsnapshot after eaf=ch installation step so that you can easily roll back to a previous configuration.

7 Install additional packages

As I am an emacs person, I would like to use something similar on the Pogoplug. As emacs is much to big, there is zile which is (for the purpose here) a lightweight emacs clone:

  apt-get install ca-certificates zile screen mc zip unzip rsync apt-utils less lsof locales psmisc aptitude

8 Setup locale

  • un-comment the required locale(s) from /etc/locale.gen (e.g. “enUS.UTF-8 UTF-8″)
  • then runs
  locale-gen

9 Setup swap file (not needed if you are using a swap partition as recommended)

In my first attempt, I did not create any swap partition (no idea why – people do stupid things…). Please read on to see how to create a swap file.

When running the LMS, I realised that it soimetimes crashed and that this was caused by memory. so before continuin, we will give the poor little Pogoplug somw space to swap. I use a file (as I did not feel like partitioning the USB Flash drive), a partition might be the better solution. But anyway: for the information used see https://wiki.debian.org/Swap for details.

I created a 1GB swapfile at /var/swapfile:

dd if=/dev/zero of=/var/swapfile bs=1024 count=1048576
mkswap /var/swapfile

and enabled it

swapon /var/swapfile

Finally, I added it to /etc/fsab:

# Swap file created on DATE
/var/swapfile                               none                           swap   sw         0  0

Job accomplished – only X steps to go…

10 fstab

This makes sure that the external partitions used for Music, TimeMachine and backup from an ubuntu machine are mounted at permanent mount points.

Some remarks before:

  • I use UUID as they do not change. I could also use the labels, but the UUID are safer. One can get the UUID by using blkid
  • I also specify a mount option for the EFI partition, even though I do not want to mount it (the noauto option)

So first we have to identify the UUIDs of the partitions. For this we can use the command

blkid

The output will look a litle bit like this below, but obviously with different UUIDs:

/dev/sda1: UUID="00e8db83-e8ab-48bf-8076-8c9f9fde2063" SEC_TYPE="ext2" TYPE="ext3"
/dev/sda2: TYPE="swap"
/dev/sdb1: LABEL="Music" UUID="83728f43-e612-9dc5-f9d7-66a259999b32" TYPE="ext4"

Now we have to edit the fstab, and I do this using zile, but you can obviously use any editor which is installed (I actually don’t know which is…) or you installed as above (nano is probably the easiest).

  zile /etc/fstab

Initially, it will look as this:

/dev/sda1: UUID="00e8db83-e8ab-48bf-8076-8c9f9fde2063" SEC_TYPE="ext2" TYPE="ext3"
/dev/sda2: TYPE="swap"
/dev/sdb1: LABEL="Music" UUID="83728f43-e612-9dc5-f9d7-66a259999b32" TYPE="ext4"

Now we want to

Add the partition (“Music”” in the previous output) so that it will be mounted to the same folder:

For this we just add

## The Music HDD
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx   /media/Music                   ext4   defaults   0  0

## The 5TB HDD for backups
# UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx   /media/Backup                  ext4   defaults   0  0
# UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx   /media/TimeMachine             ext4   defaults   0  0
# UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx   /media/Diverse                 ext4   defaults   0  0

# UUID=xxxx-xxxx                              /media/EFI_5TB                 vfat   ro,noauto  0  0

The UUID and the fstype (ext4 in my case) can be seen in the output from blkid; lines starting with “#” are comments.

Important: the fstab file has to end with an empty line!

Then we create the mount points

mkdir -p /media/BackupConnie 
mkdir /media/TimeMachine_Vortexbox
mkdir /media/EFI_ON_HP
mkdir /media/Music

Finally we can test the fstab by issuing the command

mount -a

which mounts all devices specified in the fstab.

In addition, we can change the mounting of the root partition from /dev/root to using the LABEL. For this, we have to make sure that the file system has a label:

e2label /dev/sda1

Will show the label, and

e2label /dev/sda1 rootfs

will set the label to rootfs.

Now we can change the entry in the fsatb to:

LABEL="rootfs"       /               ext3    noatime,errors=remount-ro 0 1

11 Change Hostname

We will change the hostname to pogoplug. See Change Hostname for details. To do so, the name in the file /etc/hostname has to be changed to “pogoplug” and in the /etc/hosts file, references to “debian”, the original hostname, have to be changed to “pogoplug” and a line

127.0.0.1       pogoplug

needs to be added to guarantee that “pogoplug” is resolved to “localhost”.

12 Install different file system supports

  • HFS & HFS+ read/write See ubuntu wiki on how to make the hfsplus partitions writable.
apt-get install hfsutils hfsprogs hfsutils
  • NTFS read/write
apt-get install ntfs-3g

13 DONE Install and configure hdparm and cron

Used to spin down external HDD

  apt-get install hdparm cron

Added these to the /etc/hdparm.conf file:

### Seagate 254 GB
/dev/disk/by-label/Music{
}

/dev/disk/by-label/Music{
}

### LaCie 5 TB

/dev/disk/by-label/BackupConnie{
apm = 60 ## Advanced Power Management
}

/dev/disk/by-label/TimeMachine{
apm = 60 ## Advanced Power Management
}

/dev/disk/by-label/Diverse{
apm = 60 ## Advanced Power Management
}

# HP EFI
/dev/disk/by-uuid/67E3-17ED {
        acoustic_management = 128
        spindown_time = 48  # 4 min
spindown_time = 60  # 5 min
#spindown_time = 240 # 20 min
#spindown_time = 250 # 30 min
#spindown_time = 280 # 1 hour
spindown_time = 340 # 2 hours
}

# HP BackupConnie
/dev/disk/by-uuid/a7631876-0092-400a-8372-addde17750fc {
        acoustic_management = 128
        spindown_time = 48  # 4 min
#spindown_time = 60  # 5 min
#spindown_time = 240 # 20 min
#spindown_time = 250 # 30 min
#spindown_time = 280 # 1 hour
spindown_time = 340 # 2 hours
}

# HP TimeMachine
/dev/disk/by-uuid/a808b869-b15d-451a-ba86-12296a83b9a1 {
        acoustic_management = 128
        spindown_time = 48  # 4 min
#spindown_time = 60  # 5 min
#spindown_time = 240 # 20 min
#spindown_time = 250 # 30 min
#spindown_time = 280 # 1 hour
spindown_time = 340 # 2 hours
}

# HP TimeMachine
/dev/disk/by-uuid/83728f43-e612-9dc5-f9d7-66a259999b32 {
        acoustic_management = 128
        spindown_time = 48  # 4 min
#spindown_time = 60  # 5 min
#spindown_time = 240 # 20 min
#spindown_time = 250 # 30 min
#spindown_time = 280 # 1 hour
spindown_time = 340 # 2 hours
}

Does not work for some hdd. Found the following script at http://superuser.com/questions/651880/force-spin-down-of-external-hard-drive-on-linux-raspberry-pi:

!/bin/bash
# see http://superuser.com/questions/651880/force-spin-down-of-external-hard-drive-on-linux-raspberry-pi
#
# This script looks for recent disk access, and if nothing has changed, puts /dev/"drive" into spindown mode.
# This should be used only is the hdparm power management function is not working.
# Call this script with cron or manually as desired
#
#
#
# Change which drive this script looks at by changing the drive variable below:
drive="sda"
#
#
current=`date`
caller=$(ps ax | grep "^ *$PPID" | awk '{print $NF}')
filename="/tmp/diskaccess.txt"
if [ -f "$filename" ]; then
    stat_old=`cat "$filename" | tr -dc "[:digit:]"`
    stat_new=`cat /sys/block/"$drive"/stat | tr -dc "[:digit:]"`
    if [ "$stat_old" == "$stat_new" ]; then
        stat="0"
        echo "The disk hasn't been used; spinning down /dev/$drive"
        echo $stat_old
        hdparm -y /dev/$drive > /dev/null
    else
        stat="1"
        echo $stat_old
        echo $stat_new
        echo "The drive has been used..."
        echo $stat_new > $filename
    fi
else
    echo "/tmp/diskaccess.txt file does not exist; creating it now."
    echo $stat_new > $filename
fi
echo $stat " - " $drive " - " $current " - by: " $caller >> /tmp/diskaccesslog.txt

added cronjob:

crontab -e

The following cronjob

*/5 * * * * /root/scripts/disk_spindown.sh

to ri=un script every 5 minutes

14 Logitech Media Server

14.1 Install LMS

I remember

Download the LMS installation file and install it.

# wget THE_LINK_TO_THE_DEB
dpkg -install logitechmediaserver_x.y.z_all.deb

We will get some errors relating to missing dependencies, so we have to install the missing dependencies:

apt-get install --fix-broken

14.2 Additional Software

This is needed for conversion from different formats. mplayer is needed for “Play Windows Media” plugin

apt-get install faad sox lame mplayer

Also install the codecs for wma files

sudo mkdir -p /usr/lib/codecs && \
if [ "$(uname -m)" = "x86_64" ]; then
 wget http://www.mplayerhq.hu/MPlayer/releases/codecs/essential-amd64-20071007.tar.bz2
 tar xjvf essential-amd64-20071007.tar.bz2
 sudo cp -v essential-amd64-20071007/* /usr/lib/codecs
else
 wget http://www.mplayerhq.hu/MPlayer/releases/codecs/all-20110131.tar.bz2
 tar xjvf all-20110131.tar.bz2
 sudo cp -v all-20110131/* /usr/lib/codecs
fi

14.3 Configure LMS

This is according to personal preferences. So you can decide what you do here – I will not go into detail, these are mainly notes to myself.

As I want to use a specific plugin in the LMS, we have to install and configure sudo so that a normal user can shutdown the Pogoplug.

  apt-get install sudo
  • add sudoers rule to allow shutdown for user squeezeboxserver without asking for password
  visudo -f /etc/sudoers.d/shutdown

as follow:

# Cmnd alias specification
Cmnd_Alias      SHUTDOWN = /sbin/shutdown
Cmnd_Alias      HALT = /sbin/halt
Cmnd_Alias      POWEROFF = /sbin/poweroff
Cmnd_Alias      REBOOT = /sbin/reboot

# User privilege specification
# SHUTDOWN
squeezeboxserver ALL=SHUTDOWN
squeezeboxserver ALL=NOPASSWD: SHUTDOWN

# HALT
squeezeboxserver ALL=HALT
squeezeboxserver ALL=NOPASSWD: HALT

# POWEROFF
squeezeboxserver ALL=POWEROFF
squeezeboxserver ALL=NOPASSWD: POWEROFF

#REBOOT
squeezeboxserver ALL=REBOOT
squeezeboxserver ALL=NOPASSWD: REBOOT
  • add LMS Plugin sources:
http://srvrpowerctrl.googlecode.com/svn/repo.xml
http://www.pierrebeck.fr/SqueezeboxQobuz/repo.xml
  • install the pugins
    • Qobuz
    • Server Power Control
  • Configure Server Power Control so that the shutdown command is: shutdown command:
           sudo /sbin/poweroff
    

    reboot command:

           sudo /sbin/reboot
    

Now you should be able to shutdown and reboot the Pogoplug remotely. I did nopt bother about the suspend and hybernate and disabled therse options.

15 TODO Install usbmount

  apt-get install usbmount pmount

And configure it by modifying the mountpoints:

MOUNTPOINTS="/media/usbmount/usb0 /media/usbmount/usb1 /media/usbmount/usb2 /media/usbmount/usb3
             /media/usbmount/usb4 /media/usbmount/usb5 /media/usbmount/usb6 /media/usbmount/usb7"

and create the mountpoints.

mkdir -p /media/usbmount/usb0
mkdir /media/usbmount/usb1
mkdir /media/usbmount/usb2
mkdir /media/usbmount/usb3
mkdir /media/usbmount/usb4
mkdir /media/usbmount/usb5
mkdir /media/usbmount/usb6
mkdir /media/usbmount/usb7

16 DONE Setup AFP Time and Machine

16.1 Install and setup AFP

Hm – can’t find the link. Found it: http://bullcreekstudio.com/uncategorized/debian-wheezy-mavericks-time-machine-server/

Time Machine seems to need AFP file sharing and does not work with samba, so we have to install and setup netatalk and avahi.

16.1.1 Install netatalk and avahi

apt-get install netatalk avahi-daemon avahi-utils

Netatalk is not present in Debian Jessie. So we have to compile it ourselves. I will follow this link and see how it goes, but this one actually worked:

mkdir ~/netatalk
cd ~/netatalk
wget https://github.com/adiknoth/netatalk-debian/archive/upstream/3.1.7.tar.gz
tar -xf 3.1.7.tar.gz
cd 3.1.7
apt-get install build-essential devscripts debhelper cdbs \
        autotools-dev dh-buildinfo libdb-dev libwrap0-dev libpam0g-dev \
        libcups2-dev libkrb5-dev libltdl3-dev libgcrypt11-dev \
        libcrack2-dev libavahi-client-dev libldap2-dev libacl1-dev \
        libevent-dev d-shlibs dh-systemd libtdb-dev
./configure --with-init-style=debian-systemd \
            --without-libevent \
            --without-tdb \
            --with-cracklib \
            --enable-krbV-uam \
            --with-pam-confdir=/etc/pam.d \
            --with-dbus-sysconf-dir=/etc/dbus-1/system.d \
            --with-tracker-pkgconfig-version=1.0
make
make install

16.1.2 Add the following line to /etc/netatalk/afpd.conf

- -tcp -noddp -uamlist uams_guest.so,uams_dhx.so,uams_dhx2.so

and comment out (if not already commented out)

# - -tcp -noddp -uamlist uams_dhx.so,uams_dhx2.so -nosavepassword

16.2 Setup shares

Add the exported directories for TimeMachine and others to /etc/netatalk/AppleVolumes.default

## Time Machine
/media/TimeMachine "TimeMachine" options:usedots,upriv,tm

## Music
/media/Music       "Music Read Only"       options:usedots,upriv,ro

and some other read-only shares:

# /media/external    "External Read Only"    options:usedots,upriv,ro
# /media/usbmount    "USBMount Read Only"    options:usedots,upriv,ro

And restart netatalk

service netatalk restart
  • user timemachine setup

Add some security by adding user timemachine and change ownership of the backup folder to this user:

useradd -s /bin/false timemachine
passwd timemachine
chown -R timemachine:timemachine /media/TimeMachine

17 DONE Setup samba

See Debian WIKI SambaServerSimple, HowToForge or UnixMen for details. Also the free ebook from O’Reilly

17.1 Install server and client

  apt-get install samba samba-client samba-common-bin cifs-utils

17.2 Add Users

The users must exist on the computer!

  smbpasswd -a rainerkrug
  smbpasswd -a cornelia

Check the users

  pdbedit -w -L

17.3 Add shares

In the file /etc/samba/smb.conf,

  1. change the workgroup in the section [global]
[global]
  ...
  workgroup = pogoplug

In the section [homes], you cen enable read-write access to home directories

[homes]
  ...
  read only = no

Define shares as a new section at the bottom, e.g:

[BackupConnie]
  comment = Backup for Connies computer usinb duplicity
  read only = n
  locking = no
  path = /media/BackupConnie
  guest ok = no

[Diverse]
  comment = Diverse stuff
  read only = n
  locking = no
  path = /media/Diverse
  guest ok = yes

[Music]
  comment = Music
  read only = guest nobody
  locking = no
  path = /media/Music
  guest ok = yes

17.4 Restart samba

  service samba restart

17.5 TODO Setup CUPS and AirPrint Server

See e.g. Nick’s Ramblings for background. But better, as newer, MakeUseOf Install cups and hplib (needed for HP printer)

  apt-get install cups cups-pdf hplip

Change access to CUPS to local network

#Listen localhost:631
#Listen /var/run/cups/cups.sock
Port 631
ServerAlias *
 
<Location />
Order allow,deny
Allow @LOCAL
</Location>
 
<Location /admin>
Order allow,deny
Allow @LOCAL
</Location>

Now you can go ahead and use your pogoplug as a print server.

For AirPrint, we have to install

  apt-get install avahi-discover

This will install quite a lot of additional packages!

(see MakeUseOf). There are other HowTos available, but they are outdated as, I think, AirPrint support is already included in the newer CUPS version.

18 Setup NFS

Install the required programs

apt-get install nfs-kernel-server nfs-common

Create a directory exports in which all to be exported directories will be by using bind

mkdir /exports
mkdir /exports/MusicRO
mkdir /exports/Music

Add the following to the fstab so that it is available in the directory /exports

/media/Music                   /exports/MusicRO                none    bind
/media/Music                   /exports/Music                  none    bind

and add the following to the file /etc/exports to export the directory

/exports/MusicRO        192.168.1.0/255.255.255.0(ro,async,crossmnt,no_subtree_check,insecure,all_squash,anongid=1002,anonuid=102)
/exports/Music          192.168.1.0/255.255.255.0(rw,async,crossmnt,no_subtree_check,insecure,all_squash,anongid=102,anonuid=102)

19 Add new users and groups for convenience and security

adduser rainerkrug
##
groupadd music
usermod -a -G music rainerkrug
usermod -a -G music squeezeboxserver
##
chown -R squeezeboxserver:music /media/Music
chmod -R g+rwx /media/Music

If you are thinking about using read-write access for hfsplus formatted drives, you should change the userid of the user to 501 (see ubuntu wiki):

  usermod --uid 501 rainerkrug

20 Add device image software

For usage of qcow2 images (compressed)

apt-get qemu-utils zeroferee

21 Other software

  apt-get install parted screen 
  # apt-get install gpt
Advertisements

2 responses to “Pogoplug Logitech Media Server & Time Capsule

  1. What is your conclusion after you have done this? Is this a usable solution? Any issues with the server? I once setup LMS on a Odroid C2 and was not happy with the performance at all. I have over 400 gigs of music and had lag when scrolling through all the files on the clients along with other issues that I can’t remember. Overall the lose in performance did not make it a viable solution. Thanks.

    • Well – It depends on your expectations. It os obviously not the fastest solution (end there is surely much room for improvement – use faster usb stick and possibly an hdd specifically) but I am happy with it’s performance – considering the costs and the very low energy consumption. I only have about 200 GB of music, but it works OK. As you said (and I think the Odroip is more powerful than the Pogoplug E02), not cruising, but I would say working like a tractor and no complains in playback with one or two player.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s