Nextcloud does not allow moving the data folder?

hello you should not mix server with client and system user with normal user. And aside the linux users are separately from the cloud users unless your using ldap which you do not.

reading your post I assume you have no knlowledge of what your doing. ( no offence everyone needs to start somewhere ) .

yet imo you have choosen the best/easiest maintainable installation.

looking at your screenshot it looks like everything should be working as it is.

yes nextcloud will be installed in /var/www/nextcloud this is correct and fyi is not the root folder which would be /nextcloud

you should familiarize yourself with the linux filestructure / /home /usr /var and how file permisions work.

nextcloud is only a website it does nothing for you system related. You will have to tell the system what to do with nextcloud.

your current data location is /var/www/nextcloud/data it is owned by a system-user. this user (www-data) has been disabled to login as it is not a real user. it is only used to run specific applications in this case apache webserver.

a normal user that can login should not be able to edit files in /var/www as this location is set for the webserver thus you would need root access as a user to edit here.

to change you data location you only need to prepare the new location with the correct permissons and set it in your config.

first you must find where the ssd is mounted.
you can list your hdd/ssd with

fdisk -l

you will see your disk and it’s device name ex. /dev/sda

now use

df -h

this will show a list of your filesystem and where they are mounted.

lets say /dev/sda1 is mounted at /mnt/8TBdata and you want the whole drive to be your data folder for nextcloud. then this folder /mnt/8TBdata needs to be writable by the www-data user. there are two things that set permissions the user and the file/folder.

setting the user we use

sudo chown www-data:www-data /mnt/8TBdata

setting the file we use

sudo chmod 750 /mnt/8TBdata

once set ls -l /media should return

drwxr-x— 2 www-data www-data 4096 mar 20 2023 8TBdata

you can now set maintenance on.

sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --on

copy the existing data to it’s new location

sudo -u www-data cp -r /var/www/nextcloud/data/. /mnt/8TBdata/

set your new data location.

sudo -u www-data php /var/www/nextcloud/occ config:system:set datadirectory --value=/mnt/8TBdata

disable maintenance

sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --off

so in short

set correct permissions on new disk.
copy nextcloud user data.
set new location in config.php.

there are many posts about the data directory that have usefull information.

there is no one tutorial that fits all needs.

1 Like