"Cannot create or write into the data directory" Raspberry OS (not docker)


So I can’t get past the error in the title on the install screen.

I had NextCloud up and running until a few days ago when it crashed and caused a faulty partition. I didn’t manage do save the data from the microSD card, but all my personal files are on an external HDD.
So I’ve flashed the microSD card with Raspberry OS, then following a guide installed the latest version of PHP (8.3) and all the packages NextCloud needs, downloaded the NextCloud zip and unpacked it, created an sql database, then fired up NextCloud in my browser from my PC.
So far so good, but when I point the install page to my data drive containing the data from the previous installation, it says it can’t write there. I’ve tried everything I can think of, including changing ownership of all files and folders to www-data:www-data, as well as root and the user, I even set chmod -R 777 to the entire folder, and also created a new empty data folder and tried that. It seems NextCloud can’t access the external drive at all. And I have no idea why.

My entire setup process is here, in case that sheds any light: Raspberry Pi / Nextcloud install - Pastebin.com

Data folder is located in /media/buggie/myCloudDrive/ncdata/data

Drive is formatted in Btrfs, and the only difference is previously it was mounted directely in /media/, now it’s in /media/buggie/. Not sure why that changed.
ls -l in /media/buggie/myCloudDrive/ gives me

drwxrwxrwx 1 www-data www-data  14 Oct  8 16:34  ncdata

ls -l in /media/buggie/myCloudDrive/ncdata/ gives me

drwxrwxrwx 1 www-data www-data 204 Oct 16 03:38 data
drwxrwxrwx 1 www-data www-data  42 Feb  6 19:14 tmp

As I said, I chmod 777 everything for now to try and figure out what’s going on. I’ll correct it when NextCloud install works.

Thanks in advance for anyone who can point me in the right direction.

Just a message to say I never found a fix. I reinstalled Raspberry OS and then installed NextCloud using the Curl script on the bottom of this page:

Though the script doesn’t work with the latest version of Raspberry OS yet.