[How-To] emby iocage jail installation

Status
Not open for further replies.

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
INTRODUCTION

When I rebuilt my emby Warden jail I'd documented the steps in order to post this How-To thread. I did find there was already a similar thread here, but I wanted to try and make it as simple as possible and in the style of one of my favourite How-To guides here.

There are a number of different ways to do this on FreeNAS, but from my experience, this method provides the best performance although does take a couple of hours to compile all the dependencies from ports. Using pkg to install everything would be quick, but does not guarantee the latest versions available. Using the plugin is even quicker, but leaves you with a Warden jail running a version of FreeBSD which is already EOL, so not recommended.

INSTALLATION

OPTIONAL CONFIGURATION AND UPDATING

NOTES
  • iocage jails can be updated, but I still think it's good practice to store the 'user data' outside of the jail structure (in this case the /var/db/emby-server folder containing your configuration, library and metadata)
  • it makes snapshots and backup of this data simple and also makes moving things to another jail easier if required.
  • if you plan to expose this jail outside your local network, I would strongly look at using SSL. I have a number of services exposed, so use another jail acting as a reverse proxy and creating SSL certificates so haven't described hardening external access here.
UPDATE

emby have released a new FreeBSD package for testing here, which I tested using parts of the guide below. It's a much quicker way of creating the required components - simply replace lines 3 & 4 in the first Configure Jail section with those in the link. They have also fixed an issue caused by changing the path of the data folder (/var/db/emby has gone back to /var/db/emby-server). This seems to be working quite well and I'll probably update the guide when they move this to the standard approach, as it saves the time building all the ports.

emby have now developed a script to create an emby iocage jail, which looks like it will now be the recommended approach and is much quicker than manually building from ports. Suggest reading THIS before progressing with the guide below.
 
Last edited:

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
INSTALLATION

Create User Dataset


FreeNAS WebUI
Storage > Create ZFS Dataset
  • Dataset Name = embydb
  • Compression level = lz4
  • Enable atime = Off

Create iocage Jail


FreeNAS CLI (either from Shell in menu tree or SSH)

Code:
iocage create --name “<JAIL_NAME>” -r 11.1-RELEASE ip4_addr=”vnet0|<JAIL_IP>/24″ defaultrouter=”<IPV4_DEFAULT_GATEWAY>″ vnet=”on” allow_raw_sockets=”1″ boot=”on”

Replace:

<JAIL_NAME> with the name you want the iocage jail to have (I have used "embyms")
<JAIL_IP> with the IP address you want the jail to have, within a useable range
<IPV4_DEFAULT_GATEWAY> with the value in Network > Global Configuration


Configure Jail


FreeNAS CLI

Code:
iocage start embyms
iocage console embyms
portsnap fetch extract
cd /usr/ports/multimedia/emby-server/ && make install clean

This will compile all the required dependencies and will take some time (60-90 mins) with regular intervention required. You only need to change the options for 2 applications:

FFmpeg options which should be checked
+ ASS (required for subtitle rendering)
+ LAME (required for mp3 audio transcoding)
+ OPUS (required for Opus audio codec support)
+ SMB
+ X265 (required for H.265 video codec support)

ImageMagicK option which should be unchecked
— 16BIT_PIXEL (to increase thumbnail generation performance)

Once complete, and so emby starts with the jail:

Code:
sysrc 'emby_server_enable=YES'


Stricken out instructions can be replaced by this #30

You should then create the folders which you will mount your external datasets too, for example:

Code:
mkdir /media
mkdir /media/tv


mkdir /media/
mkdir /media/tv
mkdir /media/movies
mkdir /media/dvr
mkdir /media/photos
mkdir /media/home-movies
mkdir /media/iptv
mkdir /var/db/emby-server (this is where I will mount the 'user data' to)
mkdir /temp (I use this for moving log files outside the jail if required)


Mount Datasets to Jail

FreeNAS CLI

You are likely to need 3 basic commands:

iocage fstab -l embyms (displays a list of the current fstab lines, including the INDEX number)
iocage fstab -a embyms "/mnt/<POOL_NAME>/<DATASET_LOCATION> /<JAIL_FOLDER_LOCATION nullfs rw 0 0" (to add new fstab lines)
iocage fstab -r embyms INDEX (removes the fstab line with the INDEX number used)

Two examples of my configuration:

Code:
iocage fstab -a embyms “/mnt/APEpool1/embydb /var/db/emby-server nullfs  rw  0  0”
iocage fstab -a embyms “/mnt/APEpool1/media/Films /media/movies nullfs rw 0 0”

Once complete, restart the jail:

Code:
iocage restart embyms


emby should now be accessible in the browser of your choice at http://<JAIL_IP>:8096

:)

emby Permissions

You might find you need to create an emby user in FreeNAS and then set permissions for the embydb dataset.

FreeNAS WebUI
Account > Users > Add User

  • User Id: 989
  • Username: emby
  • Disable Password Login: Checked
Storage > embydb > Change Permissions

  • Owner (user): emby
  • Owner (group): emby
  • Set permissions recursively: Checked
[/s][/B]
 
Last edited:

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
OPTIONAL CONFIGURATION AND UPDATING

Install portupgrade to maintain the jail

FreeNAS CLI

Code:
iocage console embyms
cd /usr/ports/ports-mgmt/portupgrade/ && make install clean

To update, run

Code:
portupgrade -ai

Install ufraw for better support of RAW image files (I have thousands of Canon RAW files)

FreeNAS CLI

Code:
iocage console embyms
cd /usr/ports/graphics/ufraw/ && make install clean

Manually Update emby (where a newer version or beta version is required)

FreeNAS CLI

Code:
iocage console embyms
cd /tmp
fetch https://github.com/MediaBrowser/Emby/releases/download/3.4.1.0/Emby.Mono.zip (swap with address of latest file found here)
unzip -d /tmp/emby Emby.Mono.zip
cp -Rfp /tmp/emby/ /usr/local/lib/emby-server
service emby-server start


Stricken out instructions can be replaced by this #30
 
Last edited:

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
My first How-To guide so please be gentle ;)

Let me know if something is wrong so I can update...

6/6/18 - Updated Installation section with permissions section, put some of the configuration options in 'SPOILER' tags and corrected iocage --name.
14/7/18 - Added Update section to reflect the emby FreeBSD package for testing method
20/7/18 - Updated the Update section as this now appears to work correctly!
3/9/18 - Added post #30 and struck out some of the instructions. I will revisit this again once the dust has settled on iocage jails, 11.2 plugins, etc.
 
Last edited:

Zwck

Patron
Joined
Oct 27, 2016
Messages
371
"–name" must be changed to "-n" in the iocage create command.
 

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
I found running make config-recursive multiple times to set all the options and then make install clean is better so you don't have to interact with it over the time it's installing.
 

csjjpm

Contributor
Joined
Feb 16, 2015
Messages
126
I found running make config-recursive multiple times to set all the options and then make install clean is better so you don't have to interact with it over the time it's installing.

I tried the make config-recursive and got the follow error:

Building new INDEX files... done.
root@embyms:~ # make config-recursive
make: don't know how to make config-recursive. Stop

make: stopped in /root
root@embyms:~ #



I tried it without and after about 40mins cd /usr/ports/multimedia/emby-server/ && make install clean failed with an error code 1

Any suggestions?
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
What was it trying to do when you got the error code 1?
 

csjjpm

Contributor
Joined
Feb 16, 2015
Messages
126
Last time I'd gone through a dozen or more configs but this time it happened on the first one 'emby-server'

===> License GPLv2 accepted by the user
===> emby-server-3.3.1.0_1 depends on file: /usr/local/sbin/pkg - found
=> MediaBrowser-Emby-3.3.1.0_GH0.tar.gz doesn't seem to exist in /usr/ports/dist
files/.
=> Attempting to fetch https://codeload.github.com/MediaBrowser/Emby/tar.gz/3.3.
1.0?dummy=/MediaBrowser-Emby-3.3.1.0_GH0.tar.gz
fetch: https://codeload.github.com/MediaBrowser/Emby/tar.gz/3.3.1.0?dummy=/Media
Browser-Emby-3.3.1.0_GH0.tar.gz: No address record
=> Attempting to fetch http://distcache.FreeBSD.org/ports-distfiles/MediaBrowser
-Emby-3.3.1.0_GH0.tar.gz
fetch: http://distcache.FreeBSD.org/ports-distfiles/MediaBrowser-Emby-3.3.1.0_GH
0.tar.gz: No address record
=> Couldn't fetch it - please try to retrieve this
=> port manually into /usr/ports/distfiles/ and try again.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/multimedia/emby-server
*** Error code 1

Stop.
make: stopped in /usr/ports/multimedia/emby-server
root@embyms:/usr/ports/multimedia/emby-server #
 

csjjpm

Contributor
Joined
Feb 16, 2015
Messages
126
Um.... this just hapenned


root@embyms:/usr/ports/multimedia/emby-server # portsnap fetch extract
Looking up portsnap.FreeBSD.org mirrors... none found.
Fetching snapshot tag from portsnap.FreeBSD.org... failed.
No mirrors remaining, giving up.
root@embyms:/usr/ports/multimedia/emby-server #
 

csjjpm

Contributor
Joined
Feb 16, 2015
Messages
126
Ifconfig output seems okay


root@embyms:/usr/ports/multimedia/emby-server # ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 127.0.0.1 netmask 0xff000000
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
groups: lo
epair0b: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=8<VLAN_MTU>
ether 02:ff:60:0d:d6:f4
hwaddr 02:fe:a0:00:05:0b
inet 192.168.0.107 netmask 0xffffff00 broadcast 192.168.0.255
nd6 options=1<PERFORMNUD>
media: Ethernet 10Gbase-T (10Gbase-T <full-duplex>)
status: active
groups: epair
root@embyms:/usr/ports/multimedia/emby-server #
 

csjjpm

Contributor
Joined
Feb 16, 2015
Messages
126
fixed resolv.conf but still get the errors

root@embyms:~ # portsnap fetch extract
Looking up portsnap.FreeBSD.org mirrors... none found.
Fetching snapshot tag from portsnap.FreeBSD.org... failed.
No mirrors remaining, giving up.
 
Last edited:

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
Looks like the jail isn't even connecting externally, but I have no idea why not.
 

csjjpm

Contributor
Joined
Feb 16, 2015
Messages
126
I destroyed it before when the error occurred. Third time is the charm!
 

Zwck

Patron
Joined
Oct 27, 2016
Messages
371
i am guessing you did not add the tunables. (change igb0 to yours)
post-165508-0-88464400-1528005339.png


Add
Var, value, type
cloned_interfaces, bridge0, rc
ifconfig_bridge0, addm igb0 up, rc


https://emby.media/community/index.php?/topic/13083-freenas-plugin/page-45#entry584092
 

csjjpm

Contributor
Joined
Feb 16, 2015
Messages
126
i am guessing you did not add the tunables. (change igb0 to yours)
post-165508-0-88464400-1528005339.png


Add
Var, value, type
cloned_interfaces, bridge0, rc
ifconfig_bridge0, addm igb0 up, rc


https://emby.media/community/index.php?/topic/13083-freenas-plugin/page-45#entry584092

I am on 11.1u5 and have added in these tunables as per pic replacing igb0 with epair0b. I've restarted the iocage embyms and still problems

Looking up portsnap.FreeBSD.org mirrors... none found.
Fetching snapshot tag from portsnap.FreeBSD.org... failed.
No mirrors remaining, giving up.
 
Last edited:

csjjpm

Contributor
Joined
Feb 16, 2015
Messages
126
From the console of embyms I can ping the lan router but nothing else is resolved. My resolv.conf has 192.168.0.1 as the nameserver
 

Zwck

Patron
Joined
Oct 27, 2016
Messages
371
From the console of embyms I can ping the lan router but nothing else is resolved. My resolv.conf has 192.168.0.1 as the nameserver

you need to restart freenas and i am not sure if (replacing igb0 with epair0b) is correct. check Network > interfaces > and check NIC discription
 

Zwck

Patron
Joined
Oct 27, 2016
Messages
371
not in jail

ifconfig

Code:
root@freenas:~ # ifconfig
igb0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
		options=2400b9<RXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,VLAN_HWTSO,RXCSUM_IPV6>
		ether 0c:c4:7a:c5:f5:ee
		hwaddr 0c:c4:7a:c5:f5:ee
		inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
		inet 192.168.0.110 netmask 0xffffff00 broadcast 192.168.0.255
		nd6 options=9<PERFORMNUD,IFDISABLED>
		media: Ethernet autoselect (1000baseT <full-duplex>)
		status: active
igb1: flags=8c02<BROADCAST,OACTIVE,SIMPLEX,MULTICAST> metric 0 mtu 1500
		options=6403bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,VLAN_HWTSO,RXCSUM_IPV6,TXCSUM_IPV6>
		ether 0c:c4:7a:c5:f5:ef
		hwaddr 0c:c4:7a:c5:f5:ef
		nd6 options=9<PERFORMNUD,IFDISABLED>
		media: Ethernet autoselect
		status: no carrier
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
		options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
		inet6 ::1 prefixlen 128
		inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
		inet 127.0.0.1 netmask 0xff000000
		nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
		groups: lo
bridge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
		ether 02:ac:68:db:e5:00
		nd6 options=9<PERFORMNUD,IFDISABLED>
		groups: bridge
		id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
		maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200
		root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
		member: tap0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
				ifmaxaddr 0 port 5 priority 128 path cost 2000000
		member: igb0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
				ifmaxaddr 0 port 1 priority 128 path cost 55
tap0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
		options=80000<LINKSTATE>
		ether 00:bd:44:bf:3b:00
		hwaddr 00:bd:44:bf:3b:00
		nd6 options=1<PERFORMNUD>
		media: Ethernet autoselect
		status: active
		groups: tap
		Opened by PID 3993

 

csjjpm

Contributor
Joined
Feb 16, 2015
Messages
126
In my freenas shell the device with my freenas ip address is em0. I've changed that. I'll reboot and see if that has worked.
Thank you for your help and patience.
 
Status
Not open for further replies.
Top