How do I symlink a folder in my home directory to nextcloud data directory in ubuntu?

Hi all

I have installed nextcloud 12 in a server running ubuntu 16.04. I have only one user account on this server. My data directory is /var/www/nextcloud/data

I want access to a folder in my home directory on this server through the nextcloud web interface so I can access it from anywhere.

I tried adding the folder as local external storage, but I have been unable to see the files inside the folder. I have tried to give recursive ownership of the parent folder. to www-data and also done chmod 750 on the files inside the folder. However I still cannot see the files and I am giving up on the external storage option.

Is there a way I can symlink the parent folder to the next cloud data directory so I can access it through NC? If so, please explain how I can do this.

Thanks

Edit: The reason I was not able to access the files was because they were on an ntfs partition. I solved this by following the answer below.

1 Like

Symlinks in the Datafolder are (sadly for you) not supported.

By the way, this forum boasts an excellent search function:

You might continue looking into external storage for your usecase. You will get this working :slight_smile:

1 Like

Thanks for the reply. I did see that thread but was not sure if NC12 had added support for symlinks in the last year. I will keep trying to add it as external storage.

1 Like

I am confident, that this is not the case, since this is a very basic Design/Security desicion, i cannot see undone in the near future, since it makes total sense, to disallow symlinks there.

Symlinks very likely won’t be supported for the foreseeable future.

I realized that an NTFS partition that is mounted in the data directory that I want access to. Is this why I am unable to see the files inside the directory?

that was the problem. I used the settings in this answer https://help.nextcloud.com/t/you-dont-have-permissions-to-upload-or-create-files-here-local-external-ntfs-3g-storage/5420 and solved my problem after rebooting the server and changing the permissions again and recreating the local storage folder.

The foundational purpose of Nextcloud is file sharing, yet it is nothing short of a 100 meter hurdle obstacle dash to even enable removable-media or external data storage abilities. Every possible ability to do this quickly and easily should be in place from day one.

I see someone in this particular thread on this very topic declaring no symlinks are allowed. Symlinks which in the case of Nextcloud would be buried in a /var directory and couldn’t be changed nor added unless a remote user gained the rather unlikely superuser status on your local system. If a attacker gained superuser status on your local system, not providing symlinks ability wouldn’t present a overwhelming obstacle to them having their way on most any system.

I’ve lost count from all the countless posts, articles, discussions from Nextcloud users begging for help on their failed external HD attempts to store Nextcloud files other than on a server’s tiny SSD where the Nextcloud is stored with the system files. Do the Nextcloud developers realize the scope and quantity of Nextcloud users frantically asking for easier, instant abilities to enable external storage and have that immediately available?

There’s also many reported issues with the ‘addon’ external storage plugin yet that is nearly all there is at this version 13.x point. This should not be that difficult, nor a after thought, file sharing is a primary feature and should be as automated as possible for successful use of external local server hard drives.

4 Likes

In Nextcloud 13.0.2 with “External Storage Support” app 1.4.1 there is an option to add a “local” storage type that can then be defined with a standard filepath: /path/to/somewhere/ (for Linux).
It is only available in the External Storage App in the system settings, not in the personal settings (you need to be admin).

The target needs to be accessible by the webserver user (e.g. “http” for nginx or another one depending on your webserver, distro and config)

I do not know which minimal Nextcloud / External Storage Support version is necessary to choose this storage type.

1 Like

First of all sorry for reviving an old thread, but I think it’s still relevant.

I agree that generally disallowing symlinks is a good security decision by default as it removes a whole category of potential security holes, BUT would it not be possible to add a configuration option that lets admins override and disable that restriction (kind of like a –yes-i-know-what-i-am-doing flag)?

In my particular case I want to store the user data directories on a NFS share at our central storage server, but not the files that nextcloud uses (logs, updater, static files etc) because then page loading becomes significantly slower because of many tiny NFS calls.
How would you suggest that I solve this? Our Nextcloud is hosted in a VM with a relatively small local disk image, and I’m reluctant to expand it to fit user data as SSD space is more in demand/costly than regular hard disks…

1 Like

Maybe i miss something, but if not then:

Mount the NFS share as /data and put your datadir there via setup like its a common known best practice. In this case, apart from user files only nextcloud.log will be in /data and i guess (not sure, i have not touched a live system for some time now) even that can be configured in config.php.

Like @Ascendancer said, you can always just change the datadir path in your Nextcloud config to support your use case. I’ve done this myself, keeping the Nextcloud files on an SSD and pointing the Nextcloud data directory to my hard disk (so not NFS, in my case). And this works perfectly well.

But if you want a “yes-I-know-what-I-am-doing” option for symlinks, I think you could also just create a bind mount instead of a symlink. That should look like a normal directory to Nextcloud so it can not treat it any differently and you would still be able to mount your external disk elsewhere initially. I’m not sure what the implications are of this, though. But my point is that if you know what you’re doing, this doesn’t really need to be enabled within Nextcloud.

1 Like

I´m ashamed to admit, that i have been out of the game for about a year, but to my knowledge, changing the datadir in the config is not supported, and needs to be set on ititial setup, it may lead to freak phenomena. Correct me please if this has changed since version 12.

I think I probably configured this in Nextcloud 10 and just continued updating afterwards (at Nextcloud 15 now). But I checked the documentation and this seems to still be possible:
https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/config_sample_php_parameters.html?highlight=datadirectory#default-parameters

But you’re probably right that this would not be recommended after installation, especially if you use SQLite as database.

That’s exactly what I did during setup (placed datadirectory on a NFS mount), and now the setup is incredibly slow - hence the troubleshooting to find out what’s happening.
Log file location can be configured (parameter “logfile”, default=[datadir]/nextcloud.log), that’s correct - I have configured it to be on the local file system to reduce any possible slowdowns there.

But I still get the folders appdata_[instanceid] and updater-[instanceid] folders inside the datadir, and I suspect that causes some slowdowns - like 8 seconds for each javascript and CSS file. If that’s not the culprit, then there must be something else terribly wrong with my setup…

@arucard thanks for the tip about bind mounts, I didn’ think about that but it seems to work just great (although the performance is still the same, so the problem might be something else)

If you’re having performance issues with NFS, you’re probably better off using the External Storage app in Nextcloud for accessing this NFS mount as a “Local” External Storage location. That way you can keep the Nextcloud data directory on your faster, local disk.

I don’t think Nextcloud is intended for using network-attached storage as the main location for its application data. Perhaps you can try to get Nextcloud installed on the machine where your NFS share is located (since you could then use a local data directory for Nextcloud).