setting up plex in a linux container

In case anybody out there is running a recent Debian (jessie or later), and has ever wondered how much of a hassle it would be to install Plex into a container to segregate it from the rest of your system: It turns out, it's not much of a hassle at all!

You can do something like I did here:

# as root
cd /var/lib/container/
mkdir plex
debootstrap --arch amd64 vivid plex

# Set the root password for later
systemd-nspawn --directory plex

# Now you should be at a root prompt inside the container!
# and you can enter a new password.

Now you hold Ctrl and hit ] three times, and it'll kill the container host process.

# assuming you already have a bridge set up for your NIC and it's named lxcbr0:
systemd-nspawn --network-bridge=lxcbr0 --boot --directory plex

That'll get you a fresh minimal Ubuntu Vivid installation, perfect for installing Plex. You can safely ignore the systemd-journald errors on the first boot; updating to the latest packages will fix the errors.

You'll need to bring up the network inside the VM, so log in as root using the password you just set, and run:

dhclient host0

Then add the vivid-updates repo, and upgrade to the latest packages to fix the journald errors from vivid's starting state:

echo 'deb vivid-updates main' > /etc/apt/sources.list.d/vivid-updates.list
apt-get update && apt-get dist-upgrade

Now you're up to date. Let's add the PlexPass repo and install Plex:

echo 'deb plexpass main' > /etc/apt/sources.list.d/plexmediaserver.list
apt-get update && apt-get install plexmediaserver

(If you don't have a Plex Pass, you can use the regular non-PlexPass repo, just substitute wheezy for plexpass in the above echo command. The wheezy name appears to be hilariously inaccurate, because it doesn't seem to even work on jessie anymore, but I digress.)

Now, hit Ctrl+]]] again, and stop the Plex server in the host, assuming it's on the same machine. You'll want to copy the Application Support folder from your existing Plex server (using these packages, the default location is in /var/lib/plexmediaserver/Library, but your OS may have it in a different place). Just make sure that you copy the Application Support folder into the /var/lib/container/plex/var/lib/plexmediaserver/Library on the host.

Look up the ID of the plex user inside the container. Mine didn't match between host and guest, so I ran:

grep plex plex/etc/passwd | sed -re 's;^plex:x:([0-9]+):([0-9]+):.*$;PLEXUID=\1 PLEXGID=\2;g'
chown -R {PLEXUID}:{PLEXGID} plex/var/lib/plexmediaserver

Now, you'll want to add some more arguments to your systemd-nspawn so that it can access your media library. My media is on ZFS in /tank/tv and /tank/movies so I used this command:

# assuming you're back in /var/lib/container on the host:
systemd-nspawn --network-bridge=lxcbr0 -bD plex --bind-ro=/tank/tv --bind-ro=/tank/movies

# once the container boots, log in as root again, and set up networking
# I did:
echo "auto host0\niface host0 inet dhcp" >> /etc/network/interfaces

# and then:
systemctl restart networking

Remember to add --bind-ro (or --bind, if you want Plex to be able to write to these files) for each separate filesystem you want visible inside the container.

And now you should have a working Plex running inside a container, on a separate IP address on your local network.

TL;DR Setting up Plex in a container doesn't take long at all, and separates Plex from the resources of the rest of your machine with almost no overhead.

PS: If you haven't already got a bridge for your main interface on the host machine, you can set one up like this, but be careful if you're doing it over SSH!

# as root on the host:
brctl create lxcbr0

# change eth0 to eth1 or em0 or whatever your NIC is called.
brctl addif lxcbr0 eth0 && dhclient lxcbr0

If you have a static IP for your NIC, then you should definitely use ifconfig or ip addr add to configure lxcbr0 in the second part above using the same configuration you previously had on your NIC. You'll want to update your host's /etc/network/interfaces if you're on Debian or Ubuntu on the host system. (Basically just s/eth0/lxcbr0/g on the whole file, and add a new line under the iface lxcbr0 inet <> line that looks like:

        bridge_ports eth0 # or whatever your NIC is


new design!

Still kicking the tires, and it's taken me a few hours of fiddling, but I've configured punch to spit out HTML for my blog. (Not sure if punch will be sticking around; I mostly wanted to see if I could get it to work, but magneto or pelican may end up being a better fit.)

The design is also shiny and new. I stole some ideas from John August's site, and I built this layout on top of Skeleton—I've gotten tired of seeing bootstrap everywhere, so I figured I'd try something new. The layout is fully responsive now; it should scale properly to phones, tablets, and even giant 30" displays, all without sacrificing readability.

Fonts for this design are Orbitron for the headers and NoticiaText for the body text.


<davej> so mountain dew have made a huge fuck up.
<davej> they marketed this drink to me as 'game fuel'. but it tastes distinctly like 'ass fuel'


<ajax> it's like kicking a puppy
<ajax> ... in that's it's really fun

announcing MobilePushr

When I first heard that the iPhone had a camera built-in, as well as WiFi, those two features triggered the following thought:

It would be really hot if you could upload the pictures from the camera directly to Flickr.

When I got my iPhone, I figured out a workflow that I could use to post pictures from the phone to my Flickr account, but it totally sucked balls was less than optimal. For each picture I wanted to upload, I had to open the picture in the Photos app and email it to a special address that Flickr had associated with my account.

Negatives of this approach? Impossible to use for more than a couple of images at a time, primarily, but also, annoyingly, the Mail app on the iPhone scales and recompresses the JPEG images before sending - and it strips them of their EXIF data, too.

So I was mildly displeased, but there was a way I could get it to work, kinda.

Then the iPhone got cracked wide open. People started figuring out how to write third-party apps and get them installed on their iPhones, and - to be honest - the UI for it, via, is - even though it's not from Apple - better than anything I've seen on any other mobile phone, ever.

The Friday before last (September 7th), I decided it was time to take matters into my own hands. Finally learn Objective C. Start writing my dedicated "Push all of the images in my Camera Roll to Flickr, right now dammit" application. And I got a pretty good start! Got the toolchain to build working iPhone apps, and that only took a few hours. Started reading through Flickr's API documentation. Started implementing some functions that didn't require authorization to call - learning how to use Flickr's REST API, basically. Once the first couple of unauthenticated calls worked and did what I expected, I knew it would only be a matter of time before I had my app working.

And then someone pointed me to iFlickr.

My first thought was "Dammit, somebody beat me to it." And I was a little depressed for a bit.

I downloaded it and tried to get it working. No offense to the iFlickr devs, but they clearly didn't put a lot of thought into the user experience (or if they did, I posit that their ideas about "good user experience" work completely differently from mine). I didn't end up getting it to work, but it's open-source, right?

Naturally, my next thought: "Well, I've been working on mine, and this doesn't really do what I wanted. But... maybe I can steal some of their code at least!"

And then I looked at the code.

My eyes still burn a little bit from that. That ... that was not a good idea. I've had much better ideas in the past.

I worked on this for the next few nights, realized that I could completely avoid the messy minitoken crap by using the "Desktop app" authentication mode from Flickr, deleted all of my code that dealt with mini-tokens, and the other night, I finally got it to actually upload pictures to my Flickr account. (My friend Cliff's help was so valuable as to be incalculable.)

I'll post more technical details later, but the important thing is: MobilePushr is out. The UI is going to get a lot of love in the next few days, because the current one doesn't provide nearly enough feedback, but as of right now, MobilePushr lets me do something that I've wanted for almost three months.

I can push my JPEGs directly from my iPhone to my Flickr account with the push of a single, giant red button. (And so can you! If you go download it and install it on your iPhone, that is. Assuming you have an iPhone.)

Also, of course, MobilePushr is Open Source / Free Software, released under the GPLv2. If you use git, you can look at my code by cloning git:// and poking around.

The really awesome thing about all of this is that, through Flickr, I can see how many people have given my app permission to link to their account, and in the first twelve hours alone over a thousand people have activated support for MobilePushr on their Flickr accounts.

I don't even have words to describe how awesome that makes me feel.


<ajax> i pick good days to go to olpc office
<ajax> free ice cream in the lobby
<keithp> ajax: winning
<keithp> ajax: where is it from?
<ajax> buckets?


<mjg59> daniels: You'd better be getting dolla dolla for this
<daniels> mjg59: well, euro euro, but yeah


<ajax> yum, well. let's not mention yum.
<clee> ajax: I thought you were making yum not suck.
<ajax> clee: i realized life was short and i wanted to work on something that stands the remotest chance in hell of getting me laid
<clee> ajax: I thought you already got guaranteed sex.
<ajax> HEY I MADE THE UPDATER FASTER: "eew, go away"
<davej> "Hey baby, want to see multiple graphic cards working at once? huh?"

they're gonna hunt me? for sport?

Can't really think of anything funny or clever to say about this; I had surgery for my hernia today, and it went well, I suppose. I survived, and now I have a surprisingly large incision which has been covered in superglue. It's going to form a bad-ass scar.

My surgeon prescribed vicodin and ibuprofen. I'm not entirely sure that either of those is helping me at all.

I was told before I went under the knife that the vicodin they were giving me was basically diazepam, which made me think of Metal Gear Solid, and I was happy. Visions of long, drawn-out boss fights with Sniper Wolf danced through my head. Unfortunately, it turns out that the nurse lied to me, and vicodin is not in fact diazepam.

Incidentally, I had my prescriptions filled at Target, because of their totally sweet ClearRx bottles. If you haven't heard of them, you should check out the story about why they're awesome.

Anyway. I'm alive, and that's something.