Raspberry Pi Ubuntu Server

Ever since the launch of the Raspberry Pi I’ve been a fan. I’ve bought and been gifted many of them over time. It reminds me a little of the NSLU2 (slug), but builds on the amazing hardware advancements driven by smartphones.

I recently bought my first RPi4 – the base model 2Gb version. BuyAPi.ca is local, but I had it shipped. Great prices, and my order was prepped and shipped within 3hrs of submitting it. Even via regular mail, it showed up quickly (days).

What I bought:

I have plenty of micro-sd cards around so there was no need to get another.

The Pi ships in a very cute little box.

The first thing I did was to install the heatsinks. I had to visit the web page to figure out where to put them on the board. Peeling the plastic off the adhesive tape was a little tricky, but a sharp knife blade helped me get under the edge.

There are several choices for the OS to run, and for many of my previous projects I’ve stuck with Raspbian (now known as the Raspberry Pi OS). Since my intended use for this Pi is to run it as a server hosting Pi-hole, I opted to go with Ubuntu server.

Downloading and flashing the image file to the sd-card was straight forward. I connected the Rpi4 to wired ethernet and power, and booted right after the card was flashed. By visiting my main router I could see the DHCP address that the Pi had been given.

By default – the device shows up as hostname ‘ubuntu’ and the default user is ‘ubuntu’. You can ssh directly to the machine, and on first login you are forced to change the password. The password policy requires non-trivial passwords, so it’s not a bad solution to getting going.

At this point I no longer need to access the device physically (or at least very often). I drilled some holes in a bit of wood to accept the brass stand-offs, then mounted the Pi to the stand offs. This let me mount the whole thing to the wall along side my other infrastructure bits (router, modem, voip box, switch).

Based on my server configuration post – I want the new Rpi4 server to be similarly set up.

Stuff I want to do:

  1. Change the username
  2. Change the hostname
  3. Configure automatic updates
  4. Forward email
  5. Fix timezone
  6. Redirect logs
  7. Install Prometheus monitoring

The rest of this post is the details on those steps.

Continue reading “Raspberry Pi Ubuntu Server”

Correct Playlist – Segment Map for Bluray

Before streaming was the primary way to get new content, I collected a lot of movies on DVD / bluray. I still have a large collection, but have been slowly converting it to be hosted on my Plex server. This gives me a Netflix like viewing experience, but for my own personal movie collection.

Handbrake is great for dealing with DVDs. MakeMKV is how I rip bluray disks, then feed the resulting rip into Handbrake to compress it down. I do all of this on my Ubuntu system.

Generally this works really well. Handbrake will automatically select the longest video, and that’s almost always the actual movie itself. With MakeMKV that selection is more manual, but picking 1 title from a list of 10 isn’t all that hard.

When I got to the Hunger Games series, things got a bit more interesting. Starting with Catching Fire the bluray shows you 100’s of feature length titles – all the same duration, but with different segment maps. It seems that all but one of these titles has things shuffled in the wrong order.

Initially I naively picked the 1st and used that one, but upon watching the movie it was obvious there was 1 scene out of place, and thus two weird jump cuts to the flow of the movie. Enough to be annoying.

If you got digging around, you can find advice on which of the many to pick from the list. It turns out that there are multiple versions of the movie: rental, US release, Canadian release, etc. It’s much better to figure it out for the disk you have. The MakeMKV forum has a post about using PowerDVD and Process monitor to figure this out. I struck out here as I didn’t have a Windows machine with the right software combination, and it seems I wasn’t able to get Ubuntu to natively play back a bluray either.

Recently I came across a way to use MakeMKV to do the full process, again thanks to a MakeMKV forum post.

    1. Use MakeMKV to back up the full disk.
    2. Use MakeMKVcon to dump info to a text file

    3. Isolate the segment lists from /tmp/xx.txt. It turns out that “,26,” is unique enough to grab all of the segment lists. For Mockingjay Part 1 there are 550 segment lists on the disk, 519 of these are the length of the movie.

    4. Observations:
      a) All the movie length lists start with the same segment: 519
      b) It seems they all end with 520
      c) There are only 20 chunks in each segment list, and we already know 2 of them. Only 18 to sort into order correctly
      d) The MakeMVK backup has all of the chunks in backup/<disk>/BDMV/STREAM/
    5. Now we just need to play a copy of the movie, I have the DVD as well so VLC can play that back for me. Start at the first chunk, verify it is the start, watch the end to determine the scene break. Then figure out what the next chunk is.
      By building an incrementally specific grep, I can figure out the next chunk options. It is fewer choices than you might imagine. Each one had 2-4 possibilities.
      Hint: as you identify chunks, record the duration – this helps figure out where on the DVD playback you need to review to find the scene break.
    6. Once we identify the correct chunk order – we can go back to MakeMKV and rip the correct stream. A web search can also help verify which one is the right one, as I did for Mockingjay Part 1.

It took me about 35mins to get through step 5, much shorter than watching the whole movie. During the course of the chunk identification, I came across 3 where I had no choice, the only next chunk was the same one. After walking through 12 chunks, I hit a point where there was only 1 segment list left. I quickly verified the segment end/start matches and then double checked against the web search.

Docker and macvlan networking (IPv4)

Docker is the well known spin on Linux containers (LXC), if you’re not already playing with containers it’s probably time to jump in and get familiar. I’ve been (very slowly) migrating my personal infrastructure over to a container centric setup.

For me, containers are really nice for managing the set of software dependencies needed to run any particular application. It allows me to keep my RSS feed reader up to date, and avoids me breaking something my WordPress install needs or vice versa. Containers are a light weight virtualization.

The default networking model (default bridge) allows you to easily expose (map) a set of ports from the container, onto the host. This makes it easy to host an nginx container as your webserver on port 80.

Docker does some interesting network tricks to keep things more secure, but this gets problematic too. Containers can’t easily see the host they are on, making it difficult for container A to see container B’s port on the host – however, you can put both containers on the same docker network to allow them to see each other. This is a subject for another blog post entirely.

The macvlan support in docker is very cool. It allows you to provision a second IP address on the same network card, giving your docker container a full IP on the local network. In the world of virtual machines, similar macvlan support is available, and when you want to treat a docker container like a mini-VM, this is very useful.

Continue reading “Docker and macvlan networking (IPv4)”