Plex “Not Enough Disk Space To Convert This Item”

If you have ever installed Plex on a default installation of Ubuntu, you might have noticed that Ubuntu doesn’t take up the entire disk space for the root (‘/’) partition. This is the reason Plex has the issue described in the title.

This is VERY annoying.

I was really struggling with this issue for a good couple of weeks. When I searched for this issue, none of the results were helpful.

What I had to do: Used a live CD of gparted to increase the space of the partition and then use lvm for the partition to extend into all the new free space.

So, steps below:

Shutdown and boot into GParted live CD/ISO

Startup the GUI and extend the partition you want to expand

Close the GUI and open the GParted Terminal

Enter the LVM manager using: sudo lvm

Extend the default ubuntu vg/ubuntu-lv partition to use all available space: lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

Now you can exit the LVM manager: exit

Finally, you can resize the system to use the newly sized partition: sudo resize2fs /dev/ubuntu-vg/ubuntu-lv

You can now use df -h and check that the system is using the entire space of the drive and the available partition.

You will now find that the root (‘/’) directory is no longer 99%/100% full and your media can play.

Enjoy!

Linux Directory Checking Script

Morning! Oh wait, it’s the afternoon…

Today, I finally got around to making a script that will run automatically on my network storage server (Raspberry Pi with a dinky USB hard drive) and check if the USB HDD is accessible.

This issue started a couple of weeks ago where I was getting weird IO errors on the USB disk about every 2 weeks. Instead of buying a new drive, creating a RAID array or anything else equally as intelligent and appropriate, I decided to just reboot my Raspberry Pi every time this happened. Now, I don’t want to do this manually every time so I finally created a script and added it to my cron jobs.

You can see the script I used below:

#!/bin/bash

if [ ! -d "path/to/check" ]; then
    #Directory is not found and HDD is not okay, do whatever is below
    uptime=$(uptime)
    currenttime=$(date)
    echo "Host rebooted at $currenttime. Uptime was$uptime" >> /path/to/output.txt
    sudo reboot
fi

My crontab job is running as root because the sudo reboot part was giving me a couple of issues. This is the entry in the root crontab:

@hourly /path/to/sh/file

Enjoy!

Swaks Email Scripting

Hi, in this blog post I will show you how I configured Swaks for sending emails using SMTP using my custom SMTP server.

First I ran the following command to install swaks:

sudo apt-get install swaks

With swaks installed, I could start building a test command just to
see if this would actually work. I started with the below command:

swaks --to destination@email.com --from source@email.com --auth --auth-user=source@email.com --auth-password=passwordforsource@email.comaccount --server smtp.example.com -tls

This gave me an error along the lines of “Could not authenticate – connection refused” after talking to the people hosting my SMTP server, I found out that I needed to make sure that I was using port 587 and not the default port of 465.

So I made sure that my command explicitly used that port by adding it to the server parameter and managed to get an email to successfully send. You can see the code I used below:

swaks --to destination@email.com --from source@email.com --auth --auth-user=source@email.com --auth-password=passwordforsource@email.comaccount --server smtp.example.com:587 -tls

Extra

I wanted to use this in a script so that I could launch the script and an email would get sent. I also wanted to change what would get sent in the actual email since currently, it was just using the default values.

After 5 or so minutes of cobbling a script together, I came up with what you can see below:

#!/bin/bash

hostname=$(hostname)
uptime=$(uptime)

swaks --to destination@email.com \
--from=source@email.com \
--auth \
--auth-user=source@email.com \
--auth-password=password-for-source-email \
--server smtp.example.com:587 \
--body "$hostname - uptime is $uptime" \
--header "Subject: $hostname is still up" \
-tls \

Now I can send this email whenever I want, I even created a CRON job to send the email every hour. Enjoy!