headless plex media server

this is an install log for myself how I got my plex server running

install ubuntu server 14 + SSH

apt-get update&&dist-upgrade

check ethernet config (inet dhcp / inet6 auto)

wget [latest 64 bit plex .deb file] < --seems the repo is broken forever... apt-get install avahi-daemon avahi-utils dpkg -i [plexxxxxxx.deb]

nice link on the xbmc wiki on how to get Wake-on-LAN and powersave enabled:

sudo apt-get install ethtool

Run the following command to enable it on ethX (where X is the Ethernet device number).

sudo ethtool -s eth0 wol g

verify with:

root@plex:/tmp# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Link partner advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: MII
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: g
Current message level: 0x00000033 (51)
drv probe ifdown ifup
Link detected: yes

“Wake-on: g” indicates wake on Magic Packet is enabled

Enable ethtool on Start-up

To have an application or service is running on startup, Ubuntu uses Upstart scripts which replace the old init scripts.

The following commands create wakeonlan.conf with the upstart code to run wakeonlan (as per example above), set the file to exectuable, and start the service:

bash -c "cat > /etc/init/wakeonlan.conf" < <'EOF' start on started network script interface=eth0 logger -t 'wakeonlan init script' enabling wake on lan for $interface ethtool -s $interface wol g end script EOF

chmod +x /etc/init/wakeonlan.conf
service wakeonlan start

so I tried to prevent the powerbutton to shut down immediately – would like a standby there.. and long-press switch off hard but BIOS won’t allow that

finding this:
and changing the action

event=button[ /]power

but it still shuts down… WHY?

turns out systemd is the problem – so let’s edit

and uncomment/edit: PowerKey to do “suspend”


restart systemd or reboot….
and the system now shows me this nice large LED in orange and blue (suspend/awake) :)

but I don’t like the fact that I have to use a PC or the router for wake-on-LAN – the server should do that when it sees traffic/the server in use…

again someone came up with a nice idea: Use a raspberry pi for that:
Note: this is if you want your server to suspend.. ideally it should just enter low power state.

The final solution I found for myself was writing a little bash script. The raspberry-pi dependencies are etherwake and tcpdump. Both are not installed by default on rasbian. Also on the server Wake On Lan needs to be enabled as mentioned in the other posts.

apt-get install etherwake
apt-get install tcpdump

The wake script is as follows:

nano ~/wol.sh



pingInterval=60 #time interval, in seconds, between checks that the server is still awake.
target=192.168.x.x #WOL target ip address
targetMAC=00:11:22:33:44:55 #WOL target MAC

wake () {
tcpdump -i eth0 -c 1 -p host $target
etherwake $targetMAC
#echo WOL sent to $target at $targetMAC

while sleep $pingInterval; do
varPing=`ping -s 1 -c 2 $target > /dev/null; echo $?`
if [ $varPing -eq 0 ]; then
#echo ping success
#echo ping fail

The primary idea is that it is run from my raspberry-pi which will wake the server if it notices a single arp request for the server. If the server is awake then it wont be listening for an arp request but send a few pings every now and then to make sure it is still awake.

I named the file wol.sh and made it executable. Then put it in the sudo crontab to launch @reboot as root. This is for tcpdump which needs elevated access to listen to eth0 and etherwake.

sudo chmod +x /home/pi/wol.sh
sudo crontab -e

add this to the bottom

@reboot sh /home/pi/wol.sh > /dev/null

but this could be done more elegantly with some home automation using wlan and mac addresses of my phone.. which I carry with me all the time
if my phone’s mac is in the network it must not shut down, if I leave it shuts down the server
and the other way round, when i come home it should wake on lan.
there are several options here:
– hack my own solution running on the pi
– rely on the fritz box (it has home automation stuff)
– get a keyfob / smarttag like Paul has


Raspberry Pi Remote Wake/Sleep-On-LAN Server

package on raspian is called ‘wakeonlan’
tcpdump can sniff for mac addresses – home router would be the place to check?
need to change arp timeout?

now for windows shares / samba:

apt-get install samba cifs-utils
smbpasswd -a

configure a share or two in /etc/samba/smb.conf

workgroup = NOGROUP < -- adjust netbios name = PLEX <-- adjust, ideally it's your hostname server string = %h server (Samba %v, Ubuntu) map to guest = Bad User obey pam restrictions = Yes pam password change = Yes passwd program = /usr/bin/passwd %u passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\su$ unix password sync = Yes syslog = 0 log file = /var/log/samba/log.%m max log size = 1000 dns proxy = No usershare allow guests = No panic action = /usr/share/samba/panic-action %d idmap config * : backend = tdb [plexhome] <-- name of the share path = /plexhome/ <-- location on the host comment = Plex raw media files <-- be creative writeable = yes valid users = plex browsable = yes guest ok = no

[add more if you like...]
service smbd restart

and mount from windows/mac

now that should be fine.. need to add some small details like transmission or so :)

now… about the home theater front-end – not the server!

For Ubuntu we use launchpad to distribute Plex Home Theater.

https://launchpad.ne… archive/plexht

There are some requirements for PHT on Ubuntu.

Ubuntu 12.04 12.10,13.10 and 14.04 need’s ppa:pulse-eight/libcec to work.

sudo add-apt-repository ppa:plexapp/plexht
sudo add-apt-repository ppa:pulse-eight/libcec
sudo apt-get update
sudo apt-get install plexhometheater


PHT Repo for Debian Wheezy! (do not use with Ubuntu !)

sudo apt-get install curl
sudo curl http://shell.ninthgate.se/packages/shell-ninthgate-se-keyring.key | sudo apt-key add –
echo “deb http://www.deb-multimedia.org wheezy main non-free” | sudo tee -a /etc/apt/sources.list.d/deb-multimedia.list
echo “deb http://shell.ninthgate.se/packages/debian wheezy main” | sudo tee -a /etc/apt/sources.list.d/plex.list
sudo apt-get update
sudo apt-get install deb-multimedia-keyring
sudo apt-get update
apt-get install plexhometheater

– how to fix which screen it should display? apparently plex does not understand aRandR screen layout
– how to get rid of little artifacts throughout plex? >> seems to be related to old intel video chip and linux – doesn’t happen on intel 4k