Configuring Secondary Storage on Nextcloud

July 26th, 2026 – 8:10 PM
Categorized as Computing Notes
URI: https://memorymatrix.cloud/archives/3258.html

It can be difficult to add a secondary storage to Nextcloud if the storage location is a new local drive. Authentication errors abound and leave one unable to use the additional space. To resolve this, add the drive to the system, and use the occ command to add the secondary storage. Add the new drive, whether real or virtual, and boot the machine. Then use lsblk to identify the drives. This is an example from my nextcloud instance:


NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0   480G  0 disk 
├─sda1   8:1    0   472G  0 part /
├─sda2   8:2    0     1K  0 part 
└─sda5   8:5    0     8G  0 part [SWAP]
sdb      8:16   0 464.3G  0 disk 
sr0     11:0    1  1024M  0 rom 

Create the path for the mounting of the partition via mkdir /mnt/secondary which is the path that I am using on this machine. Then use fdisk to setup the formatted partition. In the example above, the sdb device appears as the one that needs configuration. The command to begin is fdisk /dev/sdb and after that launches, use the menu to create a new partition ttable, add a new partition, set it to primary, write to disk, and exit. To confirm the existence of the partition, run a fresh lsblk and compare verify the output. After doing that, format the disk via mkfs -t ext4 /dev/sdb1.

Obtain the UUID of the new partition via the lsblk -f command. Example outpout of this command is:


lsblk -f
NAME   FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                           
├─sda1 ext4   1.0         d9720050-a770-4d6c-8620-78595132d60e   87.2G    76% /
├─sda2                                                                        
└─sda5 swap   1           f70c9ad7-e991-405b-b093-8b3c92ae8568                [SWAP]
sdb                                                                           
└─sdb1 ext4   1.0         8561c6b1-6cf0-4487-bf95-0cfb1befbb0f                
sr0   

Use nano to exit the mounting details via nano /etc/fstab. Add the new partition to that using noatime as an option, along with 0 and 2 as the parameters. The parameter noatime tells the system not to update the access time everyone a file is accessed and the 2 tells the operating system to continue booting if the disk is not present for some reason. Here is an example of the file where the data for sdb1 appears.


# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=d9720050-a770-4d6c-8620-78595132d60e /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=f70c9ad7-e991-405b-b093-8b3c92ae8568 none            swap    sw              0       0
/dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0       0
UUID=8561c6b1-6cf0-4487-bf95-0cfb1befbb0f /mnt/secondary  ext4    noatime         0       2

Then mount the new partition via mount -av which will process the fstab file. After that, cd into the /mnt directory and change the ownership of the secondary folder created earlier via chown -R www-data:www-data /mnt/secondary. The www-data user may not be the username. In this case, the webserver for the Nextcloud instance runs via the www-data account so that is the one that works here. After changing the ownership of that mountpoint, cd /var/www/html/nextcloud or whatever the Nextcloud path is for the PHP files. There should be an occ file present. Use the following command sudo -u www-data php occ files_external:create SECONDARY 'local' null::null -c datadir="/mnt/secondary" and SECONDARY will appear in Nextcloud as an external storage visible to all logged in users.