Possible to get nextcloud to run from USB-harddrive?

Thanks for the awesome DietPi project, it is simply just fantastic!

I wonder though if it’s possible to get Nextcloud to store the database onto my USB-harddrive that i have set as the primary storage unit, directly after the initial setup. I thought that dietpi would change the database the the USB-harddrive automatically during the nextcloud installation?

Or does this only work for OwnCloud?

Thanks in advance!

Hi,

The MySQL DB is stored on rootfs (eg: flash/sd). The user data (eg: stuff you save to NextCloud) is stored in the dietpi user data location, which can be changed:

I’ve created a ticket, we’ll look at also including MySQL DB’s as user data:https://github.com/Fourdee/DietPi/issues/672

Thank you, i will look into that!

It also seems that my USB Harddrive is not reachable from time to time, i think it has to do with some setting like hdd spindown. Is it possible to change that setting somewhere so that the usb harddrive is always active and running?

Just to fill on the issue i’m getting.

Nextcloud login page is now stating:

" Data directory (/mnt/dietpi_userdata/nextcloud_data) is invalid
Please check that the data directory contains a file “.ocdata” in its root "

you can literally just create a simple text file in that directory named .ocdata

it sounds like you didn’t migrate the contents of your old nextcloud-data folder to the new one - try copying all the files/folders from the old location to the new, including hidden files/folders.

Yep, Disable the following from /etc/hdparm.conf:

#DietPi external USB drive. Power management settings.
/dev/sda {
        #10 mins
        spindown_time = 120

        #
        apm = 254
}



" Data directory (/mnt/dietpi_userdata/nextcloud_data) is invalid
Please check that the data directory contains a file “.ocdata” in its root "

Strange, did you transfer the userdata location using dietpi-drive_manager or dietpi-software?

Lets check current userdata locations and contents, please paste results:

ls -lha /mnt/dietpi_userdata
ls -lha /mnt

If your USB drive is attached, please also run:

ls -lha /mnt/usb_1
  1. ls -lha /mnt/dietpi_userdata gave the following:
lrwxrwxrwx 1 root root 10 Dec 28 10:38 /mnt/dietpi_userdata -> /mnt/usb_1
  1. ls -lha /mnt:
total 40K
drwxr-xr-x 10 root root 4.0K Dec 28 10:38 .
drwxr-xr-x 20 root root 4.0K Dec 28 10:35 ..
lrwxrwxrwx  1 root root   10 Dec 28 10:38 dietpi_userdata -> /mnt/usb_1
drwxr-xr-x  2 root root 4.0K Nov  1 16:50 ftp_client
drwxr-xr-x  2 root root 4.0K Nov  1 16:47 nfs_client
drwxr-xr-x  2 root root 4.0K Nov  1 16:50 samba
drwxrwxr-x  9 root root 4.0K Dec 28 10:53 usb_1
drwxr-xr-x  2 root root 4.0K Dec 28 10:35 usb_2
drwxr-xr-x  2 root root 4.0K Dec 28 10:35 usb_3
drwxr-xr-x  2 root root 4.0K Dec 28 10:35 usb_4
drwxr-xr-x  2 root root 4.0K Dec 28 10:35 usb_5
  1. ls -lha /mnt/usb_1:
total 101M
drwxrwxr-x  9 root     root     4.0K Dec 28 10:53 .
drwxr-xr-x 10 root     root     4.0K Dec 28 10:38 ..
drwxrwxr-x  2 root     root     4.0K Dec 28 10:38 downloads
drwxrwxr-x  2 root     root      16K Dec 28 10:35 lost+found
drwxrwxr-x  2 root     root     4.0K Dec 28 10:38 Music
drwxrwx---  5 www-data www-data 4.0K Dec 28 11:10 nextcloud_data
drwxrwxr-x  2 root     root     4.0K Dec 28 10:38 Pictures
-rwxrwxr-x  1 root     root     100M Dec 28 10:38 .swapfile
drwxrwxr-x  6 urbackup urbackup 4.0K Jan  1 21:12 urbackup
drwxrwxr-x  2 root     root     4.0K Dec 28 10:38 Video



Strange, did you transfer the userdata location using dietpi-drive_manager or dietpi-software?

Yes i did change dietpi to use usb-harddrive instead of sd-card even before installing Nextcloud. Maybe it has been installing it some on the harddrive and some of the sdcard because of the spindown?

I tried the ls -lha /mnt/usb_1 again after waiting to see if the spindown has taken effect. And i now get:

root@DietPi-cloud:~# ls -lha /mnt/usb_1
ls: reading directory /mnt/usb_1: Input/output error

Hi, data locations look fine and expected folders in usb_1 exist.

I/O indicates a possible HDD failure at the basic level, even if there are filesystem errors, the IO is a major concern and the drive shouldn’t be used for important files/data.
Was the drive spun down when you ran this command?

It could be a lack of power, especially if its a 2.5inch with USB power, make sure you have at least a 5v/2a PSU. Even then, it really needs to be an official PSU from RPi or Odroid for proven stability.

Might also be worth checking the drive for filesystem errors:

fsck /dev/sda1 -f

Failing that, you’ll need to check the SMART status of drive, should provide info on drive health:
https://www.howtoforge.com/checking-hard-disk-sanity-with-smartmontools-debian-ubuntu

Yes the HDD was probably spun down when i ran the command, even though i disabled the settings in hdparm.conf.
I will check the power supply and see if it provides too little power to run the rpi 3 + usb hdd, thanks!

I reinstalled Nextcloud to make sure that all the files are on the USB HDD.

I will let you know how it goes, thanks for all your help!

I uninstalled Nextcloud and disabled the hdparm.conf line as you recommended, it has been working now without any issues for several hours!
I will let you know if this changes.

Thank you so very much for all the help!!

Have you edit the line at the config.php?

datadirectory => var/www/owncloud/data

I think you haft to edit this line for the storage place.

And one more thing is if the disk is spinning all the time will get warm.It is faster to respond but…!!!
I had setup it in this style and i didnt like cose is not safe also for the data.
Keep us informed whith your setup cose I’m also interesting.

I’ve tested my configuration out a bit now and this is what i’ve done so far.

I’ve changed the spindown back on, since the longer duration (lifetime) of the hard drive is much more appreciated than speed.
i.e made no changes to etc/hdparm.conf everything is now working as expected. I just reinstalled Nextcloud and chose force USB under drive manager. Hope that might help others encountering similar issues in the future!

Hi. Im planning to store my data on an external 2.5" HDD connecting it to my OPi with this cable (or similar) and a dedicated power supply for it. Would it be necessary to edit the hdparam.conf to avoid spindwon?

Thanks.

Unknown on this adapter, but if in doubt, disabling the spin down feature would be beneficial to avoid a possible issue.