Pi4 New installation fail when trying to set SSD as datastorage

I’m setting up a Raspberry pi 4 with the AIO installation. This is working like a charm (the installation and the nextcloud). But I couldn’t figure out how to change the datastore from the SD card to an SSD drive. I tried to follow the instructions but I’m no expert in linux. So I decided to redo a complete new installation and follow this guide:

so I formatted the drive using these commands:

sudo fdisk /dev/sda1
	n (new partition)
	p (primary partition)
	1 (partition number)
	<enter} use default starting sector
	<enter} use default last sector
	w (write partition to disk)
(at this point there was an error because old partition was still in memory.  reboot)
reboot
sudo mkfs -t ext4 /dev/sda1

and then I assigned this SSD as a USBdrive like this:

sudo mkdir -p /USBdrive
sudo mount /dev/sda1 /USBdrive
ls -lh /dev/disk/by-uuid/
From that command, retreive the UUID of the external drive
sudo nano /etc/fstab
then add this line to the end of fstab
UUID=b1337022-770a-4c79-af05-bd76870a6d65 /USBdrive ext4 rw,users 0 0
reboot
sudo chmod -R 777 /USBdrive
sudo chown -R www-data /USBdrive

and then I redid the AIO installation using this docker command:

sudo docker run
–sig-proxy=false
–name nextcloud-aio-mastercontainer
–restart always
–publish 80:80
–publish 8080:8080
–publish 8443:8443
–volume nextcloud_aio_mastercontainer:/mnt/docker-aio-config
–volume /var/run/docker.sock:/var/run/docker.sock:ro
–env NEXTCLOUD_DATADIR=“/USBdrive/nextcloud”
nextcloud/all-in-one:latest

I really thought it was going to work as it did create the nextcloud directory on the USBdrive but then, it just hang while trying to start the container nextcloud. The log shows that it doesn’t have the right password. I’m kind of surprise to get a password error at this point but here is the log;

Connection to nextcloud-aio-database (172.18.0.4) 5432 port [tcp/postgresql] succeeded!
+ '[' -f /dev-dri-group-was-added ']'
++ find /dev -maxdepth 1 -mindepth 1 -name dri
+ '[' -n '' ']'
+ set +x
Enabling Imagick...
WARNING: opening from cache https://dl-cdn.alpinelinux.org/alpine/v3.19/main: No such file or directory
WARNING: opening from cache https://dl-cdn.alpinelinux.org/alpine/v3.19/community: No such file or directory
Configuring Redis as session handler...
Initializing nextcloud 27.1.5.1 ...
Initializing finished
New Nextcloud instance.
Installing with PostgreSQL database
Starting Nextcloud installation...
PostgreSQL username and/or password not valid
 -> You need to enter details of an existing account.
Trace: #0 /var/www/html/lib/private/Setup.php(356): OC\Setup\PostgreSQL->setupDatabase('admin')
#1 /var/www/html/core/Command/Maintenance/Install.php(115): OC\Setup->install(Array, NULL)
#2 /var/www/html/3rdparty/symfony/console/Command/Command.php(298): OC\Core\Command\Maintenance\Install->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /var/www/html/3rdparty/symfony/console/Application.php(1040): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /var/www/html/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand(Object(OC\Core\Command\Maintenance\Install), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /var/www/html/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /var/www/html/lib/private/Console/Application.php(211): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /var/www/html/console.php(100): OC\Console\Application->run()
#8 /var/www/html/occ(11): require_once('/var/www/html/c...')

}

Previous: Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[08006] [7] connection to server at "nextcloud-aio-database" (172.18.0.4), port 5432 failed: FATAL:  password authentication failed for user "oc_nextcloud"
Trace: #0 /var/www/html/lib/private/Setup/PostgreSQL.php(112): OC\DB\Connection->connect()
#1 /var/www/html/lib/private/Setup.php(356): OC\Setup\PostgreSQL->setupDatabase('admin')
#2 /var/www/html/core/Command/Maintenance/Install.php(115): OC\Setup->install(Array, NULL)
#3 /var/www/html/3rdparty/symfony/console/Command/Command.php(298): OC\Core\Command\Maintenance\Install->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /var/www/html/3rdparty/symfony/console/Application.php(1040): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /var/www/html/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand(Object(OC\Core\Command\Maintenance\Install), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /var/www/html/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /var/www/html/lib/private/Console/Application.php(211): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /var/www/html/console.php(100): OC\Console\Application->run()
#9 /var/www/html/occ(11): require_once('/var/www/html/c...')
#10 {main}
Installation of Nextcloud failed!
Connection to nextcloud-aio-database (172.18.0.4) 5432 port [tcp/postgresql] succeeded!
psql: error: connection to server at "nextcloud-aio-database" (172.18.0.4), port 5432 failed: FATAL:  password authentication failed for user "oc_nextcloud"
Waiting for the database to start...
psql: error: connection to server at "nextcloud-aio-database" (172.18.0.4), port 5432 failed: FATAL:  password authentication failed for user "oc_nextcloud"
Waiting for the database to start...

then repeated this 3 next lines forever

psql: error: connection to server at "nextcloud-aio-database" (172.18.0.4), port 5432 failed: FATAL:  password authentication failed for user "oc_nextcloud"
Waiting for the database to start...

I’m wondering if this was just a bad connection to the internet, or if really I did something wrong.
I just want to mention that this is a newly formatted SD card, with a new PI OS so everything is just clean as it could be. And the AIO installation I did just before (without the external drive) worked perfectly.
Thanks for your support.

Hi, can you follow https://github.com/nextcloud/all-in-one?tab=readme-ov-file#how-to-properly-reset-the-instance and try again?

OK, I’ll try it tonight then. I’ll post the result later.
Thanks

OK, Resetting the instance went very well. »Thank you.
I didn’t take any chance, I hooked up the raspberry pi to the hub and shut down the wifi. The Pi is not known for a good wifi.
Then redid the installation using the USBdrive and everything went well.
Thank you very much!