Raspberry Pi 4: Nextcloud Database Location

Hi,

I’m following this guide to install Nextcloud on my Pi 4 which I’m hoping to use with an attached USB 3 SSD:

How to Setup a Raspberry Pi Nextcloud Server - Pi My Life Up

At this section, the author decide’s to move the Nextcloud data and I went with it thinking that makes sense only now I’m not so sure. Why does the author move the entire nextcloud data set when actually all that is presumably wanted is to point Nextcloud at the location he wants the data (in my case the USB 3 attached SSD)?

If I’m right, can someone tell me how I can tell Nextcloud I want it to use my USB device as the data store?

Thanks

James

Their primary goal sounds like it was to move the datadirectory out of /var/www and off of the SD card post-install.

Since the installation was already completed and at least one account active (admin), the existing /var/www/nextcloud/data folder contents would have to get moved into the new location. Just changing the datadirectory value would have caused the loss of the admin accounts home directory. That would be the entire Nextcloud data set (the file based piece anyway; database is a different animal).

They do skip over cleaning up the oc_storages table. AFAIK that’s still a reasonable idea (see General troubleshooting — Nextcloud latest Administration Manual latest documentation), but I haven’t had to change the base path of the datadirectory recently.

If the main goal is to simply get it off the SD card post-install, another approach would be to copy the contents of /var/www/nextcloud/data to the root of the second drive (mounted somewhere temporary). Then to remount the second drive in place of /var/www/nextcloud/data. That would be invisible to Nextcloud (as long as it’s not running during all this).

That all said, the data directory can also be specified during setup so… Then the above moving step is not at all necessary: Installation wizard — Nextcloud latest Administration Manual latest documentation (you will still need to get your second drive mounted appropriately in the OS but that’s the case no matter what).

Obviously there are several different ways of accomplishing the same thing (or roughly the same thing). I’d personally do it during installation (not post-install) if possible (since it’s cleaner and less error prone).

Btw, while you’re thinking through this two other things come to mind:

  • you can boot your Pi 4 entirely from the USB drive and ditch the SD card outright and then not have to mess with any of this at all (at least for data storage allocation purposes)
  • don’t overlook the database. MariaDB’s /var/lib/mysql or equivalent should probably not be on the SD card either if possible. That may change how you partition the second drive since not all of it would be for the NC datadirectory (less of an issue if you outright install the OS and boot from the USB drive)

Hi Josh,

Thanks, the idea of remounting to the data directory sounds like a good one however, the idea of booting from USB sounds better/easier.

I’ve got to a certain point in my build; nextcloud is working but I haven’t mounted the SSD or moved the data so my question is, if I image my current build to the SSD does that mean I can remove the MicroSD, plug in the SSD and it’ll just work? I know Linux uses things like sda, sdb so I’m not sure how that’ll translate.

Also, is there likely to be any speed loss (or gain) doing it that way?

James

Depends a little on how how much you’ve deviated from defaults/etc. You’ll probably have to update PARTUUID’s references in /etc/fstab and possibly kernel boot files. Make sure your Pi 4 is running recent enough firmware to support USB Mass Storage booting (check raspberrypi.org docs).

e.g. https://gist.github.com/avoidik/d8fc39a372db680090edd5322d60848f

Gain. Nearly all SSD drives in use are significantly faster than even the best SD cards.

Hi Josh,

I already had an image and blow me if it didn’t work perfectly first time :slight_smile:

Yes it does seem faster (I also did some tests that confirmed that) but the bit that literally flew was the image to disk; used to take several minutes but was done in not much over 30 seconds.

So now, all I have to do is go through the rest of that article, configuring nextcloud for use and, of course, documenting it all.

Thanks you for your help :slight_smile:

James

1 Like