[SOLVED] Nextcloud external storage configuration (HDD) and becoming 'www-data'

I want to configure Nextcloud to store and access files on an external hard drive I have connected to my FreedomBox.

In my FreedomBox’s Storage system setting, I see it listed like this:

Device: /dev/sda1
Mount point: /media/root/a-long-number

I found this thread [SOLVED] Nextcloud accessing SSD started by another user and followed the instructions posted by @nbenedek.

  1. While logged in as the admin user in Plinth, I created a new user named serviceuser in the Users and Groups category.
  2. I SSHed into my FreedomBox as the admin user and entered the command sudo chown -R serviceuser /media/root/a-long-number
  3. I configured Nextcloud like the attached image in the post with the following parameters:

Folder name: /dev/sda1
External storage: SFTP
Authentication: Login and password
Configuration: localhost [blank] /media/root/a-long-number serviceuser [password for serviceuser]

and I received the error Exception: Login failed. I made sure to enter the serviceuser and admin passwords correctly.

I decided to try the Local storage option. After I enabled External Storage, I selected Local for the storage type, put /dev/sda1 in the Folder name field, and /media/root/a-long-number in the Configuration field. It tells me that local storage path does not exist /media/root/a-long-number.

I visited the Nextcloud documentation to try and find an answer, and found some pages addressing Local storage configurations:

https: // docs .nextcloud.com/server/latest/admin_manual/configuration_files/external_storage/local.html

I see listed some commands that are similar to @nbenedek’s approach:

sudo chown -R www-data:www-data /path/to/localdir
sudo chmod -R 0750 /path/to/localdir

sudo -u www-data bash
cd /path/to/localdir
mkdir data

My questions are:

  1. The other user seemed to get @nbenedek’s method to work. Where have I made an error?
  2. How do I become www-data so I may try this approach as well? Entering my admin password as sudo doesn’t work, nor does entering my password when I try the command su.

Thank you for reading my post.

I received the error Exception: Login failed. I made sure to enter the serviceuser and admin passwords correctly.

This sounds like the user wasn’t able to log in. You should check under https://example.com/plinth/sys/ssh/ the settings of Disable password authentication and Allow all users to login remotely.

If you disabled password authentication, make sure to add a public key to your service user and use that key pair to authenticate to the storage. This is not a requirement though, if this is not ticked, you can choose to leave it as it is.

If you have Allow all users to login remotely disabled, then make sure to add the service user to the ssh group: tick Remotely login using Secure Shell (SSH) (freedombox-ssh) under https://example.com/plinth/sys/users/serviceuser/edit/.

How do I become www-data so I may try this approach as well? Entering my admin password as sudo doesn’t work, nor does entering my password when I try the command su.

Making www-data the owner of your files is only applicable if you are mounting a local storage. Nextcloud on FreedomBox is running inside a container, so the container does not see directories of your Freedombox unless you explicitly mount them in the container. In the previous discussion I recommended using SFTP so that we don’t have to manually modify the container config and mount local directories. To answer your question, you’re not supposed to log in directly with the www-data user.

This was exactly the root of the problem. Once I put serviceuser inside the freedombox-ssh group, I was able to save the configuration without an error. Thank you so much!

I appreciate you taking the time to explain this to me, as I now understand the logic behind your workaround. This is good to know.

1 Like