Adding more space to NC (Ubuntu)

I was looking for a tutorial on this matter but couldn’t manage to succefully do this:

My ubuntu is installed initially on a single 500GB HDD and after configuring everything I am able to see only about 450GB free space in my Nexctloud (which is normal). Now I installed 2 additiong internal HDDs (4TB each). Mounted them in nextcloud data folder and I see them listed in my NC system settings but the available space is still only ~450GB. How do I add the space of these 2x4TB drives to my nextcloud?

I would also like to add aditional external HDD available only for a specific user. So how to do this as well?

And finally - is it possible to mirror/backup my files so if any of my hdd fails I would have a backup?

Thank you in advance!

Nextcloud uses only one folder defined in config/config.php.
'datadirectory' => '/var/www/nextcloud/data',

I think you must move all data to the new HDD and then re-mount it or use another path for datadirectory Then you must also use:

sudo -u www-data php occ files:scan --help

Another option is to use External Storage . In your case, however, i would not use it.

When I ran the sudo -u www-data php occ files:scan --help I got an error: Could not open input file: occ. So I thoough i have a privileges problem and searched online how to give access to all users in my system (only me and some system users\groups).
I ran several 744 and 774 chmod commands to nextcloud paths and now when I try to open my nextcloud I get the message : Forbidden: You don't have permission to access this resource..

Tried sudo chown -R www-data:www-data nextcloud/ but couldn’t fix it. So now I am trying to geet my access back and fix the Could not open input file: occ


What are the chmod commands given and at what location.

you probably ran the command

sudo -u www-data php occ files:scan --help

in your home or root directory and not from your NC installation directory.

for restoring permission

Also check this post and consider lvm for the future

Thanks Vincent!

I will definetelly look up lvm once I fix my system.
You were right that I was not tunning the sudo -u www-data php occ files:scan --help in the correct directory. Running it in the nextcloud directory gives the following errors which I’ve just found and did not research on my own yet:

PHP Warning:  require_once(/var/www/nextcloud/console.php): Failed to open stream: Permission denied in /var/www/nextcloud/occ on line 11
PHP Fatal error:  Uncaught Error: Failed opening required '/var/www/nextcloud/console.php' (include_path='.:/usr/share/php') in /var/www/nextcloud/occ:11
Stack trace:
#0 {main}
  thrown in /var/www/nextcloud/occ on line 11

occ file at line 11:

require_once __DIR__ . '/console.php';

Meanwhile, the restoring of the permissions seems not working for me. I’ve ran the 2 commands you are offering in the correct directory. But I still don’t have access when I try to enter my NC (locally and remotely). I’ve looked up the commands I ran when things messed up and I see I’ve ran also sudo chmod 774 /var/www. Might that be another reason for the NC to deny access and if yes - what number chmod should I assign to it?

Depending on the user:group of /var/www that might be a problem

directories should be 750
files should be 640

this means
7 user rights rwx
5 group rights r-x
0 other right —

6 user right rw-
4 group rights r–
0 other rights —

666 gives everyone write access 664 gives everyone read access user and group may write 644 everyone can read only user can write

user:group is set with chown

/var/www is in my case owned by www-data and group www-data as it is a directory chmod 750 or if you have users in the group www-data that need write access use 770

the last 0 — prevents any user not in group www-data to have access to it. if you need other users to have access change it to 5 r-x

looking over all commands it should have access already.
look specificly at permissions of

ls -l /var/www/nextcloud/console.php

Thank you Vincent, your answers are very contenful and descriptive. Appreciate that!
I managed to restore access with

sudo chown -R www-data:www-data /var/www/

This also cleared the errors which sudo -u www-data php occ files:scan --help was issuing.

Now to get back of adding more disk space to NC:
In my data folder I created 2 subfolders named “A” and “B”. One for each internal HDD.
The disks are named sdb and sdc.

But as you see my total free space is not affacted.
Also, in All Files I see only the basic NC files which were created on installation.

Yes This overview simply shows all disk available in the system.

For me this is useful when I connect my backup disk it appears and I can see if there is sufficient space to backup. However this is not relevant.

in short:

  • I would advice you to create a LVM with the 2 new disk.
  • copy the current data to the new lvm
  • set maintenance mode on
  • set config.php to your new LVM directory
  • rsync changed files on last time
  • disable maintenance mode

then when all works you can remove the old data eventually shrink your root partition create a new partition and add it to the LVM

Setup LVM

fdisk /dev/sd[b,c] change partition to Linux LVM 8e or 31
sudo pvcreate /dev/sdb1 /dev/sdc1
#sudo pvs [to check results]
sudo vgcreate cloud /dev/sdb1 /dev/sdc1
#sudo vgs [to check results]
sudo lvcreate -l 100%FREE -n data cloud
#sudo lvs [to check results]
sudo mkfs.ext4 /dev/cloud/data
sudo mkdir /cloud
#copy the UUID of /dev/mapper/cloud-data
sudo nano /etc/fstab
#add the following to fstab
UUID=xxxxx-xxxxxx-xxxxxx-xxxxxx /cloud ext4 defaults 0 2
#quit nano :q
sudo mount -a

at this point you should have your 2 disk mounted under the directory /cloud
set the correct permissions on this directory.

If you followed this path and reached this point and need further instructions let us know

Although the super helpful answer from Vincent, I did my own research and decided to use RAID instead of LVM, because of more reliability in case of failure - as far as I read the LVM has also data mirroring but I found more info about this matter online for raid system and I decided to choose that.

I followed these steps as well as Vincent’s advice to set the RAID 1.:

I set the ownership of the mounting folder to www-data and edited the nextcloud’s config.php file and was ready to check for any progress, but when I started NC there was a error of a missing “.ocdata” file which I simply copied from the old data folder to the new and everything is up and runing now.

Thank you all and especially Vincent for the very helpful advices!

1 Like

I enjoyed too fast…

It seems that the problems with the permissions persist.
At first, when I resolved the missing .ocdata file by copying it, I was able to enter NC dashboard, but I wasn’t able to manage files. A simple upload would give “Forbidden” message, not able to open/delete existing files as well. Tried to set the accurate permissions following thtis advice:

directories should be 750
files should be 640

But I got the missing .ocdata error again and I can not fix it for now. Switching the data directory back to the old one fixes the problem but I’m using only the main hdd, where Ubuntu was installed.

Any ideas would be welcome.
Here are the permissions of my data folder as of now :

NC config.php:

'datadirectory' => '/mnt/md0/nextcloud/data',

you made a wise choice to read up and setup on your own way.

simply look at your directories as user www-data

it needs atleast read access in /mnt/md0/nextcloud
and atleast write access in data

check owner of /mnt

if its root:root user:group so user www-data is other it needs read access here and execute as its a directory

if it 750 drwxr-x— change to 755 drwxr-xr-x

chmod 755 /mnt

do this for /mnt/md0 if not owned by www-data

from /mnt/md0/nextcloud the owner:group can be www-data:www-data and chmod 750 should be applied


If for security reasons 755 is not permitted by yourself the alternative approach would be to change the group of /mnt/md0 either to www-data or to a newly created group and add www-data to that newly created group.