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?
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).
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).
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)
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?
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).