How to Add External Storage to ownCloud 9

OwnCloud is a server software for data synchronization and file sharing with an easy to use web-based frontend that is available under an open source license. Owncloud can be installed on a Linux or Windows web server, it is easy to configure and has a comprehensive online documentation.

In OwnCloud, we can add external storage as ownCloud storage devices to extend the storage capabilities of the local server. This feature makes it easy to add new storage when we have a small server. We just need to mount and add it to the ownCloud storage devices list.

Supported storage types in ownCloud:

  • Amazon S3
  • Dropbox
  • FTP/FTPS
  • Google Drive
  • Local
  • OpenStack Object Storage
  • ownCloud
  • SFTPS
  • MB/CIFS
  • WebDAV

In this tutorial, I will show you how to enable an external storage or drive in ownCloud 9. I will show you how to add a new 'Local' storage to the ownCloud server and how to mount it as an ownCloud storage device.

Prerequisites

  • CentOS 7 OwnCloud Server Installed.
  • Root Privileges.
  • External drive - I will use '/dev/sdb' here.

Step 1 - Configure the Storage Drive

In this step, we will prepare new drive '/dev/sdb' for the use in ownCloud. I will format it with an 'ext4' file system and mount it permanently with an entry in /etc/fstab to a local directory.

Connect to the ownCloud server by SSH (or open the terminal when you work locally)

ssh root@owncloudIP

Check if there is a '/dev/sdb' drive available.

sudo fdisk -l /dev/sdb

Now make a new partition with the fdisk command.

fdisk /dev/sdb

Type 'o' to create a new partition table.
Type 'n' to create a new partition.
Choose the primary partition type, input 'p'.
Partition Number - we just need 1.
Leave all default on the First sector and Last sector - Press Enter.
Type 'w' and press enter to write the partition.

Create a partition with fdisk

The '/dev/sdb1' partition has been created, now we have to format it to 'ext4' with the mkfs tool. Then check the volume size.

mkfs.ext4 /dev/sdb1
fdisk -s /dev/sdb1

Format the new partition with ext4

Next, create a new 'data' directory and mount '/dev/sdb1' to that directory.

sudo mkdir -p /data
sudo mount /dev/sdb1 /data

Under the data directory, we've already mounted a new disk. Create a new directory 'sdb-owncloud' in it for owncloud. Then change the owner of the directory to the 'nginx' user, owncloud running under 'nginx' user in my setup (see my ownCloud installation tutorials here at Howtoforge for the ownCloud base setup).

sudo mkdir -p /data/sdb-owncloud
sudo chown -R nginx:nginx /data/sdb-owncloud

Run SELinux command below to allow ownCloud to write to new disk directory. This has to be done on CentOS only but not on Ubuntu and Debian.

sudo semanage fcontext -a -t httpd_sys_rw_content_t '/data/sdb-owncloud(/.*)?'
sudo restorecon -Rv /data/sdb-owncloud/

To mount new disk permanently, we add the new mount configuration to the fstab file. Open fstab with vom:

vim /etc/fstab

Paste the configuration below at the end of the file.

/dev/sdb1     /data     ext4     defaults     0     1

Save fstab and exit vim.

Now remount the disk and make sure that there is no error.

umount /data
mount -a
df -h

Mount the drive permanently in fstab

Step 2 - Enable External Storage

To enable ownCloud for using an external storage, we must enable apps in ownCloud admin area.

Login to ownCloud as admin.

ownCloud Login

Now click on the 'Files' section and choose 'Apps'.

OwnCloud add apps

Click the tab 'Not enabled' and choose 'External storage support', click 'Enable' and wait.

Enable External Storage in ownCloud

External storage support enabled.

Step 3 - Add New Storage

Owncloud app for 'External storage support' has been enabled. Go to the admin settings and you will see an 'External Storage' tab, click on it.

Add new storage in ownCloud

Add new storage, type 'Local'.

Type in the information below:

  • Folder name - name on the owncloud dashboard 'sdb-owncloud'
  • Configuration - data storage directory '/data/sdb-owncloud/'
  • Available for - this storage available for some 'Group or User'

If there is a 'Green' color, it means available and success.

OwnCloud add local storage

Now back to admin file-manager dashboard, and you will see the 'sdb-owncloud' directory.

Local storage added to ownCloud

Step 4 - Login as Normal User

Login as a normal user, in my case the user 'hakase', and you will see that the 'sdb-owncloud' directory is available there as well.

Local storage available to the user

When you upload a file to 'sdb-woncloud', the file is available for other users which have permission to access the 'sdb-owncloud' local storage.

Reference

Share this page:

3 Comment(s)