Gitea with Snap: unable to access removable drives

Hello, all. As title implies, I’ve installed Gitea v1.17.3 on an Ubuntu 22.04.1 LTS server via Snap. On the install page, I changed the repo and lfs directory to /media/<drive-name-here>/gitea/repo and /media/<drive-name-here>/gitea/lfs respectively. Their permissions are as follows:

$ pwd
/media/<drive-name-here>/gitea

$ sudo ls -l
total 0
drwxr-x--- 1 git git 0 Nov 21 05:15 lfs
drwxr-x--- 1 git git 0 Nov 21 04:21 repo

Despite setting the username to git, I would consistently get the notification, mkdir /media/<drive-name-here>/gitea/data failed: Permission denied. Just in case, I did run:

sudo snap connect gitea:removable-media

But this didn’t appear to help on install. For now, I’ve installed using the pre-filled variables (i.e. in the /var/snap/gitea/common/data directory), but I’m wondering what else I could do to make Gitea have permissions to create files in the /media mounted drives.

Also, how do I test if the removable-media permission actually worked? Do I edit /var/snap/gitea/common/conf/app.ini to the values below?

RUN_USER = git

[repository]
ROOT = /media/<drive-name-here>/gitea/repo

[lfs]
PATH = /media/<drive-name-here>/gitea/lfs

What is the output of ls -al in /media/<drive-name-here>/gitea? I suspect that folder is not owned by git:git or has incorrect permissions set, leading to Gitea being unable to create folders within it.

I am unfamiliar with snap, but it may also be AppArmor related if that is configured.

Sorry, was on vacation. Output looks like this:

$ ls -al /media/<drive-name-here>/gitea
total 16
drwxrwxr-x 1 <me> <me> 14 Nov 21 05:41 .
drwxr-xr-x 1 <me> <me> 86 Nov 21 04:20 ..
drwxr-x--- 1 git  git   0 Nov 21 05:15 lfs
drwxr-x--- 1 git  git   0 Nov 21 04:21 repo

No worries. Based on that output, Gitea running as git can’t create any files in that directory since your user owns it. A quick chown git:git /media/<drive-name-here>/gitea should fix that and allow Gitea to create the data folder.

Hmm, after changing folder permissions, then changing the app.ini to point to these folders, I must have done something wrong when restarting gitea, but gitea web doesn’t seem to be hosting anymore (I get an “Unable to connect” on Firefox.) I have also reverted the app.ini file back to its old settings, but it still had the same problem: I suspect it has nothing to do with changing the permissions on the gitea folder. I’ll try troubleshooting it for a while.