Ubuntu mdadm array can't use for optimized versions

Hi All,

I’m new to Plex and new to the forums. I’ve installed Plex on an Ubuntu 16.04 server that has an mdadm mounted array. I have created libraries for all my media fine. However, I can’t get optimized versions to save on the array. Whenever I try I get the error message “Converted files cannot be written to the disk”

Here is my log of the issue:
Nov 26, 2016 20:33:51.427 [0xa83fcb40] DEBUG - MDE: analyzing media item 54
Nov 26, 2016 20:33:51.427 [0xa83fcb40] DEBUG - MDE: Stick Man (2016): no direct play video profile exists for http/mpegts/h264
Nov 26, 2016 20:33:51.427 [0xa83fcb40] DEBUG - MDE: Stick Man (2016): no direct play video profile exists for http/mpegts/h264/ac3
Nov 26, 2016 20:33:51.427 [0xa83fcb40] DEBUG - MDE: Stick Man (2016): non-selected embedded subtitle stream 14900 cannot be direct-played
Nov 26, 2016 20:33:51.427 [0xa83fcb40] DEBUG - Stick Man - video.hasScalingMatrix limitation applies: 1 == 1
Nov 26, 2016 20:33:51.427 [0xa83fcb40] DEBUG - Stick Man - video.hasScalingMatrix limitation applies: 1 == 1
Nov 26, 2016 20:33:51.427 [0xa83fcb40] DEBUG - MDE: Stick Man (2016): no remuxable profile found, so video stream will be transcoded
Nov 26, 2016 20:33:51.427 [0xa83fcb40] DEBUG - Stick Man - video.hasScalingMatrix limitation applies: 1 == 1
Nov 26, 2016 20:33:51.427 [0xa83fcb40] DEBUG - MDE: computed resolution bounding box of 1280x720.
Nov 26, 2016 20:33:51.427 [0xa83fcb40] DEBUG - Scaled up video bitrate to 4711Kbps based on 1.500000x fudge factor.
Nov 26, 2016 20:33:51.427 [0xa83fcb40] DEBUG - Scaled maximum bitrate for resolution reduction to 2093Kbps.
Nov 26, 2016 20:33:51.427 [0xa83fcb40] DEBUG - MDE: Stick Man (2016): selected media 0 / 54
Nov 26, 2016 20:33:51.428 [0xa83fcb40] DEBUG - Versions: version file path is /media/media/plexoptimized/Plex Versions/Optimized for Mobile/Stick Man (2016).mp4
Nov 26, 2016 20:33:51.430 [0xa83fcb40] ERROR - Error creating directory /media/media/plexoptimized/Plex Versions/Optimized for Mobile: boost::filesystem::create_directories: Permission denied: “/media/media/plexoptimized/Plex Versions”
Nov 26, 2016 20:33:51.430 [0xa83fcb40] ERROR - TranscodeJobManager: [Running] directory is not writable: /media/media/plexoptimized/Plex Versions/Optimized for Mobile

Here is the user plex is running as:
plex 1168 0.0 0.0 2368 576 ? Ss 20:29 0:00 /bin/sh -c LD_LIBRARY_PATH=/usr/lib/plexmediaserver /usr/lib/plexmediaserver/Plex\ Media\ Server

Here are the permissions on /media/media/plexoptimized:
media@media:/media/media$ ls -lah plexoptimised/
total 8.0K
drwxrwxr-x 2 plex plex 4.0K Nov 26 20:45 .
drwxr-xr-x 15 media media 4.0K Nov 26 18:07 …

Here is how the raid array is configured in /etc/mdadm/mdadm.conf (changed mode from 0660 to 0775 while troubleshooting without success):
CREATE owner=root group=disk mode=0775 auto=yes

Here is how the array is mounted in /etc/fstab:
/dev/md0 /media/media ext4 defaults 0 0

I can create directories and files from the shell as user “plex”:
plex@media:/media/media/plexoptimised$ touch test
plex@media:/media/media/plexoptimised$ mkdir dirtest
plex@media:/media/media/plexoptimised$ ls -lah
total 12K
drwxrwxr-x 3 plex plex 4.0K Nov 26 20:49 .
drwxr-xr-x 15 media media 4.0K Nov 26 18:07 …
drwxrwxr-x 2 plex plex 4.0K Nov 26 20:49 dirtest
-rw-rw-r-- 1 plex plex 0 Nov 26 20:48 test

If I set the optimized directory to be on my local SSD rather than the mounted raid array, the files are created fine.

Any pointers on what is wrong here?

Thanks,
Ben

Make certain /media/media hasn’t been automounted by the Gnome desktop manager (Nautilus). When this happens, your username is given exclusive access and PMS is excluded regardless of file /directory permissions. The resolution for this is to create /etc/fstab entry to mount the file system at system boot and before both PMS and Gnome session-manager start.

Thanks ChuckPa. I’m not using a desktop manager, I have this as a headless setup - although I believe it is the desktop version of Ubuntu rather than the Server version.

The array is currently mounted in /etc/fstab at system boot.

The bit I don’t understand is that if I su to user plex, I can create files and directories in the exact locations that Plex is having the permissions error.

I even added Plex to the group “media” which is what I used to commission the array and that owns the rest of the file structure, this still didn’t help.

I also tried giving user plex in group plex 777 permissions to the folder with no joy. I suspect there is a subtlety in how the array is being mounted and that plex is giving a generic permissions error when it might be something a bit more specific.

This is my whole /etc/fstab

'# /etc/fstab: static file system information.
'#
'# Use ‘blkid’ to print the universally unique identifier for a
'# device; this may be used with UUID= as a more robust way to name devices
'# that works even if disks are added and removed. See fstab(5).
'#
'#
/dev/mapper/ubuntu–vg-root / ext4 errors=remount-ro 0 1
'# /boot was on /dev/sda1 during installation
UUID=35407687-39dd-4500-aec4-1339e1b57f6f /boot ext2 defaults 0 2
/dev/mapper/ubuntu–vg-swap_1 none swap sw 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
/dev/sr0 /media/floppy1 auto rw,user,noauto,exec,utf8 0 0
/dev/md0 /media/media ext4 defaults 0 0

What does the output of mount show?

What does the output of find /media/media -type d -exec ls -ld {} \; show?

Thanks MacGriogair.

media@media:/media/media$ mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=880428k,nr_inodes=209908,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=179972k,mode=755)
/dev/mapper/ubuntu–vg-root on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (rw,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset,clone_children)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event,release_agent=/run/cgmanager/agents/cgm-release-agent.perf_event)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids,release_agent=/run/cgmanager/agents/cgm-release-agent.pids)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb,release_agent=/run/cgmanager/agents/cgm-release-agent.hugetlb)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=28,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
/dev/sdb1 on /boot type ext2 (rw,relatime,block_validity,barrier,user_xattr,acl)
/dev/md0 on /media/media type ext4 (rw,relatime,stripe=32,data=ordered)
cgmfs on /run/cgmanager/fs type tmpfs (rw,relatime,size=100k,mode=755)
tmpfs on /run/user/112 type tmpfs (rw,nosuid,nodev,relatime,size=179972k,mode=700,uid=112,gid=118)
gvfsd-fuse on /run/user/112/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=112,group_id=118)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=179972k,mode=700,uid=1000,gid=1000)

The output of the second command generates thousands of lines. Its a 14TB array mostly full. I added the folder that I’ve got configured for transcoding to limit the output:

media@media:/media/media$ find /media/media/plexoptimised/ -type d -exec ls -ld {} ;
drwxrwxr-x 3 plex plex 4096 Nov 26 20:49 /media/media/plexoptimised/
drwxrwxr-x 2 plex plex 4096 Nov 26 20:49 /media/media/plexoptimised/dirtest

In case its relevant here is some other output showing a few folders within the movies library. Plex will happily build a library from this.

media@media:/media/media$ find /media/media/movies/ -type d -exec ls -ld {} ;
drwxr-xr-x 509 media media 28672 Nov 19 14:58 /media/media/movies/
drwxr-xr-x 2 media media 4096 Jan 11 2014 /media/media/movies/Scott.Pilgrim.vs.The.World.2010
drwxr-xr-x 2 media media 4096 Feb 16 2014 /media/media/movies/Little.Voice.1998
drwxr-xr-x 2 media media 4096 May 14 2014 /media/media/movies/Jack.Ryan.Shadow.Recruit.2014

(It’s much easier if you wrap the output in code tags)

What about ls -ld "/media/media/plexoptimized/Plex Versions"?

Ha - yeah, new to the forum, tried to use the code tags and got some weird output. Will try again!

media@media:/media/media$ ls -ld "/media/media/plexoptimized/Plex Versions" ls: cannot access '/media/media/plexoptimized/Plex Versions': No such file or directory

It never got as far as creating that directory

Check your plex settings to see if you’ve chosen that directory for Optimised versions. If you have, try creating that directory and setting the owner to plex :wink:

Thanks MacGriogair.

Sadly, I’ve tried that already. I created the folders “Plex Versions” and inside that “Optimized for Mobile” and then did a sudo chown -R plex:plex and sudo chmod -R 755 "Plex Versions"

Generates the same error unfortunately.

Here is the folder structure
plex@media:/media/media/plexoptimised$ ls -lah total 12K drwxrwxr-x 3 plex plex 4.0K Nov 27 18:59 . drwxr-xr-x 15 media media 4.0K Nov 26 18:07 .. drwxr-xr-x 3 plex plex 4.0K Nov 27 18:52 Plex Versions plex@media:/media/media/plexoptimised$ cd Plex\ Versions/ plex@media:/media/media/plexoptimised/Plex Versions$ ls -lah total 12K drwxr-xr-x 3 plex plex 4.0K Nov 27 18:52 . drwxrwxr-x 3 plex plex 4.0K Nov 27 18:59 .. drwxr-xr-x 2 plex plex 4.0K Nov 27 18:52 Optimized for Mobile

Here is the log after attempting optimized version:

Nov 27, 2016 18:57:37.018 [0x973ffb40] DEBUG - Versions: version file path is /media/media/plexoptimized/Plex Versions/Optimized for Mobile/Finding Nemo (2003).mp4 Nov 27, 2016 18:57:37.021 [0x973ffb40] ERROR - Error creating directory /media/media/plexoptimized/Plex Versions/Optimized for Mobile: boost::filesystem::create_directories: Permission denied: "/media/media/plexoptimized/Plex Versions" Nov 27, 2016 18:57:37.021 [0x973ffb40] ERROR - TranscodeJobManager: [Running] directory is not writable: /media/media/plexoptimized/Plex Versions/Optimized for Mobile Nov 27, 2016 18:57:37.021 [0x973ffb40] DEBUG - BPQ: setOverrideState for generator 119: failed/diskUnwritable

Everything you folks are trying here, coupled with the results you’re getting, lead me to believe Ubuntu has gone so far as to make /media a reserved directory regardless of the desktop manager or not.

For sake of testing & verification, create a new directory, e.g /raid, as root with directory permissions 0755. Mount /dev/md0 on /raid in /etc/fstab as you would any normal mount.

Once mounted, create /raid/plex, owned by plex:plex.

Point PMS at /raid/plex and let it do its thing.

Bingo!

That works a charm. Very odd.

Thanks very much ChuckPa and MacGriogair for helping to get to the bottom of this one.

Now please excuse me, I have a bunch of Samba and network scripts to update with new paths!

Then it is confirmed?

Ubuntu now claims exclusive access to /media whether Desktop or Server (headless). Interesting. I will note this for all.

Yes - once mounted on /raid, PMS is able to write to folders created below that path that have plex:plex ownership.