Add local folder to Nextcloud Snap as External Storage

After setting up my Ubuntu Server as a home server I wanted to make Nextcloud mount my network shared folder so I could alter files through the Nextcloud interface.

First I installed the Nextcloud removable media snap with,

sudo snap connect nextcloud:removable-media

which meant that the Nextcloud Snap would be able to access removable media (eg; anything mounted under /media). I then created a folder in media to mount to,

sudo mkdir /media/Public

and used bind to bring the two together.

sudo mount -o bind /home/<username>/Public/ /media/Public

I then tested the two were bound properly with,

ls /media/Public

To see if my files were there. Amazingly it all worked so logged into the admin account on Nextcloud, went to Settings in the right hand menu and then External Storages on the bottom left of the screen (If it isn’t there you may need to enable the module in Apps).

In Externals Storage add a folder name, choose Local for External Storage, Authentication (none), Put the file path in configuration (eg; /media/Public), choose what users you want it available for and click the tick.

If it goes green all should be well and you should be able to access the folder through the External Storage menu after logging in. To make the bind permanent you need to add it to your fstab so it lasts through reboot.

To do this make a backup of fstab,

sudo cp /etc/fstab /etc/fstab_backup

open up fstab in nano with,

sudo nano /etc/fstab

and add a line at the bottom. My one is,

home/<insert username>/Public /media/Public/ none bind

Yours can be whatever you want as long as you follow the same process. Be careful if you are not used to fstab, it is used to mount your disks when booting so if you don’t do it right then your computer won’t boot so make a backup first.

Before reboot you can test the config with,

sudo mount -a 

to see if it gives any errors.

Leave a Reply

Your email address will not be published. Required fields are marked *