-->

hobby raspberry_pi, plex, media_server

Raspberry Pis these days are powerful computers that can run a lot of tasks at home with very efficient electricity usage. In this post I’m going to show how to use a Raspberry Pi 4 8GB as a Plex server and serve your own media files in your own network.

Hardware

  • Raspberry Pi 4 (8 GB)
  • Argon ONE case (with M.2 adapter)
  • M.2 SATA SSD (1TB)
  • Standard pi power supply

Getting Started

In this project I used an Argon ONE M.2 Case for Raspberry Pi 4 as it allowed me to use an SSD drive with the Pi which is a lot faster than a microSD card.

Argon ONE comes with a comprehensive used guide and take about 10 minutes to put everything together so it’s not too different than using a regular Pi case. The added benefits are:

  • You get to use a M.2 SATA SSD (Be mindful about the SATA here. It doesn’t work with NVMe SSDs even though it fits. So make sure to buy a M.2 SATA SSD)
  • You get 2 full-sized HDMI ports instead of the micro ones that come with a Pi 4

The final build looks like this with a 5-bay YottaMaster enclosure attached to it:

Software Installation

The easiest installation way I could find is downloading the Plex Media Server for Linux package from Plex Downloads Page

First choose Linux from the OS list

and click Choose Distribution

Once you’ve downloaded the installation package right click and select Package install

After the installation open http://localhost:32400/web and you’re ready to go!

Plex Account

I already had an account so I just logged in with my credentials. This automatically adds the new server to your account so you can see the libraries in other server instances in your account as well.

File Share

Because I attached a 5-bay hard drive enclosure to the Pi, I wanted to use it for a general file server as well. This also helps if your media files are located somewhere else on the network and you want to copy them over the network if you’re not able to attach the source drive directly to the Plex Server Pi.

To create the file server I followed this guide to install Samba on my Pi: Samba: Set up a Raspberry Pi as a File Server for your local network

Troubleshoot File Permission Issue

One issue I had when I tried to add some test folders was that Plex wasn’t able to list the folders in a selected drive. I found the solution here: Plex Media Server cannot see sub folders.. Permissions issue?

Basically added the permissions to the folders in the path as shown in the accepted answer:

sudo chmod a+rX /mnt
sudo chmod a+rX /mnt/sda
sudo chmod a+rX /mnt/sda/will

Client

I’m not going to go into much detail on the client side as there are a vast number of ways to consume content from a Plex Server. In my case, I’m using a Kodi on another Raspberry Pi and as soon as I added the new Plex Server to my Plex account I was able to view the content on my client Kodi Pi.

Conclusion

Overall it was quite straightforward as the server package came ready to install. The only issue I had was to figure out the folder permission issue and after that’s been resolved I was able to enjoy a brand new Plex Server instance in my own network. Hope this helps if you’re after similar results.

Resources

hobby raspberry_pi, productivity, dymo, labelwriter_450

I have a Dymo LabelWriter 450 for years and I love using it. Especially it worked a miracle recently when I organised all ny shelves and bagged and labelled everything. To have the ability of keeping the printer online all the time and print easily I decided to plug it in a Raspberry Pi and share over the network. The steps below explain how it can be done easily:

Step 01: Plug in the printer to the Pi via USB

Simply plug it in and power it on.

Step 02:

  • Click Pi -> Preferences -> Add / Remove Software
  • Search “dymo”
  • Tick the checkbox next to “printer driver for DYMO label printers”
  • Click Apply and wait for the installation to complete

Step 03: Configure printer

  • On the Pi itself, open a browser and go to “http://localhost:631”

  • Click Administration and Add Printer. In the username/password prompt, use the account you used to log in (most likely username “pi”)

  • You should see DYMO printer in the list of Local Printers

  • Change the name of the printer if you like and click Continue

  • Change the drivers if it’s incorrect and click Add Printer

  • Accept or modify the default options and click Set Default Options

  • Confirm the printer is listed in the printers list

Step 04: Share the printer

  • Click Pi -> Preferences -> Print Settings

  • From Printer menu select Shared to share it over the network

Step 05: Setup client machine

Option 1: Add network printer

  • Download and install DYMO software
  • Upon first run, application asks to run Add Network Printer Utility
  • Click Yes

For me, this method did work on one machine and did not work on another one. So for the other machine I used Option 2

Option 2: Add printer using OS’s add printer functionality

I used a Mac for this but should be similar on Windows.

  • Search for Printers & Scanners
  • Click + button
  • It should show the printer on the network:

Step 06: Test

Now that printer is recognized on the client machine, just design your labels and print using DYMO Label app.

Resources

aws ec2, migration

Recently I needed to migrate an EC2 instance to a different AWS account. There’s no built-in functionality to handle this. The solution is creating an AMI from the instance and sharing it with the target account. I scripted my solution with Powershell and AWS Tools for Powershell as below.

Prerequisites

Since the operation involves a source account and a target account, first create 2 profiles with EC2 access. credentials files should look like this

[source_profile]
aws_access_key_id = xxxxxxxxx
aws_secret_access_key = xxxxxxxxx

[target_profile]
aws_access_key_id = xxxxxxxxx
aws_secret_access_key = xxxxxxxxx

Step 00: Configuration

I put all the variables in a Powershell script file which I include in the following steps. To use the scripts you need to provide the values first. Hopefully the variable names are self-explanatory:

$sourceAccountAwsProfileName = ""
$sourceRegion = ""
$sourceAccountId = ""
$instanceId = ""
$amiName = ""
$amiDescription = ""
$targetAccountAwsProfileName = ""
$targetAccountId = ""
$targetRegion = ""

Step 01: Create AMI

First step to migrate EC2 instance is to create an AMi from the instance.

. .\"00. configuration.ps1"

# Create AMI
$imageId = New-EC2Image -InstanceId $instanceId -Name $amiName -Description $amiDescription -ProfileName $sourceAccountAwsProfileName -Region $sourceRegion

Set-Variable -Scope global -Name AMI_ID -Value $imageId
Write-Host "AMI_ID: [" $AMI_ID "]"

This operation takes a few minutes. The image has to become available before we can proceed to the next step.

Step 02: Share AMI

Now the image is ready we have to share it with the target account. The script below shares the AMI and allows new volumes created from this AMI.

. .\"00. configuration.ps1"

$imageId = Get-Variable AMI_ID -valueOnly
Edit-EC2ImageAttribute -ImageId $imageId -Attribute launchPermission -OperationType add -UserId $targetAccountId -ProfileName $sourceAccountAwsProfileName -Region $sourceRegion

$imageSnapshots = Get-EC2Snapshot -OwnerId $sourceAccountId -ProfileName $sourceAccountAwsProfileName -Region $sourceRegion
                | Where-Object {$_.Description -like "*$imageId*" }

foreach ($snapshot in $imageSnapshots) {
    Edit-EC2SnapshotAttribute -SnapshotId $snapshot.SnapshotId -Attribute createVolumePermission -OperationType add -UserId $targetAccountId -ProfileName $sourceAccountAwsProfileName -Region $sourceRegion
}

Step 03: Copy AMI

At this point, if you go to the target account you should be able to see the image when you choose “Private images” category. Make sure to choose the same region as the source account to be able to see the image.

We have access to this image but we want to have our own copy which we accomplish with the script below:

. .\"00. configuration.ps1"

$imageId = Get-Variable AMI_ID -valueOnly
Copy-EC2Image -SourceImageId $imageId -SourceRegion $sourceRegion -Name $amiName -ProfileName $targetAccountAwsProfileName -Region $targetRegion

In my experience the whole copying process took about 5 minutes.

Now that we have our own copy of the AMI we can launch instances as we please. Job (almost) done!

Step 04: Clean Up

Final step is to clean up after ourselves. Since this AMI was created to migrate to the new account only I assume we won’t need it anymore in the source account. The following script deregisters the AMI and deletes all the associated snapshots.

. .\"00. configuration.ps1"

# Create image script writes the AMI ID to a variable. If it doesn't exist get the image id from AWS Management Console
$imageId = Get-Variable AMI_ID -valueOnly

Write-Host "Unregistering image: [" $imageId "]"
Unregister-EC2Image -ImageId $imageId -ProfileName $sourceAccountAwsProfileName -Region $sourceRegion

$imageSnapshots = Get-EC2Snapshot -OwnerId $sourceAccountId -ProfileName $sourceAccountAwsProfileName -Region $sourceRegion
                | Where-Object {$_.Description -like "*$imageId*" }

foreach ($snapshot in $imageSnapshots) {
    Write-Host "Removing snapshot: [" $snapshot.SnapshotId "]"
    Remove-EC2Snapshot -SnapshotId $snapshot.SnapshotId -Force -ProfileName $sourceAccountAwsProfileName -Region $sourceRegion
}

# Delete variable
Remove-Variable AMI_ID -Scope global

Resources