We will be performing plex.tv database server maintenance starting 22:00 Pacific Time on Wednesday, June 28 (05:00 GMT, June 29). It is expected to last ~1.5 hours. See http://status.plex.tv/incidents/c1t6djj5vq9r
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,731 Plex Team Member
edited 12:41AM in Linux

The Linux FAQ has become part of **Tips & Tricks **

Please bookmark this new location: https://forums.plex.tv/categories/linux-tips


  • ChuckPAChuckPA Members, Plex Pass, Plex Ninja, Plex Team Member Posts: 13,731 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,731 Plex Team Member
    edited June 25

    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
    Environment="PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/home/plex/Library/Application Support"
    UMask=0002    # this must be 4 digits of octal       

    INFO: It appears some systems want Umask while others want UMask. Please be cautious of this until fully resolved and noted here.

    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

    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

    Edit: 24-Jun-2017. Typo correction.

This discussion has been closed.