What permissions I need for nc to access a local drive

Support intro

Sorry to hear you’re facing problems. :slightly_frowning_face:

The community help forum (help.nextcloud.com) is for home and non-enterprise users. Support is provided by other community members on a best effort / “as available” basis. All of those responding are volunteering their time to help you.

If you’re using Nextcloud in a business/critical setting, paid and SLA-based support services can be accessed via portal.nextcloud.com where Nextcloud engineers can help ensure your business keeps running smoothly.

Getting help

In order to help you as efficiently (and quickly!) as possible, please fill in as much of the below requested information as you can.

Before clicking submit: Please check if your query is already addressed via the following resources:

(Utilizing these existing resources is typically faster. It also helps reduce the load on our generous volunteers while elevating the signal to noise ratio of the forums otherwise arising from the same queries being posted repeatedly).

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can. :heart:

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 30.0.5
  • Operating system and version (e.g., Ubuntu 24.04):
    • ubuntu 24.04
  • Web server and version (e.g, Apache 2.4.25):
    -2.4.58
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • replace me
  • PHP version (e.g, 8.3):
    • 8.3.6
  • Is this the first time you’ve seen this error? (Yes / No):
    • yes
  • When did this problem seem to first start?
    • after install
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • `snap
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • no

Summary of the issue you are facing:

want nextcloud to use an different local drive

Steps to replicate it (hint: details matter!):

  1. install external_storage app

  2. mount a drive /dev/sda1 to /media/www (sda1 is a drive installed separately from the nextcloud & ubuntu installation)

  3. mkdir data after cd /media/www

  4. chown -R www-data:www-data /media/www/data

  5. chmod -R 0770 /media/www

  6. drwxrwx— 3 www-data www-data 4096 Feb 15 21:52 .
    drwxrwx— 7 wanj wanj 4096 Feb 15 22:00 …
    drwxrwx— 4 www-data www-data 4096 Feb 15 19:23 data

  7. result: external storage not available

Log entries

StorageNotAvailableException Local storage path does not exist “/media/www/data/”

  1. /snap/nextcloud/46218/htdocs/apps/files_external/lib/MountConfig.phpLine 95
OC\Files\Storage\Local->__construct
()
  1. /snap/nextcloud/46218/htdocs/apps/files_external/lib/Controller/StoragesController.phpLine 224
OCA\Files_External\MountConfig::getBackendStatus
(
  "*** sensitive parameters replaced ***"
)
  1. /snap/nextcloud/46218/htdocs/apps/files_external/lib/Controller/StoragesController.phpLine 277
OCA\Files_External\Controller\StoragesController->updateStorageStatus
(
  "*** sensitive parameters replaced ***"
)
  1. /snap/nextcloud/46218/htdocs/lib/private/AppFramework/Http/Dispatcher.phpLine 208
OCA\Files_External\Controller\StoragesController->show
()
  1. /snap/nextcloud/46218/htdocs/lib/private/AppFramework/Http/Dispatcher.phpLine 114
OC\AppFramework\Http\Dispatcher->executeController
()
  1. /snap/nextcloud/46218/htdocs/lib/private/AppFramework/App.phpLine 161
OC\AppFramework\Http\Dispatcher->dispatch
()
  1. /snap/nextcloud/46218/htdocs/lib/private/Route/Router.phpLine 302
OC\AppFramework\App::main
()
  1. /snap/nextcloud/46218/htdocs/lib/base.phpLine 1003
OC\Route\Router->match
()
  1. /snap/nextcloud/46218/htdocs/index.phpLine 24
OC::handleRequest
()

Raw log entry

{
  "reqId": "mAf04pq05r3kRdImDHRj",
  "level": 3,
  "time": "2025-02-17T05:59:43+00:00",
  "remoteAddr": "192.168.1.4",
  "user": "wanj",
  "app": "files_external",
  "method": "GET",
  "url": "/index.php/apps/files_external/globalstorages/3?testOnly=true",
  "message": "Local storage path does not exist \"/media/www/data/\"",
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0",
  "version": "30.0.5.1",
  "exception": {
    "Exception": "OCP\\Files\\StorageNotAvailableException",
    "Message": "Local storage path does not exist \"/media/www/data/\"",
    "Code": 1,
    "Trace": [
      {
        "file": "/snap/nextcloud/46218/htdocs/apps/files_external/lib/MountConfig.php",
        "line": 95,
        "function": "__construct",
        "class": "OC\\Files\\Storage\\Local",
        "type": "->"
      },
      {
        "file": "/snap/nextcloud/46218/htdocs/apps/files_external/lib/Controller/StoragesController.php",
        "line": 224,
        "function": "getBackendStatus",
        "class": "OCA\\Files_External\\MountConfig",
        "type": "::",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/snap/nextcloud/46218/htdocs/apps/files_external/lib/Controller/StoragesController.php",
        "line": 277,
        "function": "updateStorageStatus",
        "class": "OCA\\Files_External\\Controller\\StoragesController",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/snap/nextcloud/46218/htdocs/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 208,
        "function": "show",
        "class": "OCA\\Files_External\\Controller\\StoragesController",
        "type": "->"
      },
      {
        "file": "/snap/nextcloud/46218/htdocs/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 114,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/snap/nextcloud/46218/htdocs/lib/private/AppFramework/App.php",
        "line": 161,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/snap/nextcloud/46218/htdocs/lib/private/Route/Router.php",
        "line": 302,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::"
      },
      {
        "file": "/snap/nextcloud/46218/htdocs/lib/base.php",
        "line": 1003,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->"
      },
      {
        "file": "/snap/nextcloud/46218/htdocs/index.php",
        "line": 24,
        "function": "handleRequest",
        "class": "OC",
        "type": "::"
      }
    ],
    "File": "/snap/nextcloud/46218/htdocs/lib/private/Files/Storage/Local.php",
    "Line": 70,
    "Hint": "Storage is temporarily not available",
    "message": "Local storage path does not exist \"/media/www/data/\"",
    "exception": [],
    "CustomMessage": "Local storage path does not exist \"/media/www/data/\""
  },
  "id": "67b2d2321c6a2"
}

Nextcloud

Please provide the log entries from your Nextcloud log that are generated during the time of problem (via the Copy raw option from Administration settings->Logging screen or from your nextcloud.log located in your data directory). Feel free to use a pastebin/gist service if necessary.

PASTE HERE

Web Browser

If the problem is related to the Web interface, open your browser inspector Console and Network tabs while refreshing (reloading) and reproducing the problem. Provide any relevant output/errors here that appear.

PASTE

Web server / Reverse Proxy

The output of your Apache/nginx/system log in /var/log/____:

PASTE HERE

Configuration

Nextcloud

The output of occ config:list system or similar is best, but, if not possible, the contents of your config.php file from /path/to/nextcloud is fine (make sure to remove any identifiable information!):

<?php
$CONFIG = array (
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/snap/nextcloud/current/htdocs/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/snap/nextcloud/current/nextcloud/extra-apps',
      'url' => '/extra-apps',
      'writable' => true,
    ),
  ),
  'supportedDatabases' =>
  array (
    0 => 'mysql',
  ),
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/tmp/sockets/redis.sock',
    'port' => 0,
  ),
  'log_type' => 'file',
  'logfile' => '/var/snap/nextcloud/current/logs/nextcloud.log',
  'logfilemode' => 416,
  'maintenance_window_start' => 1,
  'passwordsalt' => '1hp/x6xeMRIjoUXGOoCVr/auY0MuU0',
  'secret' => 'O0YDeG1kXMg+WfEaC7iF/SfvFHsBGYwyvrley+Y/8RjxQx7l',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => '192.168.1.5',
    2 => 'nc.jackwan2.ddns.us',
  ),
  'datadirectory' => '/var/snap/nextcloud/common/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '30.0.5.1',
  'overwrite.cli.url' => 'http://localhost',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:/tmp/sockets/mysql.sock',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'aM7rCwVyfg904NMVSzbhtOFi9nCbwSg8-lf03ydvg3KQhv6VD3rstEg27VJ-4q2I',
  'installed' => true,
  'instanceid' => 'ocjat877dr84',
  'maintenance' => false,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'winme',
  'mail_domain' => 'creforum.net',
  'mail_smtphost' => 'mail.creforum.net',
  'mail_smtpport' => '465',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'winme@creforum.net',
  'mail_smtppassword' => '##Vivian1',
  'forbidden_filename_basenames' =>
  array (
    0 => 'con',
    1 => 'prn',
    2 => 'aux',
    3 => 'nul',
    4 => 'com0',
    5 => 'com1',
    6 => 'com2',
    7 => 'com3',
    8 => 'com4',
    9 => 'com5',
    10 => 'com6',
    11 => 'com7',
    12 => 'com8',
    13 => 'com9',
    14 => 'com¹',
    15 => 'com²',
    16 => 'com³',
    17 => 'lpt0',
    18 => 'lpt1',
    19 => 'lpt2',
    20 => 'lpt3',
    21 => 'lpt4',
    22 => 'lpt5',
    23 => 'lpt6',
    24 => 'lpt7',
    25 => 'lpt8',
    26 => 'lpt9',
    27 => 'lpt¹',
    28 => 'lpt²',
    29 => 'lpt³',
  ),
  'forbidden_filename_characters' =>
  array (
    0 => '<',
    1 => '>',
    2 => ':',
    3 => '"',
    4 => '|',
    5 => '?',
    6 => '*',
    7 => '\\',
    8 => '/',
  ),
  'forbidden_filename_extensions' =>
  array (
    0 => ' ',
    1 => '.',
    2 => '.filepart',
    3 => '.part',
  ),
  'app_install_overwrite' =>
  array (
    0 => 'files_scripts',
    1 => 'mailnotifier',
  ),
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
);

Apps

The output of occ app:list (if possible).

Tips for increasing the likelihood of a response

  • Use the preformatted text formatting option in the editor for all log entries and configuration output.
  • If screenshots are useful, feel free to include them.
    • If possible, also include key error output in text form so it can be searched for.
  • Try to edit log output only minimally (if at all) so that it can be ran through analyzers / formatters by those trying to help you.

Hello,

There isn’t much you need to do for allowing snap nextcloud to access your external drive for user data storage. Steps are really simple.

However, please note, snap nextcloud by default can’t access outside of it’s confinement. Following command would allow it to access outside of it’s default place holder.

sudo snap connect nextcloud:removable-media

Refer here → nextcloud-snap/nextcloud-snap: :cloud::package: Nextcloud packaged as a snap

Secondly, as you have done it, rightly so, Snap Nextcloud can only access drives or directory or network share mounted under /mnt or /media volumes.

Lastly, you need to edit the snap nextcloud configuration file to change the default location to your new data directory path. The default location of config file is → /var/snap/nextcloud/current/nextcloud/config/config.php You need to edit the atribute
'datadirectory' => '/media/your/data/location',

Refer here → Wiki Change data directory · nextcloud-snap/nextcloud-snap Wiki

For more information and FAQ, kindly consider reading the Snap Nextcloud WiKi. → Home · nextcloud-snap/nextcloud-snap Wiki

Did you run that above command to allow external drive access?

Thanks.

1 Like

Thanks a lot for your help, right now I only want to link the “External Storage” which is /media/www/data to nextcloud, so I did not change directory location in the config.php. I however did execute the command as suggested:

sudo snap connect nextcloud:removable-media

Background: I am using docker-compose nginx to access nextcloud, in its default drive location, I have no problem to up/download files. the nginx is installed on a server 192.168.1.4, while nextcloud is installed on a server 192.168.1.5

the intended external file location is on 192.168.1.5 and mounted as /media/www/ via fstab

In external storage section of nextcloud admin how should I configure?

If I configure it as local drive error message in /media/www or /media/www/data not found, in review the error log, it was pointing to 192.168.1.4 (see log above,
remoteAddr": “192.168.1.4”
)

If I configure it as a nextcloud drive and put URL as 192.168.1.5 or 192.168.1.5:xxx or the ddns url. Error message comes back as recheck configuration, but not recorded in the error log. I tried various combination in the configuration and failing.

If I configure external storage as local and /media, I have no problem. But /media is not the mounted drive.

Am I missing some thing?

StorageNotAvailableException Local storage path does not exist “/media/www/data/”

  1. /snap/nextcloud/46218/htdocs/apps/files_external/lib/MountConfig.phpLine 95
OC\Files\Storage\Local->__construct
()
  1. /snap/nextcloud/46218/htdocs/apps/files_external/lib/Controller/StoragesController.phpLine 224
OCA\Files_External\MountConfig::getBackendStatus
(
  "*** sensitive parameters replaced ***"
)
  1. /snap/nextcloud/46218/htdocs/apps/files_external/lib/Controller/StoragesController.phpLine 277
OCA\Files_External\Controller\StoragesController->updateStorageStatus
(
  "*** sensitive parameters replaced ***"
)
  1. /snap/nextcloud/46218/htdocs/lib/private/AppFramework/Http/Dispatcher.phpLine 208
OCA\Files_External\Controller\StoragesController->show
()
  1. /snap/nextcloud/46218/htdocs/lib/private/AppFramework/Http/Dispatcher.phpLine 114
OC\AppFramework\Http\Dispatcher->executeController
()
  1. /snap/nextcloud/46218/htdocs/lib/private/AppFramework/App.phpLine 161
OC\AppFramework\Http\Dispatcher->dispatch
()
  1. /snap/nextcloud/46218/htdocs/lib/private/Route/Router.phpLine 302
OC\AppFramework\App::main
()
  1. /snap/nextcloud/46218/htdocs/lib/base.phpLine 1003
OC\Route\Router->match
()
  1. /snap/nextcloud/46218/htdocs/index.phpLine 24
OC::handleRequest
()

Raw log entry

{
  "reqId": "ToABjcm3Hsr4yzxX7yoM",
  "level": 3,
  "time": "2025-02-18T20:04:12+00:00",
  "remoteAddr": "192.168.1.4",
  "user": "wanj",
  "app": "files_external",
  "method": "GET",
  "url": "/index.php/apps/files_external/globalstorages/9?testOnly=true",
  "message": "Local storage path does not exist \"/media/www/data/\"",
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0",
  "version": "30.0.5.1",
  "exception": {
    "Exception": "OCP\\Files\\StorageNotAvailableException",
    "Message": "Local storage path does not exist \"/media/www/data/\"",
    "Code": 1,
    "Trace": [
      {
        "file": "/snap/nextcloud/46218/htdocs/apps/files_external/lib/MountConfig.php",
        "line": 95,
        "function": "__construct",
        "class": "OC\\Files\\Storage\\Local",
        "type": "->"
      },
      {
        "file": "/snap/nextcloud/46218/htdocs/apps/files_external/lib/Controller/StoragesController.php",
        "line": 224,
        "function": "getBackendStatus",
        "class": "OCA\\Files_External\\MountConfig",
        "type": "::",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/snap/nextcloud/46218/htdocs/apps/files_external/lib/Controller/StoragesController.php",
        "line": 277,
        "function": "updateStorageStatus",
        "class": "OCA\\Files_External\\Controller\\StoragesController",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/snap/nextcloud/46218/htdocs/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 208,
        "function": "show",
        "class": "OCA\\Files_External\\Controller\\StoragesController",
        "type": "->"
      },
      {
        "file": "/snap/nextcloud/46218/htdocs/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 114,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/snap/nextcloud/46218/htdocs/lib/private/AppFramework/App.php",
        "line": 161,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/snap/nextcloud/46218/htdocs/lib/private/Route/Router.php",
        "line": 302,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::"
      },
      {
        "file": "/snap/nextcloud/46218/htdocs/lib/base.php",
        "line": 1003,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->"
      },
      {
        "file": "/snap/nextcloud/46218/htdocs/index.php",
        "line": 24,
        "function": "handleRequest",
        "class": "OC",
        "type": "::"
      }
    ],
    "File": "/snap/nextcloud/46218/htdocs/lib/private/Files/Storage/Local.php",
    "Line": 70,
    "Hint": "Storage is temporarily not available",
    "message": "Local storage path does not exist \"/media/www/data/\"",
    "exception": [],
    "CustomMessage": "Local storage path does not exist \"/media/www/data/\""
  },
  "id": "67b4e7ddc065c"
}