File browser (DietPi) External HDD - permission denied when creating folder

Creating a bug report/issue

I have searched the existing open and closed issues

Required Information

DietPi version | cat /boot/dietpi/.version
G_DIETPI_VERSION_CORE=9
G_DIETPI_VERSION_SUB=5
G_DIETPI_VERSION_RC=1
G_GITBRANCH=‘master’
G_GITOWNER=‘MichaIng’
G_LIVE_PATCH_STATUS[0]=‘not applicable’

  • Distro version | bullseye
  • Kernel version | Linux DietPi 5.10.127-dietpi-x-lts #trunk SMP PREEMPT Wed Jun 29 09:26:01 UTC 2022 aarch64 GNU/Linux
  • Architecture | arm64
  • SBC model | `STBHG680P
  • Power supply used | (EG: 12V 1A RAVpower)
  • SD card used | (EG: SanDisk ultra)

Additional Information (if applicable)

  • Software title | (EG: Nextcloud)
  • Was the software title installed freshly or updated/migrated?
  • Can this issue be replicated on a fresh installation of DietPi?
    ← If you sent a “dietpi-bugreport”, please paste the ID here →
  • Bug report ID | echo $G_HW_UUID

Steps to reproduce

Expected behaviour

Actual behaviour

Extra details

Extra details

Jul 01 14:37:16 DietPi filebrowser[169527]: 2024/07/01 14:37:16 /dietpi_userdata/: 404 192.168.55.35 lstat /media/dietpi_userdata: no such file or directory
Jul 01 14:37:16 DietPi filebrowser[169527]: 2024/07/01 14:37:16 /dietpi_userdata/: 404 192.168.55.35 lstat /media/dietpi_userdata: no such file or directory
Jul 01 14:37:33 DietPi filebrowser[169527]: 2024/07/01 14:37:33 /tes/: 403 192.168.55.35 mkdir /media/tes: permission denied
  • this is the permission directory from external my storage drwxr-xr-x 6 root root 524288 Jul 1 13:09 media

/dietpi_userdata is at /mnt and not /media.

The default directory for filebrowser is /mnt, so you can not create folders outside of this directory with filebrowser, unless you change the default directory to e.g. /.
See:
https://dietpi.com/docs/software/cloud/#__tabbed_16_2

/opt/filebrowser/filebrowser config set -r /foo/bar/baz -d /mnt/dietpi_userdata/filebrowser/filebrowser.db

/opt/filebrowser/filebrowser config set -r /media -d /mnt/dietpi_userdata/filebrowser/filebrowser.db

whether by running the command above the default directory of the file browser has been changed,

I have tried but can’t create a folder

Did you stopthe service before modifying the config?

I also just saw, filebrowser uses the user dietpi, so you need do adjust the permissions of /media too.
See:
G_EXEC_DESC=“Setting up File Browser login user ‘dietpi’” G_EXEC /opt/filebrowser/filebrowser users add dietpi “$GLOBAL_PW” --perm.admin

yes sir

root@DietPi:~# systemctl stop filebrowser.service
root@DietPi:~# /opt/filebrowser/filebrowser config set -r /media -d /mnt/dietpi_userdata/filebrowser/filebrowser.db
2024/07/01 15:46:44 Using database: /mnt/dietpi_userdata/filebrowser/filebrowser.db
Sign up:          false
Create User Dir:  false
Auth method:      json
Shell:

Branding:
  Name:
  Files override:
  Disable external links:              false
  Disable used disk percentage graph:  false
  Color:
  Theme:

Server:
  Log:           stdout
  Port:          8084
  Base URL:
  Root:          /media
  Socket:
  Address:       0.0.0.0
  TLS Cert:
  TLS Key:
  Exec Enabled:  false

Defaults:
  Scope:         .
  Locale:        en
  View mode:     list
  Single Click:  false
  Commands:
  Sorting:
    By:   name
    Asc:  false
  Permissions:
    Admin:     false
    Execute:   true
    Create:    true
    Rename:    true
    Modify:    true
    Delete:    true
    Share:     true
    Download:  true

Auther configuration (raw):

{
  "recaptcha": null
}

I don’t understand sir
can you tell me how sir
I’m still a beginner at this

/media is owned by user root. Therefore root is the only one who is able to write to that directory.

Is /media just a directory or did you mount something on it?

Maybe the Red Hat descriptions can bring some clearity and help:

So here is a quick step-by-step guide:

  1. I created a folder /media/test.
    Initially it’s owned by root:root with the permissions 755 (only owner can write/read/execute, group and others can only read and execute).
root@TestPi3B:~# l /media/
total 4
drwxr-xr-x 2 root root 4096 Jul  1 17:36 test

  1. I changed the root of File Browser to this path
root@TestPi3B:~# systemctl stop filebrowser.service
root@TestPi3B:~# /opt/filebrowser/filebrowser config set -r /media/test -d /mnt/dietpi_userdata/filebrowser/filebrowser.db
root@TestPi3B:~# systemctl start filebrowser.service
  1. I am unable to create new files / folders because File Browser is using the user dietpi, which can not write to it.
    No we have two options:
  • Change ownership to dietpi:
    chown -R dietpi:dietpi /media/test
  • Change permissions, so everybody can write to it (this is what I did)
    chmod -R 777 /media/test/

That’s it,I can now create files (and directories) with File Browser in the location /media/test:

root@TestPi3B:~# cat /media/test/test2/joooo
it's working I guess
root@DietPi:/# chown -R dietpi-dietpi
chown: operand missing after `dietpi-dietpi'
Try 'chown --help' for more information.

The media folder is external storage (flash disk) exfat format

when I created a folder via terminal everything worked.
problem when creating a folder via the filebrowser web interface

I forgot in the guide to append the path. Of course you need to specify where you wanna change the ownsership.

This could also be the root of the problem, since exFAT does not support linux file system persmissions.
If the command above fails or does not help with your problem you would need to mount the drive with uid and gid for the user dietpi. (see https://manpages.debian.org/jessie/exfat-fuse/mount.exfat.8.en.html)

But I recommend to use ext4 file system instead of exFAT.

root@DietPi:/media# sudo chown -R dietpi:dietpi /media/DATA
chown: changing ownership of ‘/media/DATA’: Operation not permitted

Maybe the problem is with the flash disk

I think the problem is the exFAT filesystem. Do you really need to use exFAT?

You could try to mount it with other ownership, like I stated in my previous post.
For this you need to edit your fstab and change some things:

umount /media/DATA
nano /etc/fstab

Look for the entry for you USB stick and change uid and gid to

uid=dietpi,gid=dietpi

then mount the stick again

mount /media/DATA

it is, because exFAT is not supporting Linux file system permisson

what format is recommended ? sir

It worked but after rebooting it didn’t work again

[image]

Best would be to use Linux file system format ext4

finally everything worked fine

by changing the external storage location to /mnt
and format external storage to btrfs via DietPi-Drive_Manager
Tried formatting to ext4 but it still doesn’t work, maybe because of the flash disk.
At least for now it’s working

ok thank you all sir, with this experience I can better understand the Dietpi OS (Linux)

There should be no difference between ext4 and btrfs in regards to file system permissions

1 Like