Corrupt PLEX Database removal and rescan – TerraMaster TNAS

NAS: TerraMaster F2-221
TOS Version: 4.2.07-2012241608
Plex Version: 1.21.1.3842

I’m posting this as a ‘fix’ for issues relating to database corruption with a Plex install. The issue I had that my database was screwed and I could not locate the installation location to repair them. You can skip about in File Manager all you like but you’ll never find them.

Fine – I thought – I’ll just uninstall/reinstall the app and start again… but no – the underlying Plex app data seemed to be persistent and upon reinstall I saw my libraries remained with the same issues.

OK Then – I thought – I’ll simply just remove the library files and try again by going through the Plex interface… but no – the database corruption was such that I got a simple “I’m sorry, Dave. I’m afraid I can’t do that.” style message. The exact wording escapes me but it was something like “Unable to blah blah”.

Next was to look online and trawl through the forums! This was absolutely no help whatsoever although it did give me some ideas… there was some scary stuff about the Btrfs filesystem and how it’s not going to let you do anything unless to wipe the whole system, delete the volumes and start again. Eek – nope… too much data to do that – no way am I transferring 6TB of files to and fro EVERY TIME (because it will happen again) the DB goes t*ts up.

So yeah, at this point all I wanted to do now is nuke Plex from orbit, start fresh and rescan everything again… OK – it’ll take a wee while to scan everything [not nearly as long copying everything off and factory resetting the box though] but it’s the only way to be sure! The problem is how to go about that?!

My first clue was when I attempted to add a new library and was presented with a strange default start location for searching when I clicked “Browse for Media Folder” – this being:

/home/plex

This location appears to contain the subfolders:

Library 
tmp_transcoding

Ah… so – I drilled down into the Library folder to check that out. By the time I got to:

/home/plex/Library/Application Support/Plex Media Server

I figured that I had located the source.

WARNING – at this point you need to make sure that YOUR media files are not stored here. Pon my travels though the forums I saw sad tales of users you held reams of data locked up in an unknown Plex location; FYI – it’s here AND if it is here then you’ll have to move it out to another location. Come to think about it this is probably why Plex likes to persist its libraries etc when you uninstall. It’s trying to be ‘helpful’ by not removing your meda. Thanks.

So – yeah, the reason you can’t normally see this stuff is that upon install Plex sort of creates a hidden user called Plex and THAT is where it stores all its gear. Removing the app does not remove the user or any of the files that user has. Ya get me?

So to sort this mess out and nuke Plex then try these steps that worked for me – I don’t know if this is dangerous or not so please be careful with what you type.

  1. Stop Plex and uninstall it.
  2. Enable SSH on your TNAS (Control Panel->Terminal & SNMP->Telnet & SNMP)
  3. On your windows run a command prompt
  4. type: “ssh root@192.168.1.100 -p 9222” where 192.168.1.100 is the IP address of YOUR TNAS i.e. mine is @ 100 yours could be anything.
  5. Say “yes” if you get some blah warning about verification
  6. Type in your admin password
    At this point you’ll be in so navigate to the Plex user directory – type the command:
    “cd /home/plex”

WARNING - Before we go any further you should move all your media data to a public folder if it’s located here as we are going to remove it!

Anyway - you’ll probably just want to rename what’s in here to start with just in case – type the commands:

“mv Library LibraryBACKUP”
“mv tmp_transcoding tmp_transcodingBACKUP”

That’s it. Done.

Restart the NAS and reinstall the Plex app and then start it – you’ll have to wait a minute as it will rebuild its filesystem in the same location but it will be fresh, new and squeaky clean.

Hope it helps someone with the same problems I had.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.