Nextcloud: External directory for one user
Nextcloud supports mounting external folders as storage for specific users. This solves data isolation, quota application, or providing access to a shared directory without cluttering the main storage.
Why need external directory
In scenarios where a single user or service requires dedicated space, creating an external directory separately from the main Nextcloud storage is more convenient. This allows: — Applying separate access rights to the folder. — Setting quotas at the filesystem level. — Ensuring backup or synchronization of a specific user without affecting others. — Allowing the user to manage their files via the web interface or WebDAV without access to other parts of the instance.
Prepare directory and access rights
Before adding the storage to Nextcloud, prepare a folder on the host. Example for user alice:
If SELinux is enabled (CentOS/RHEL), the context may be required:
Use ACLs for fine-grained tuning if needed, so that Nextcloud and other processes have different access masks.
Configure external storage in Nextcloud
Enable the External Storage app (usually included in the base package). A storage can be added via the web interface or occ. For an external folder, select type Directory.
Key parameters when adding via occ (syntax may vary depending on version, but the essence is universal):
| Parameter | Description |
|---|---|
userId | Nextcloud user ID the storage belongs to |
rootFolderId | ID of the root folder inside Nextcloud (usually -1 means the user’s root) |
volumeId | Volume identifier (any unique string) |
isReadOnly | Read-only flag (true/false) |
loginName | Username for authentication, if required |
Example adding via occ (path specified absolute, accessible to the web server):
After adding, verify the folder appears in user alice’s list.
Do not specify paths accessible only to root processes without explicitly switching the web server user. Permission denied at the mount stage is a typical trap.
Check functionality and typical errors
After configuration, log in as user alice and verify the folder mounts and files create in /data/nextcloud/alice.
Common causes of failure:
- Mismatched owner — the folder belongs to a different user or group, and the web server lacks write rights. Fix:
chown www-data:www-data /pathand verifychmod. - SELinux / AppArmor — security context blocks web server access to the folder. Fix:
restorecon -Rv /pathor policy configuration. - Paths with spaces or special characters — always use quotes in
occparameters and avoid paths with spaces without escaping. - Missing External Storage app — ensure the app is enabled (
occ app:enable externalstorageor via admin UI). - Incorrect
userId— theocccommand may succeed, but the folder won’t appear in the UI if the user ID doesn’t exist or is wrong.
For diagnostics, list external storages:
If the path is correct but files don’t appear, check the Nextcloud data/ structure and .htaccess settings or trusted_proxies if access comes through a reverse proxy.
In most cases, the issue is resolved by correcting the folder owner and re-running the occ command with output verification.