Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

Linux FAQ

ChuckPAChuckPA Members, Plex Pass, Plex Ninja, Plex Team Member Posts: 13,128 Plex Team Member
edited May 16 in Linux

This will grow with Tips & tricks as well as ways to help us help you. Linux uses a lot of special characters the forum is sensitive (markdown formatting) to. We need to accommodate for those. Here are some basic things:

Copy/paste of command line text or XML

Answer: There are 4 easy ways:

A. Surround the single line command with the grave character.
results in This is how it looks when you've typing it

B. Surround a block of text with triple grave

Becomes:

This is
a
multi-line

C. After you copy/paste the text, use 'Code' paragraph formatting and mark the entire selected block of text . You will see it indent.

D. Use something like Gnone-Screenshot (used here to make these graphics) for little graphic-inclusive items. Use the 'picture attach' feature above or drag & drop the image. Allow it ample time to upload and resolve to a 'link' in the thread (you'll see it when done)

Comments

  • ChuckPAChuckPA Members, Plex Pass, Plex Ninja, Plex Team Member Posts: 13,128 Plex Team Member
    edited May 17

    Manually Optimizing the Database using CURL and SQLite3

    If you can't get to the UI because it times out (your database is really fragmented). This will allow you to invoke database optimization.

    Manual CLI/curl Database Optimization with PMS running

    #!/bin/sh
    
    # Get the contents of the Preferences file, keep only what we need,  push to a temp, then use it in the curl command
    
    # you may remove the sudo if not needed to read your Preferences.xml
    
    cat "/home/plexdir/Library/Application Support/Plex Media Server/Preferences.xml" |  \
    sed -e 's;^.* PlexOnlineToken=";;' | sed -e 's;".*$;;' | tail -1 > /tmp/plex.tmp
    
    curl --request PUT http://127.0.0.1:32400/library/optimize\?async=1\&X-Plex-Token=`cat /tmp/plex.tmp`
    
    rm -f /tmp/plex.tmp
    

    Manual shell/sqlite3 Database Optimization with PMS stopped

    This is an advanced method for those who are comfortable with using the shell and direct hands-on of the DB.

    sudo sh
    
    service plexmediaserver stop
    cd "/var/lib/plexmediaserver/library/Application Support/Plex Media Server/Plug-in Support/Databases"
    
    mv com.plexapp.plugins.library.db com.plexapp.plugins.library.prev.db
    rm com.plexapp.plugins.library.db-???
    
    sqlite3 com.plexapp.plugins.library.prev.db .dump > dbdump.sql
    sqlite3 com.plexapp.plugins.library.db < dbdump.sql
    chown plex:plex com.plexapp.plugins.library.db
    
    service plexmedia server start
    

    Note: You will still need to perform Empty-Trash and Clean-Bundles as normal regardless of technique

  • ChuckPAChuckPA Members, Plex Pass, Plex Ninja, Plex Team Member Posts: 13,128 Plex Team Member
    edited May 16

    Mounting external NTFS / EXT drives in Linux

    This interim document shows you how to mount your external drives

    The forum does not allow uploading PDFs so is linked here .

    https://drive.google.com/open?id=0B57qR6p2QjXpY0RFc0FXVHhud3M

    After the drives are mounted at their new location, should you like a nice bookmark in the left panel of your File Manager, the "Bookmark this location" is under the cog in the upper right corner.

  • ChuckPAChuckPA Members, Plex Pass, Plex Ninja, Plex Team Member Posts: 13,128 Plex Team Member
    edited May 6

    Header Compression in MKV files

    If you encounter any issues with header compression in MKV files, this little script will tell you which files in the current directory are using it.

    IFS=$'\n'; for infile in `find . -name "*.mkv"` ;  do uses_compression=$(mkvinfo "$infile" | grep "header removal"); if [ -n "$uses_compression" ]; then echo $infile; fi; done
    

    Obviously the script can be expanded and mkvmerge invoked to remux without header compression.

    PMS has gotten much better at detecting this but may not catch all cases (AFAIK)/

  • ChuckPAChuckPA Members, Plex Pass, Plex Ninja, Plex Team Member Posts: 13,128 Plex Team Member
    edited May 16

    Changing PMS's runtime configuration and/or Relocating Plex's Library

    If you wish/need to relocate /var/lib/plexmediaserver from it's default location, you have several options.

    This procedure is intended for those which use Systemd. Verify this by executing cat /proc/1/comm at the command line. If it returns systemd you can use this procedure.

    On systems which use Systemd (Ubuntu 16+, Fedora, Centos 7, Debian 8,) you create a customization file which SystemD reads prior to launching PMS. This file is independent of the default configuration and service control mechanisms in /lib/systemd/system/plexmediaserver.service. The Plex-supplied service definition should not be modified as any changes are subject to overwriting at every update.

    The task, with PMS stopped, is:

    1. Create the 'override' file
    2. Move the files to their new location
    3. Change ownership if needed
    4. Inform systemd of the changes
    5. Start PMS

    In the example below, the following will be shown. Tailor to your environment as needed

    a) Run as user chuck:spacecadet
    b) Move the metadata (Library) to /home/plex for the extra space
    c) Relax the default file-creation permissions (for plug-ins, etc)

    The following steps must be done as root, elevate first and get a full shell to work in
    sudo sh

    Begin here:

    A. Create /etc/systemd/system/plexmediaserver.service.d/override.conf containing the following

    #
    # Customize Plex's config
    [Service]
    Environment="PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/home/plex/Library/Application Support"
    #
    #
    User=chuck
    Group=spacecadet
    #
    Umask=0002    # this must be 4 digits of octal
    

    B. Now copy the existing library. (Resolve errors before deleting the original copy of your library)

    mkdir  /home/plex
    
    cd /var/lib/plexmediaserver
    tar cf - ./Library | (cd /home/plex ; tar xf -)   # this will take some time
    cd /home/plex
    
    # now change ownership
    cd /home/plex
    chown -R chuck:spacecadet . 
    

    C. Inform SystemD of the changes and test the related & reconfigured PMS

    systemctl daemon-reload
    systemctl start plexmediaserver
    

    D. Test your system. Verify everything is exactly as it was. If not, resolve before proceeding

    http://127.0.0.1:32400/web
    

    E. Delete the old library in /var

    rm -rf  /var/lib/plexmediaserver/Library &         # this can safely go into the background
    

    Once you have created the override file, you can later edit it with systemctl edit plexmediaserver

This discussion has been closed.