Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

A few days ago I wrote about when I physically put together my Odroid-XU4 home media server. This article deals with the software side of the setup. This server runs Plex, shares all the media files via Samba (Windows file sharing) and also runs the Deluge torrent client.

When I was initially looking at my options there was only one NAS oriented OS that seemed to meet all my requirements - OpenMediaVault. I did install it and tried to get it set up the way I wanted, but after much struggle, headache and frustration I decided to give up and use a bare minimum distribution instead.

I chose DietPi as the OS to run on my XU4. I was a little skeptical at first given how gaudy their web site is, but it's actually a very well put together Debian (Jessie) Linux based distribution for ARM.

If you read my previous posts, I jumped the gun in sealing my XU4 in the enclosure so was forced to boot from the SD card and transfer files over to the eMMC afterwards. That wasn't a big deal, just meant a couple extra reboots. When booting from the SD card, the eMMC is visible as the first block device so copying the DietPi image is as simple as...
 Command
dd if="DietPi_v127_OdroidXU4-armv7-(Jessie).img" of=/dev/mmcblk0 bs=1M


After booting from the eMMC, the initial setup was simple and guided by the installer...
  • Login as root
  • Accept update request
  • Set up networking
  • XU4 restarts here
  • Login as root again, installer runs again


At this point you're given the option to select which software you want, I picked the following:
  • Plex Media Server
  • Deluge
  • Samba


Then just select GO and let the installer do its thing.



At this point I had most of the software I wanted, but not all. Specifically, webmin was missing. Installing it was a little more involved, the following commands did it though...
 Commands
echo "deb http://download.webmin.com/download/repository sarge contrib" >> /etc/apt/sources.list
wget http://www.webmin.com/jcameron-key.asc
apt-key add jcameron-key.asc
apt-get update
apt-get install webmin -y


That took care of webmin, but a few others were still required. I needed HFS+ support since the disks I was copying from were from an OS X server. The rsync, and other utilities were there to assist in the file migration process and avahi-daemon for aesthetic reasons I'll cover later. I installed these using apt-get...
 Commands
apt-get install hfsplus hfsprogs hfsutils rsync locate screen avahi-daemon


I was going to use Plex for the media server, which goes hand-in-hand with Trakt.tv so the Plex Trakt Scrobbler was installed. I had major issues trying to get this working when I had OpenMediaVault installed, on DietPi the install and running of this plugin went without a hitch. Install instructions can be found here.

Next was time to copy my 3Tb+ of data from the HFS+ disks. These mounted without any issue and I used rsync to copy them over. It took about two days (with breaks in between). The maximum transfer speeds I could get were 40Mb/s, which is well under USB 3.0 speeds, which is probably more due to the HDD enclosure than the XU4. This was the command I used to copy data...
 Command
rsync -vrW --chown=nobody:nogroup --size-only --progress /mnt/Temp/* /mnt/Data1


While data was being copied (in a screen session) I did some research on performance, fan speed and cooling of the XU4. This thread on fan control was very useful. I experimented with setting the fan speed as follows:
 Command
echo "0 40 65 95" > /sys/devices/odroid_fan.14/fan_speeds
echo "50 70 85" > /sys/devices/odroid_fan.14/temp_levels


To make these permanent I created the /etc/udev/rules.d/60-odroid_fan.rules file with the following contents:
 /etc/udev/rules.d/60-odroid_fan.rules
DRIVER=="odroid-fan", ACTION=="add", ATTR{fan_speeds}="0 45 65 95", ATTR{temp_levels}="50 70 85"


At the same time, using dietpi-config I set Performance Options as follows:
 Performance Options
Governor | conservative
Throttle up | 85% CPU usage


Why those (non-performant) settings? Mostly because there is no need to run the XU4 flat-out when it is idle or in light use. Those settings work well for file copy and direct Plex streaming. It does ramp up when needed but my main focus was having just enough performance while keeping the whole setup cool.

I noticed that i had the spi1 process running all the time and taking up considerable CPU (around 20%). After some research I found this process is for the CloudShell and since I don't have one, I decided to disable the SPI module by creating the /etc/modprobe.d/blacklist file with the following contents:
 /etc/modprobe.d/blacklist.conf
blacklist spi_s3c64xx
blacklist spidev


To make the module blacklisting permanent, I ran the command below and restarted.
 Command
update-initramfs -u


I was getting annoyed by the heartbeat LED on the XU4 flashing all the time. Fortunately this was easy to disable on boot by adding the following line to /etc/rc.local. That makes the blue heartbeat LED flash only during eMMC access instead of on timed intervals.
 /etc/rc.local
echo "mmc0" > /sys/class/leds/blue\:heartbeart/trigger


In my setup I use an SSD as a kind of temporary/cache drive. That is so that the large 4Tb disk is not used unnecessarily. That means torrent downloads, data for my traffic cam and Plex metadata are located there. By default Plex metadata is on the eMMC (or the / partition) which is not ideal, so I moved it to the SSD (mounted at /mnt/Stage1) after shutting down the plexmediaserver service (/etc/init.d/plexmediaserver stop). Instead of just moving the data I made a copy and renamed the old directory to keep as a backup...
 Commands
mkdir /mnt/Stage1/PlexData
cp -prv /var/lib/plexmediaserver/* /mnt/Stage1/PlexData
mv /var/lib/plexmediaserver /var/lib/plexmediaserver.old


After copying metadata, the /etc/default/plexmediaserver config file was updated with the new location as follows:
 /etc/default/plexmediaserver
PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/mnt/Stage1/PlexData/Library/Application\ Support"


Now coming back to the aesthetic reasons I mentioned earlier. I wanted to control how the server name and icon appeared when viewed form my MacBook Pro. The first image shows the before and second image the after version of what Finder displays. The second is much more pleasant I think.

avahi1.png avahi2.png


To set that up, I added the Samba service to Avahi configuration as follows:
 /etc/avahi/services/smb.service
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_smb._tcp</type>
<port>445</port>
</service>
<service>
<type>_device-info._tcp</type>
<port>0</port>
<txt-record>model=RackMac</txt-record>
</service>
</service-group>


To make the above work the hostname was also set to 'PulseDroid' i.e. it was in camel case, not standard lower case.

Lastly, after a couple of days of usage I noticed that the hard disk was spinning down and spinning up constantly. That's not so great for the disk health so I decided to change the spin down time to 2.5 hours and disable advanced power management.

Those changes can be done on the fly by running:
 Command
hdparm -S 243 -B 255 /dev/sda


To make them permanent, the /etc/hdparm.conf was updated with the following contents (I did it for both disks though it's not actually needed for the SSD):
 /etc/hdparm.conf
/dev/sda {
spindown_time = 243
apm = 255
}
/dev/sdb {
spindown_time = 243
apm = 255
}


That's pretty much it for the setup. I did add a script to display system stats on the Odroid-Show2 that I have attached to the XU4, which I'll cover in a separate post.

-i

A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.