Quantcast
Channel: creechy iv: a new hope
Viewing all articles
Browse latest Browse all 20

Notes on my Media Server

$
0
0

I recently rebuilt my media server. Previously it was based on an old ReadyNAS NV+ and Mac Mini. These both have  outlasted their lifetimes, they are slow, noisy and large. So I recently rebuilt the whole rig.

Primary Uses

I call it a media server but in reality its much more than that. The 1Gbit broadband service my internet provider gives me affords lots of bandwidth to do interesting things.

  • File Server – photos, among other digital assets, that I want to have available in my home.
  • Media serving – videos that I want to have available to view on my TV and other devices.
  • Web presence – Some personal web sites and web applications I want to be able to access anywhere.

The Rig

The goal here is to strike a balance between simplicity, power, and noise. The primary components I chose are

  • Intel NUC6i7KYK – A very compact all-in-one unit. Slightly loud fan, but quieter than my old rig, and it is generally drowned out by background noise anyways.
  • Seagate 5TB Backup Plus USB 3.0 Disk – These are for the data partition. The old ReadyNAS had 4TB of redundant disk. I got two of these Seagate disks to build similar redundancy.
  • Samsung 960 Evo NVMe 500GB SSD – This will hold the system software. Probably a 250GB SSD is sufficient really.

System Software

I decided to use Ubuntu 18.04. There are some applications that do have a GUI for them, making the full Ubuntu desktop available though remote access (via VNC) was required.

There was nothing notable for the basic install, however making Ubuntu run in “headless” mode took some work, which I previously wrote about.

I did choose to partition the system disk using LVM. My original intention was to use LVM to build a redundant data partition, but after the basic install was done, I discovered that ZFS was ported to Linux which is far easier to work with.

Data Partition

I built the data partition using the two Seagate 5TB drives. Really simple mirroring (RAID-1). Using ZFS made this incredibly easy, It has been a while since I last used ZFS but it came back to me pretty quickly. I started with the Ubuntu ZFS Tutorial and followed that up with a read through the Ubuntu ZFS Reference to figure out how create file systems, etc.

% zfs list
NAME               USED  AVAIL  REFER  MOUNTPOINT
data-pool         2.85T  1.54T    96K  none
data-pool/backup  63.0G  1.54T  63.0G  /data/backup
data-pool/home    78.9M  1.54T  78.9M  /data/home
data-pool/media   2.57T  1.54T  2.57T  /data/media
data-pool/photos   229G  1.54T   229G  /data/photos

File Server

File serving is always an annoying thing. Even for a home network where you might have only a few users with different access permissions, it can be frustrating.

The natural solution for making files available in a heterogeneous environment is to use SAMBA. Here’s some notes on configuration and tweaks. There are some global tweaks I made to /etc/samba/smb.conf

[global]
mangled names=no
veto files = /._*/.DS_Store/
delete veto files = yes
min protocol = SMB2
netbios name = mockhub

This is mainly because I didn’t want to have any of those special OSX files all over the place.

Since I last used SAMBA I found there is a net share, command. I thought this would make it easy to configure my shares, but it doesn’t really provide the level of control I need. In the end I added my shares to /etc/samba/smb.conf file. Here’s an example

[media]
path=/data/media
comment=Media Archive
#usershare acl=Everyone:F,
guest ok=yes
force user=media
read only=no

The force user parameter is the key to simplifying permissions. It tells the samba server to always access files as the specified user. And so even though a client will have to authenticate with their own user/password, all access is done as that user.

Media Server

I’ve found two great options that provide a DLNA-based media server; Universal Media Server and Serviio. Both provide both a server and a management interface. I have used Universal Media Server for a long time. They both have similar features for my needs.

There’s not much special configuration for either of these tools. Simply point them to your archive of video files and they will discover, catalog, and thumbnail them.

One interesting thing to note is regarding fast-forward & rewind. Neither of these can apparently provide fast-foward/rewind if they are transcoding (on the fly). Transcoding can be necessary for various reasons but the main two I have seen are because the source format is not compatible with your player (TV) and to provide subtitles.

For example, I have some h.265 encoded files, but my television can’t play them natively so these programs have to transcode them to play them.

Finally, I wrestled with random disconnects from my TV to both UMS & Serviio, tweaking various settings in the apps and the router. The magic so far has been this:

In LAN -> IPTV Tab, enable the following settings:

Web Server

I have both Java web-apps and plain HTML sites that want to serve. The obvious choice is Tomcat for this.

The trick here is that I don’t want to run Tomcat as root, but I want to serve content from the typical port 80 & 443. I could create a mapping in my router for this, but for now I opted to create some iptables rules to map 80 & 443 to Tomcat’s 8080 & 8443.

% sudo iptables -L -n -t nat
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         
REDIRECT   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:80 redir ports 8080
REDIRECT   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:443 redir ports 844

I also wanted to use letsencrypt to create my own certificate for Tomcat. Unfortunately letsencrypt doesn’t natively support Tomcat. The additional wrinkle is I want to support multiple domains with a single certificate.

I found this excellent article – Configuring Let’s Encrypt with Tomcat 6.x and 7.x – to do the basic configuration. And combined it with the article Adding an SAN to an SSL cert (in Java)

Conclusion

Since the original installation, I have been finding more uses for the server. For example, I’ve been trying to decrypt an old iOS backup that I lost the password for, but the tools to do this are generally Windows based. So, using VirtualBox, I started up a Windows VM, have have set up a process where I automatically suspend and resume the VM during the day to continue searching for the password.

Although its taken some time to set up, I have enjoyed the additional flexibility of the fully custom media server.


Viewing all articles
Browse latest Browse all 20

Trending Articles