Disable *not delete* external storage mount from commandline using occ

I’ve been trying to figure out how to disable some external file storage mappings from the command line using occ but can’t find a way.

Use case
I have a number of external storage - mainly SMB and FTP - mappings. These are mapped to 5-6 different servers.

Issue
Intermittently, one of the servers becomes unavailable (due to a problem with that server which is often beyond my control).

When this server becomes unavailable my Nextcloud instance becomes very slow to respond. It works, but it very slow.

This impacts on experience for my users (less than 20 users). I have traced this (I think) to
continuous attempts to reconnect to the unavailable SMB mounts.

Work around
When I disable external storage support (via occ in command line), the Nextcloud response times go back to normal.

This is sub-optimal as all other external storage mappings become unavailable as a result.

Expectations
I would expect to be able to disable individual mappings 1) by mapping address or 2) by server, something like:

sudo -u www-data php /var/www/nextcloud/occ files_external:disable <mount_point>

or

sudo -u www-data php /var/www/nextcloud/occ files_external:disable <host>

I’ve looked through the command line options and admin manual but can’t find it anywhere.

Any suggestions on how to do it from command line, ideally on server or mount basis?

If not, would an option for that be possible to add? I’m happy to help with design and testing if needed.

Thanks!

Anybody to have a solution to this?
I need to solve the same problem. I attached a NAS as external storage to my Nextcloud via SMB and set for all users a mount point on the NAS, whereas all data is not saved on the NC server itself (except the installation) but on the NAS. After changing my home network ip adress (X.X.178.X) to (X.X.10.X) I get the following error message preventing me accessing nextcloud via the Web GUI:

Storage with mount id 26 is not available
Storage is temporarily not available

I assume it’s because the NAS got a new IP adress, so of course it must be changed in the Nextcloud settings. However, I can’t do this cause I can’t login (see screenshot).

Any way of how to disable the external storage via command line?
2

System:

NC 23.01
Ubuntu 20 LTS
NC on Docker

As far as I know there is currently no way to disable an external storage. not in the frontend and also not in the backend.

Hello @szaimen,

thanks for your reply.
I found a solution in another thread: Can't remove external mount - #11 by SimpleCake

Solution by User SimpleCake:

Open a docker interactive terminal (if you’re using docker with the official image)

sudo docker exec -it docker-nextcloud /bin/bash

List the currently active mount points for all users

Standard Usage

occ files_external:list -a

Docker

su -c "php /var/www/html/occ files_external:list -a" -s /bin/sh www-data

Delete a selected mount using the mount’s ID

Standard Usage

occ files_external:delete <Mount ID>

Docker

su -c "php /var/www/html/occ files_external:delete <Mount ID>" -s /bin/sh www-data

Command results for reference

These commands were issued from inside a docker container, so they command syntax will look different if you’re using the terminal (as discussed previously) or if you are using a different image base in your docker container.

List ALL of the mount points as the root user

root@mydockercontainer# su -c "php /var/www/html/occ files_external:list -a" -s /bin/sh www-data
+----------+-------------+-------------------------------------+-----------------------+----------------------------------------------------------------------------------------------------------+---------+------------------+-------------------+----------+
| Mount ID | Mount Point | Storage                             | Authentication Type   | Configuration                                                                                            | Options | Applicable Users | Applicable Groups | Type     |
+----------+-------------+-------------------------------------+-----------------------+----------------------------------------------------------------------------------------------------------+---------+------------------+-------------------+----------+
| 2        | /BoxDotCom  | WebDAV                              | Username and password | host: "dav.box.com\/dav", root: "NextCloud", secure: true, user: "emai1@local.com", password: "***"      |         | user1            |                   | Personal |
| 3        | /GDrive     | Unknown storage backend googledrive | OAuth2                | configured: "true", client_id: "xxxxxx...al.com", client_secret: "***", token: "***"                     |         | user2            |                   | Personal |
+----------+-------------+-------------------------------------+-----------------------+----------------------------------------------------------------------------------------------------------+---------+------------------+-------------------+----------+

Pick out your ID from the results

I choose number three which is associated with the provider type and user that is having the issue.

Delete the mount and confirm when prompted

root@mydockercontainer# su -c "php /var/www/html/occ files_external:delete 3" -s /bin/sh www-data
+----------+-------------+-------------------------------------+---------------------+--------------------------------------------------------------------------------------+---------+------------------+-------------------+
| Mount ID | Mount Point | Storage                             | Authentication Type | Configuration                                                                        | Options | Applicable Users | Applicable Groups |
+----------+-------------+-------------------------------------+---------------------+--------------------------------------------------------------------------------------+---------+------------------+-------------------+
| 3        | /GDrive     | Unknown storage backend googledrive | OAuth2              | configured: "true", client_id: "xxxxxx...al.com", client_secret: "***", token: "***" |         | user2            |                   |
+----------+-------------+-------------------------------------+---------------------+--------------------------------------------------------------------------------------+---------+------------------+-------------------+
Delete this mount? [y/N] y

List ALL of the mount points again to ensure it’s gone

root@mydockercontainer# su -c "php /var/www/html/occ files_external:list -a" -s /bin/sh www-data
+----------+-------------+---------+-----------------------+----------------------------------------------------------------------------------------------------------+---------+------------------+-------------------+----------+
| Mount ID | Mount Point | Storage | Authentication Type   | Configuration                                                                                            | Options | Applicable Users | Applicable Groups | Type     |
+----------+-------------+---------+-----------------------+----------------------------------------------------------------------------------------------------------+---------+------------------+-------------------+----------+
| 2        | /BoxDotCom  | WebDAV  | Username and password | host: "dav.box.com\/dav", root: "NextCloud", secure: true, user: "email@local.com", password: "***"      |         | user1            |                   | Personal |
+----------+-------------+---------+-----------------------+----------------------------------------------------------------------------------------------------------+---------+------------------+-------------------+----------+

Go back to the browser and verify that the issue is fixed

Yes, deletion is possible but not disabling. (I was refering to the title of this thread…)

This isn’t a solution to my question. The original goal is to disable, not delete.

@bernard
Sorry i can not help you. There is a closed issue. Perhaps you can open an issue here.

@devnull That’s OK! I didn’t see that closed issue. At least it’s clear that it isn’t possible, so I suppose your answer is a kind of solution. :wink:

???

As this sounds like a nice feature, the requests for this are quite low. Currently there are no plans to implement such a feature. Thus I will close this ticket for now. This does not mean we don’t want this feature, but it is simply not on our roadmap for the near future. If somebody wants to implement this feature nevertheless we are happy to assist and help out.If you wish to have this feature implemented by the Nextcloud GmbH there is the option for consulting work on top of your Nextcloud Enterprise subscription to get your features implemented.

Heh, I meant I wasn’t aware of that issue. I had not seen it before you posted the link.

1 Like