# Optimize unable to write to disk

**URL:** https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599
**Category:** Plex Media Server
**Tags:** server-linux, server-docker
**Created:** [March 12, 2021, 4:44pm UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599 "2021-03-12T16:44:53Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![keabro](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@keabro](https://forums.plex.tv/u/keabro)
#### Post date: [March 12, 2021, 4:44pm UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/1 "2021-03-12T16:44:53Z")

</div>

Server Version#: 1.22.0.4163  
Player Version#: 4.53.0  
I’m having trouble getting plex to be able to write optimized files to disk. I followed this guide for permissions [https://forums.plex.tv/t/automating-linux-permissions-using-inheritance-helps-dvr/198011](https://forums.plex.tv/t/automating-linux-permissions-using-inheritance-helps-dvr/198011)  
I’m running plex in a docker container with the same UID and GID as my plex user:group on linux. plex owns the folder and permissions are set to 775 yet when I try to optimize a file it states can’t write to disk. If I change permissions to 777 then it works. I think it’s some permission issue with the docker container. The container umask is set to 002 as well and rw has been added to each volume mapping. I’m entirely lost at this point. Any help would be appreciated. Also I can’t find any errors in the plex logs. Maybe I’m looking in the wrong place.

---

<div class="post-metadata">

### Author: ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)
#### Post date: [March 12, 2021, 5:18pm UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/2 "2021-03-12T17:18:23Z")

</div>

Can you provide the DEBUG log files which capture this happening please ?

---

<div class="post-metadata">

### Author: ![keabro](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@keabro](https://forums.plex.tv/u/keabro)
#### Post date: [March 12, 2021, 5:57pm UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/3 "2021-03-12T17:57:38Z")

</div>

Here is the associated section. I can post the entire file if you want it. So it is a permission issue I just don’t understand what is wrong with the permissions.

“Mar 12, 2021 10:40:20.670 [0x7fb644b8f700] DEBUG - MDE: Avengers: Age of Ultron (2015): selected media 0 / 1784513  
Mar 12, 2021 10:40:20.671 [0x7fb644b8f700] DEBUG - Versions: version file path is “/data/Movies/Avengers Age of Ultron (2015)/Plex Versions/Optimized for Mobile/Avengers\_ Age of Ultron (2015).mp4”  
Mar 12, 2021 10:40:20.672 [0x7fb644b8f700] ERROR - Error creating directory “/data/Movies/Avengers Age of Ultron (2015)/Plex Versions/Optimized for Mobile”: Permission denied  
Mar 12, 2021 10:40:20.672 [0x7fb644b8f700] ERROR - TranscodeJobManager: [Running] directory is not writable: “/data/Movies/Avengers Age of Ultron (2015)/Plex Versions/Optimized for Mobile”  
Mar 12, 2021 10:40:20.672 [0x7fb644b8f700] DEBUG - BPQ: setOverrideState for generator 8601: failed/diskUnwritable  
Mar 12, 2021 10:40:20.673 [0x7fb644b8f700] DEBUG - BPQ: generator 8601 changed state: pending → failed  
Mar 12, 2021 10:40:20.673 [0x7fb644b8f700] DEBUG - BPQ: reprocessing requested while processing item  
Mar 12, 2021 10:40:20.673 [0x7fb644b8f700] DEBUG - BPQ: onConsiderProcessing: Processing (true)  
Mar 12, 2021 10:40:20.673 [0x7fb644b8f700] DEBUG - Versions: updating status for generator 8601  
Mar 12, 2021 10:40:20.674 [0x7fb644b8f700] VERBOSE - Versions: generator 8601: failed/diskUnwritable with 0/0/0/1/0 item(s)”

---

<div class="post-metadata">

### Author: ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)
#### Post date: [March 12, 2021, 8:19pm UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/4 "2021-03-12T20:19:36Z")

</div>

can you jump into that shell,  
walking the path as the PLEX\_UID, PLEX\_GID user,  
and verify permissions at each level from `/data` → `Optimized for Mobile` ?

It’s complaining because it doesn’t have write access to when creating either “Plex Versions” or “Optimized for Mobile”.

---

<div class="post-metadata">

### Author: ![keabro](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@keabro](https://forums.plex.tv/u/keabro)
#### Post date: [March 12, 2021, 10:09pm UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/5 "2021-03-12T22:09:02Z")

</div>

Permissions are 775 from /data to Optimized for Mobile with 121 as the PLEX\_UID and 130 as the PLEX\_GID in the docker container which match Plex user and group id in linux of 121 and 130.  
Thank you for helping out it’s much appreciated!

---

<div class="post-metadata">

### Author: ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)
#### Post date: [March 12, 2021, 10:29pm UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/6 "2021-03-12T22:29:44Z")

</div>

Should have also mentioned…

With container stopped (not mounted),  
and with network share which is `/data` not mounted,  
what are the permissions?

I ask because a common issue is:

1. The Filesystem (after mounting) has the proper permissions.
2. The mount-point itself does not. Everything stops there.

Can you show me the directory perms? (ls -la of the mount point before & after)?

I’d like to check and verify the suid/sgid are properly tagged in the perms fields.  
(those will also bite when least expecting)

---

<div class="post-metadata">

### Author: ![keabro](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@keabro](https://forums.plex.tv/u/keabro)
#### Post date: [March 13, 2021, 4:38am UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/7 "2021-03-13T04:38:35Z")

</div>

I’m not entirely sure I understand. The folder that is mapped in plex docker to /data is /media1/Media. That folder when the container is down has the same permissions as when it is up attached is a screen shot. I took two and they are the same. Are you looking for something different than that?

 ![Screenshot 2021-03-12 at 9.33.52 PM](https://global.discourse-cdn.com/plex/original/3X/b/2/b21cf2e165808db422ae35b187767a869d72228c.png)

---

<div class="post-metadata">

### Author: ![keabro](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@keabro](https://forums.plex.tv/u/keabro)
#### Post date: [March 13, 2021, 5:04am UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/8 "2021-03-13T05:04:53Z")

</div>

Also checked on the fstab entry for mounting and it mounts with defaults which should include rw and suid.

---

<div class="post-metadata">

### Author: ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)
#### Post date: [March 13, 2021, 5:09am UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/9 "2021-03-13T05:09:27Z")

</div>

I’m not seeing / understanding what’s wrong here.

What you show me is correct.

It’s as if the container does not have RW permission.  
I don’t use docker enough – might it be mapped RO by default?

What I’m referring to occurs when:

1. `ls -la /somewhere/example` – has the read-only permissions
2. mount nas:/media /somewhere/example
3. `ls -la /somewhere/example` – shows the right permissions because we’re in the file system.

What linux will often do is cut you off at /somewhere or /somewhere/example – BEFORE – getting into the mounted (mapped) file system.

---

<div class="post-metadata">

### Author: ![keabro](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@keabro](https://forums.plex.tv/u/keabro)
#### Post date: [March 14, 2021, 6:59pm UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/10 "2021-03-14T18:59:55Z")

</div>

So I checked the containers write permissions by opening a shell inside the plex container. If I go to a movie folder I can mkdir and touch a text file inside the container so it doesn’t seem to be a container problem. Which makes it more weird because if the container can write then all the permissions are correct and it’s a plex issue?

---

<div class="post-metadata">

### Author: ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)
#### Post date: [March 15, 2021, 3:11pm UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/11 "2021-03-15T15:11:21Z")

</div>

Not likely Plex. This is a Linux permissions issue. The difficulty is in finding it.

Which media directories are the optimization target ?

Is UID 911 trying to optimize into “videos” or “tvshows” or any other directories with group “plex” ?

---

<div class="post-metadata">

### Author: ![keabro](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@keabro](https://forums.plex.tv/u/keabro)
#### Post date: [March 15, 2021, 3:52pm UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/12 "2021-03-15T15:52:09Z")

</div>

/media1/Media/Movies/“Movienamefolder”/“optimizedversions folder”/optimized.mp4  
That would be the directory that plex would use.  
I’ve tried to optimize a tv show as well and also change the optimized file location to see if it will work elsewhere and it has not. How do I check if UID 911 is doing that?

---

<div class="post-metadata">

### Author: ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)
#### Post date: [March 15, 2021, 3:53pm UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/13 "2021-03-15T15:53:22Z")

</div>

I got UID 911 from your screenshot 🙂

---

<div class="post-metadata">

### Author: ![keabro](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@keabro](https://forums.plex.tv/u/keabro)
#### Post date: [March 15, 2021, 3:54pm UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/14 "2021-03-15T15:54:27Z")

</div>

Dang you’re too fast. I just noticed that and changed my post haha. How do I check if UID 911 is doing that?

---

<div class="post-metadata">

### Author: ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)
#### Post date: [March 15, 2021, 3:55pm UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/15 "2021-03-15T15:55:47Z")

</div>

Is PMS in the container running as UID/GID 911?

I bet it is 😃

if that’s the case, either add it to the ‘plex’ group or change the GID of the container to be that of group ‘plex’ and then `setgid` bits will work – which is what you want?

---

<div class="post-metadata">

### Author: ![keabro](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@keabro](https://forums.plex.tv/u/keabro)
#### Post date: [March 15, 2021, 3:57pm UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/16 "2021-03-15T15:57:21Z")

</div>

How do I change the GID of the container? I thought I did that with docker compose setting PLEX\_GUID=130

---

<div class="post-metadata">

### Author: ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)
#### Post date: [March 15, 2021, 3:58pm UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/17 "2021-03-15T15:58:34Z")

</div>

Not `PLEX_GUID`. Use PLEX\_UID and PLEX\_GID

---

<div class="post-metadata">

### Author: ![keabro](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@keabro](https://forums.plex.tv/u/keabro)
#### Post date: [March 15, 2021, 4:17pm UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/18 "2021-03-15T16:17:13Z")

</div>

Sorry I actually have that correct in my docker compose. it is PLEX\_UID= and PLEX\_GID=

---

<div class="post-metadata">

### Author: ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)
#### Post date: [March 15, 2021, 4:20pm UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/19 "2021-03-15T16:20:11Z")

</div>

Want to make this really easy?

Set PLEX\_GID to that of Plex. It’s perfectly legal to use real Plex’s GID.

```auto
grep plex /etc/passwd | awk -F: '{print $4}'

```

---

<div class="post-metadata">

### Author: ![keabro](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@keabro](https://forums.plex.tv/u/keabro)
#### Post date: [March 15, 2021, 4:57pm UTC](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599/20 "2021-03-15T16:57:20Z")

</div>

the plex GID is set to 130 and is 130 on the host machine. the docker container however changes ownership of the plexdata config location to 911 I don’t really understand why. If I change ownership back to user:plex then plex will not show my library. Still narrows it down to docker permissions I think, but i’m completely lost as to why docker is using 911 instead of 1000:130

[Next page](https://forums.plex.tv/t/optimize-unable-to-write-to-disk/699599.md?page=2)
