How to configure NextCloudPi v1.46.7 to use an external USB drive

I wanted to configure Nextcloudpi v1.46.7 to use an external drive to store all my data and files since my microSD card lacks the capacity to store all my files. This is how I got it working by following this guide

Insert your USB drive to RaspberryPi. I'm using a 1TB SSD USB drive.

Login to your Nextcloudpi web interface:

https://192.168.0.28:4443

Replace 192.168.0.28 with your own RaspberryPi IP address. You need the port number 4443. If you are having issues using Chrome to access your Nextcloudpi, use Firefox instead. 

First, we will format the drive to BTRFS file system. Note 1: In order for you to be able to use an external USB drive, the USB drive must not be formatted as NTFS/FAT as these do not support the user/permission system.

nc-format-USB

Navigate to nc-format-USB in the main menu on the left of the screen. Change the LABEL to a label you like. This is also the name of the directory that the USB drive will mount to (i.e, /media/"myLabel"). I named my label CloudStorage (so my path is now: /media/CloudStorage). Then click apply button and after that click Run or Start.

Now we need to mount the drive. In the main menu on the left of your screen, look for nc-automount menu link and click on it. 

nc-automount

Click on the checkbox and click apply button. Then, click Run or Start.

Navigate to nc-datadir. Change DATADIR to your data location in the mount point (for example, my data directory is the mount point i created earlier: /media/CloudStorage). Click apply button, then click Run or Start.

nc-datadir

Now you can test to see if you can upload files. Login to your nextcloud:

https://192.168.0.28

Replace IP address with your RaspberryPi IP address but do not add the port number this time to access your Nextcloud frontend. Go to file menu and upload a file to test. If it works, you are good to go. But to be sure, you can SSH to the raspberryPi and check if the files have been written to your external drive. Here's the problem though, you will a permission error when you try to view the data directory (this is where the files are located). To get pass this, in your terminal, type:

sudo -i

Now you can change directory to your data directory. The path should be cd /media/{your_label_name}/data

When you are done, type:

exit

Or you can list all files using (sudo -u www-data ls -la /path/to/folder):

sudo -u www-data ls -la /media/{your_label_name}/data

Replace {your_label_name} with your own. 

This was an excellent advice at https://kenfavors.com/code/how-to-access-nextcloud-data-directory/ 

Anyway, I was not so lucky and encountered problem at this stage. 

Problems after mounting external drive and moving next cloud data over

I was getting this error message (below) when i tried to upload a file:

Expected filesize of 10485760 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 8192 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.

 I think this error was cause by a broken path to temp directory. Luckily, it turned out to be an easy fix:

  • Navigate to nc-fix-permissions and click on apply.
  • SSH to your RaspberryPi and in the terminal, type:
    sudo nano /var/www/nextcloud/config/config.php

    Change the line: ‘tempdirectory‘ => ‘/media/USBdrive/ncdata/tmp’ to
     

    ‘tempdirectory‘ => ‘/var/www/nextcloud/data/tmp’

     

Save it and restart all servers, by typing: 
 

sudo systemctl restart {apache2,mysql,php7.3-fpm}

If this does not work for you, see other suggestions for help

If you want to add another USB drive, you need to disconnect your current one and go thru the same process and then connect all your USB drive again. 

If for some reason you wanted to connect your external USB drive into Windows PC to view the content of the drive, it would not be recognised by Windows because it does not support BTRFS (ie, file system). You need to install WinBtrfs driver for Windows. To install the driver, right-click btrfs.inf, and choose Install. See: https://www.ilovefreesoftware.com/19/tutorial/how-to-mount-btrfs-volumes-on-windows-10.html

Linux can read BTRFS so no issue there. However, MacOS is not able to and i can't find a driver for it? anyone know, please leave comment below. 

 

The content of this field is kept private and will not be shown publicly.
Your email address will be kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.