Using external hard drive on nextcloud

After building the cloud machine you may want to add external storage like external hard drive or even a pen drive to the cloud. To do this follow these steps:

1) First identity uid and gid numbers of apache user. Default apache user of apache on Debian/Raspbian is www-data. Look for gid and uid numbers of this user.

root@cld:~# id www-data
uid=33(www-data) gid=33(www-data) groups=33(www-data)

Here uid and gid numbers are 33

2) Connect external hard disk to USB port of PC or raspberry. It will get automatically mounted, Find mounting parameters by issue mount command. output will look something like:

/dev/sda1 /xxx vfat rw,relatime,uid=xx,gid=xx,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro 0 0

3) Now create a mount point directory of your choice like

mkdir /mnt/cloud-drive

4) Modify the mount parameters discovered in step 2 as following and append it in end of /etc/fstab file

/dev/sda1 /mnt/cloud-drive vfat rw,relatime,uid=33,gid=33,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro 0 0

Reboot the system and now content of external hard drive should be available in /mnt/cloud-drive

5) Now login into nextcloud and navigate to Apps->disabled apps. Here locate external storeage and “Enable” it.

6) Go to Settings->Administration->External Storages and configure it as shown in screenshot. You can define users and groups who can access it, enable sharing, enable mounting options for users, make it read-only and so on.

7) Login as normal user to which access has been granted on External storage and you will see content of external storage available as “CloudDrive”