Data still syncing to SD card after changing datadirectory to USB

Hi community,

After being a NCP user for several years and solving any issue with info from several forums I would appreciate support on an issue I’m not able to solve myself.

  • Installation method:
    • NCP image v1.55.3

I changed the datadir to /media/USBdrive/ncdata/data using the webinterface.
However all data is still being synced to the SD card.

System info:

OS Armbian-unofficial 24.8.2 Bookworm \l . 6.6.45-current-bcm2711 (aarch64)
automount yes
USB devices sda
datadir /media/USBdrive/ncdata/data
data in SD yes
data filesystem ext2/ext3
data disk usage 12G/14G
rootfs usage 12G/14G
swapfile /var/swap
dbdir /media/USBdrive/ncdatabase
Nextcloud check ok
Nextcloud version 30.0.13.1
HTTPD service up
PHP service up
MariaDB service up
Redis service up
HPB service up
Postfix service up
Internet check ok
Public IPv4 xx.xxx.xxx.x
Public IPv6 not found
Port 80 open
Port 443 open
IP 192.168.0.59
Gateway 192.168.0.1
Interface end0

Nextcloud log:


{"reqId":"hzhCF4RY9vw3Bt9jjhFe","level":3,"time":"2025-08-12T05:09:43+00:00","re                                                                                                             moteAddr":"","user":"--","app":"no app in context","method":"","url":"--","messa                                                                                                             ge":"Redis server /var/run/redis/redis.sock:0 went away","userAgent":"--","versi                                                                                                             on":"30.0.13.1","exception":{"Exception":"RedisException","Message":"Redis serve                                                                                                             r /var/run/redis/redis.sock:0 went away","Code":0,"Trace":[{"file":"/var/www/nex                                                                                                             tcloud/lib/private/Memcache/Redis.php","line":60,"function":"get","class":"Redis                                                                                                             ","type":"->"},{"file":"/var/www/nextcloud/lib/autoloader.php","line":132,"funct                                                                                                             ion":"get","class":"OC\\Memcache\\Redis","type":"->"},{"function":"load","class"                                                                                                             :"OC\\Autoloader","type":"->"},{"file":"/var/www/nextcloud/lib/private/ServerCon                                                                                                             tainer.php","line":88,"function":"class_exists"},{"file":"/var/www/nextcloud/lib                                                                                                             /private/ServerContainer.php","line":170,"function":"getAppContainer","class":"O                                                                                                             C\\ServerContainer","type":"->"},{"file":"/var/www/nextcloud/lib/private/ServerC                                                                                                             ontainer.php","line":135,"function":"getAppContainerForService","class":"OC\\Ser                                                                                                             verContainer","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/                                                                                                             Utility/SimpleContainer.php","line":42,"function":"query","class":"OC\\ServerCon                                                                                                             tainer","type":"->"},{"file":"/var/www/nextcloud/lib/public/Server.php","line":3                                                                                                             9,"function":"get","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"                                                                                                             ->"},{"file":"/var/www/nextcloud/lib/private/Console/Application.php","line":189                                                                                                             ,"function":"get","class":"OCP\\Server","type":"::"},{"file":"/var/www/nextcloud                                                                                                             /lib/private/Console/Application.php","line":95,"function":"loadCommandsFromInfo                                                                                                             Xml","class":"OC\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud                                                                                                             /console.php","line":81,"function":"loadCommands","class":"OC\\Console\\Applicat                                                                                                             ion","type":"->"},{"file":"/var/www/nextcloud/occ","line":33,"args":["/var/www/n                                                                                                             extcloud/console.php"],"function":"require_once"}],"File":"/var/www/nextcloud/li                                                                                                             b/private/Memcache/Redis.php","Line":60,"message":"Redis server /var/run/redis/r                                                                                                             edis.sock:0 went away","exception":{},"CustomMessage":"Redis server /var/run/red                                                                                                             is/redis.sock:0 went away"}}

Nextcloud config.php:

<?php
$CONFIG = array (
  'passwordsalt' => 'MLwdfKidJxyh71MWIVJAkvPFR.....',
  'secret' => 'AOnNM7fK4jHw0Lyp3OOT9zGk1Yv345Jkj+fCt5OSlV.....',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    7 => 'nextcloudpi',
    5 => 'nextcloudpi.local',
    8 => 'nextcloudpi.lan',
    3 => 'xxx.ddns.net',
    14 => 'nextcloudpi',
    11 => 'xx.xxx.xxx.x',
    1 => '192.168.0.59',
    2 => 'xxxx.ddns.net',
    20 => '192.168.0.59',
  ),
  'datadirectory' => '/media/USBdrive/ncdata/data',
  'dbtype' => 'mysql',
  'version' => '30.0.13.1',
  'overwrite.cli.url' => 'https://xxx.ddns.net/',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'ncadmin',
  'dbpassword' => 'EoPrr6TvgNDOzFPy4/C0ZuGlCGBAJFfysj.............',
  'installed' => true,
  'instanceid' => 'ocut2g9g78ea',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'timeout' => 0.0,
    'password' => 'aqxBjzGfqjnIP21bRZ8zx76nVjgX8HoRn...........',
  ),
  'tempdirectory' => '/media/USBdrive/ncdata/data/tmp',
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_from_address' => 'info',
  'mail_domain' => '',
  'preview_max_x' => '2048',
  'preview_max_y' => '2048',
  'jpeg_quality' => '60',
  'overwriteprotocol' => 'https',
  'maintenance' => false,
  'logfile' => '/media/USBdrive/ncdata/data/nextcloud.log',
  'trusted_proxies' =>
  array (
    11 => '127.0.0.1',
    12 => '::1',
    14 => 'xx.xxx.xxx.x',
  ),
  'loglevel' => '2',
  'log_type' => 'file',
  'mail_sendmailmode' => 'smtp',
  'mail_smtphost' => 'mail.xxxx.nl',
  'mail_smtpport' => '465',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'xxx.xx',
  'mail_smtppassword' => '',
  'mail_smtpsecure' => 'ssl',
);

Not too much evidence about the facts, so my advice is reading
How to configure an external USB drive with NextcloudPi
Don’t hesitate to read the following discussion too.
I prefer using ncp-config as webui.

I red and followed the USB configuration guide.
In ncp-config I tried nc-datadir again.
It states INFO: data already there.
However, the data is still on the SD card.

When I unmount /dev/sda1 (the SSD) and mount it to /media/USBdrive/ncdata/data
data disk usage changes from 12G/14G (the SD card parameters) to the parameters corresponding with the SSD.

From there I probably need to change the paths (and probably owner) for database, swapfile and nextcloud logfile. I prefer to be 100% sure of knowing what to do in which order before making changes.

I don’t remember to have done anything else than running the script., you are you crate a file test.txt at your nc-user account and this file will be located on sd-card, not ssd?
Maybe you have aspare sd-card to setup a test server to exercise this data transition?

I tried a fresh installation with NCP image v1.55.3

Everything is working fine but, following the guide How to configure an external USB drive with NextcloudPi as has been mentioned above, nc-datadir unfortunately resulted in:

,
Running nc-datadir
Maintenance mode enabled
moving data directory from /opt/ncdata/data to /media/c5d9946d-f49a-a38a-0090-b7a9d0d0251c/ncdata/data/data…
{“reqId”:“D8AerL5Sss36keurKayM”,“level”:2,“time”:“2025-08-12T13:27:13+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“no app in context”,“method”:“”,“url”:“–”,“message”:“Temporary directory /opt/ncdata/data/tmp is not present or writable”,“userAgent”:“–”,“version”:“30.0.1.2”,“data”:}
Nextcloud is in maintenance mode, no apps are loaded.
Commands provided by apps are unavailable.
Your data directory is invalid.
Ensure there is a file called “.ncdata” in the root of the data directory. It should have the content: “# Nextcloud data directory”

Cannot create “data” directory.
This can usually be fixed by giving the web server write access to the root directory. See https://docs.nextcloud.com/server/30/go.php?to=admin-dir_permissions

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:137
Stack trace:
#0 /var/www/nextcloud/console.php(81): OC\Console\Application->loadCommands()
#1 /var/www/nextcloud/occ(11): require_once(‘…’)
#2 {main}Nextcloud is in maintenance mode, no apps are loaded.
Commands provided by apps are unavailable.
System config value logfile set to string /media/c5d9946d-f49a-a38a-0090-b7a9d0d0251c/ncdata/data/data/nextcloud.log
Nextcloud is in maintenance mode, no apps are loaded.
Commands provided by apps are unavailable.
System config value tempdirectory set to string /media/c5d9946d-f49a-a38a-0090-b7a9d0d0251c/ncdata/data/data/tmp
Installing template ‘php/opcache.ini.sh’…
Maintenance mode disabled
Installing template ‘ncp-metrics.cfg.sh’…
,

I entered /media/USBdrive/ncdata/data/ in DATADIR field

I don’t understand what is causing these faults and what is and where it is going wrong.
Any further directions would be highly appreciated.

ssh configured, log in, there must be a hint at update v1.55.4

Edit: We should consider an armbian-upgrade first.

Try first to do this update

pi@ncp-ct100:~$  sudo ncp-update
[sudo] password for pi:
Downloading updates
Performing updates
NextcloudPi updated to version v1.55.4
pi@ncp-ct100:~$

You also could do it within ncp-config. I propose doing all updates wanted now than advance with directory setup as last step.

I appreciate the support, let that be clear! This will be the last attempt, considering 3 days of struggling. After that I will leave the rpi image and follow a different path.

What are you running? rpi4 or rpi5?
I assume rpi5.

rpi4b+ 4Gb

So there should be no problem, mine is running 3+y at rpi400 usb boot device, and that is what you may think about, leave the sd card, setup an usb ssd device, my rpi4, rpi5 test boxes run from sd card img 1.553 just work.
So to circumvent the hustle with changing directories, may be usb boot device may be an option for you.

It is an option. If there is a guide I will follow it.

You may start here:
Raspberry PI 4 – Booting from USB Device (no microSD)

I tried it. The pi booted from usb but unfortunately the activation page didn’t show up. I tried different browsers with several settings without result.

From there I decided to install debianlite and installed apache, php, Mariadb and Nextcloud on top of it.

I got my Nextcloud-setup with data on SSD fully operational.

Very impressive and I am really glad to hear you got a working solution.

Just for my personal statistics, writing the images you do not use rpi-imager (no presets, maybe you used balena etcher?

I tried both rpi-imager and balena etcher with the same result.

I’lL try to install NCP on a RPI3B+ when I can find a suitable image.

Maybe NextcloudPi_RaspberryPi_v1.53.2.zip is a starting point, that is before dist-upgrade to bookworm, so many updates have to be done.

This spring we had nice conversations about rpi3 https://help.nextcloud.com/search?q=rpi3%20order%3Alatest.

Great, that means I found a suitable image. Thanks!

Thanks for pointing me to your discussion from last spring.

You may also take a look at the release notes at Nextcloudpi on github; the issue section with their discussions may be of some interest to you.
Good luck and much fun.