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

1 Like

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

Any workaround since? I mounted the external storage I use with the backup app, and it interacts poorly and I suspect this might be causing some of my backup issues (also the ā€˜recommended filesā€™ panel in my welcome page always mention backup files, which is ugly). Iā€™d be happy to just unmount it from the files app since I only use it to store remote backupsā€¦