How to configure an external USB drive with NextcloudPi

This guide will help you configure an external USB drive.

:: Important note ::
If you are using only one USB drive, you can leave the default path /media/USBdrive for all configuration options, but if you are going to use more than one you need to reference them by label, or NCP will not be able to know which one is which.
For instance, if the label of the drive is mylabel then use the path /media/mylabel for items such as nc-datadir, nc-database and so on.


  1. Format USB drive (optional but check note).

  2. Enable nc-automount.

  3. Configure Nextcloud data to be on the USB drive.

  4. Configure Database data to be on the USB drive (optional).

  5. Configure Swap on the USB drive (optional).

Format USB drive (optional)

nc-format-USB will format your external USB drive to BTRFS, with the given Label.

:: Note ::
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, this will format all USB drives you have connected to the Raspberry Pi.

  1. Navigate to nc-format-USB in the TUI or the WebUI.

  2. Change the LABEL to a label you like. This is also the name of the directory that the USB drive will mount to (e.x. /media/“myLabel”).

  3. Click Run or Start.

Enable nc-automount

To enable nc-automount follow the steps:

  1. Navigate to nc-automount in the TUI or the WebUI.

  2. Change ACTIVE to yes.

  3. Click Run or Start.

Configure Nextcloud data to be on the USB drive

To make Nextcloud data directory to be on the USB drive, follow the steps:

  1. Navigate to nc-datadir in the TUI or the WebUI.

  2. Change DATADIR to your data location in the mount point.

  3. Click Run or Start.

Configure Database data to be on the USB drive (optional).

To make Database data to be on the USB Drive, follow the steps:

  1. Navigate to nc-database in the TUI or the WebUI.

  2. Change DBDIR to your database location in the mount point.

  3. Click Run or Start.

Configure Swap on the USB drive (optional).

:: Note ::
This is not supported in BTRFS, use ZRAM for that

To configure Swap location and size, follow the steps:

  1. Navigate to nc-swapfile in the TUI or the WebUI.

  2. Change the SWAPFILE to the desired location in the mount point.

  3. Change the SWAPSIZE to the desired size of Swap File (Default: 1024MB).

Now you have configured NextCloudPi to use an external USB drive for Nextcloud data, optionally Database data and Swap.

We hope this doc was helpful, if you encounter any issues please reach out to the community.
These docs are written by volunteers, please consider becoming one of them.
Contact the wiki team at Matrix or Telegram

How would you do this if nc-datadir and nc-automount are not available in ncp-config, like in docker or proxmox installation?
Mounting the drive to any path I could still achieve I think, but do not understand how I can bring a mount point and the expectation of NCP of where to find the data together. In my proxmox installation the nc-datadir is /var/www/nextcloud/data, this is shown in the system info, but not changeable there.

Edit: My bad, I thought I was replying to another post :pray:

For Proxmox, it is a VM Hypervisor, you configure it in the “hardware” section.

Like in mine, here is a picture

For Docker, the volume definitions are where your data will be stored. Change this to change your data point

1 Like

You can just mount any host directory to /data/nextcloud/data using the container or VM configuration

Haha! It’s your lucky day :smiley: thankfully I’ve been dilligent and keeping notes ever since I started tinkering with a RPi4, Proxmox etc. I went digging through these notes and found how I made a VM on Proxmox using the NextcloudPi LXD image.

If I’m not mistaken, or my memory is wrong, there is a couple that are looking for this information. I even kept snapshots

Now I don’t know if I kept notes of the entire process or not, there is quite a lot though but spread out over 2 or 3 txt documents, if I remember correctly …

I’ll put them in a new post

Hmm … I don’t know what happened there … ? Did I somehow edit over your post? If so I’m sorry :pray: that was really weird, I’m sure I was editing my own post… can you see the version history by clicking on the little pen in the corner of the post? If so, you should be able to go back a version in the bottom left corner with the back icon & copy the previous version of your post by selecting to view it “raw” in the top right corner. It doesn’t work for me, which is weird since I can edit your post

Yes, indeed you overwrote my post, you have a log of privileges :wink:

But I could get my text from the history like you wrote. That was:

I have a CT via Proxmox Helper Scripts | Proxmox Scripts For Home Automation. Nevertheless, I think i would also get my HDD in there as shown in your screenshot, have not tested that but read how to do this.

But to @theCalcaholic as said the current datadir of my installation is /var/www/nextcloud/data. From what I meanwhile read I would need to mount the drive to any mount point that I choose (via console input), and then edit the config.php manually to point to that datadir, as for some reason that option is not available in ncp-config?

I have an existing HDD from my current RPi installation in BTRFS format that hosts the datadir as well das the NCP database.
The database I do not need, the HDD I would in the simplest case like to continue to use in the new proxmox installation. In the worst case I would reinitialize the HDD and copy the data then back from a backup.
BTRFS in Proxmox also seems to be not the easiest thing from what I read and also not possible from the GUI: [SOLVED] - BTRFS mount point in LXC | Proxmox Support Forum
So if it is easier I might also go with EXT4 instead.

As I see in your screenshot that you also added BTRFS I would indeed be interested in your how-to :slight_smile:

1 Like

Well, I don’t think these steps will work anymore, they were constructed when the image was exported as tar.bz2 and now it is tar.gz instead. They are converted to tar.gz in the last step, so the principle should still work, even easier in fact :thinking: since you can skip the conversion step

I don’t know, the URL in the commands also no longer works, I just put the steps here as a reference, it is also for my configuration, so your directories aren’t necessarily the same

I think this is the ISO directory on mine, I could be wrong, I’ve already shut it down at the moment. /var/lib/pve/local-btrfs/template/iso/ you’ll have to check

CT Image Directory: /var/lib/pve/local-btrfs/template/cache/

This should be done within your CT or ISO directory, depending on what method you want to attempt.

  • Download LXD image
wget -O NextCloudPi_LXD_10-08-21.tar.bz2  wget
  • Unpack image
tar xpf ./NextCloudPi_LXD_10-08-21.tar.bz2
rm ./NextCloudPi_LXD_10-08-21.tar.bz2
tar cpzf ./NextcloudPi_LXD.tar.gz -C backup/container/rootfs/ .
rm -R backup/

Awesome! :smiley: Great it worked for you to get it back

Sure, I installed using Proxmox’s image and selected BTRFS during install :3

That was really all I did for that part, then of course if you need to add other volumes and things like that you need to configure this things in the devices and hardware tabs

Edit: Ah I realised you mean for the NextcloudPi VM, my bad :pray: at the moment I don’t remember, I’ll have to get back to you with that. I think it was following Proxmox documentation for mounting BTRFS volumes and a couple posts on their community forum

I am currently trying this out with an empty USB stick that I have formated with BTRFS, even though I assume my current Nextcloud HDD has different partitions.
The process seems to be:

  1. Mount USB drive in proxmox node
  2. Bind this mount point into the CT with pct (qm only works for VMs)
  3. edit config.php in CT and make it point to this mount point

When I got this working and a file uploaded in Nextcloud is successfully saved to the USB stick, I would try the same with my HDD, hoping that all files will then appear in Nextcloud.
Not so easy for a Linux noob :sweat_smile:

If that worked, I can also write a short tutorial about that, unfortunately I could not find this anywhere on the internet so far.

1 Like

I wrote down in a separate thread how I got things working so far:

1 Like

Thank you so much :pray: I’ll send you an invite and you can create an article in draft documentation if you want, then it can be added in the docs :slight_smile:

A post was split to a new topic: Having trouble with local storage mounting


Does anyone know which automount system nc-automount uses underneath?

I am using NCP with a SSD drive and I would like to configure periodic - perhaps weekly - TRIM on the filesystem, but most of the instructions I read assume the mounts are defined in fstab.

This is said to help with long term SSD health and performance, so would be a high priority.


@ncpbot This is really helpful for me, I set up a NextCloudPi recently with an external SSD connected and ran into this issue-getting a message that I had almost run out of space when I should have nearly 1T available.

I’m trying to follow the procedure you outlined and have formatted and labeled the external drive and enabled nc-automount without any issue.

I’m having trouble configuring the nextcloud data to be on the USB drive. I navigated to the nc-datadir in the webui and it currently says the data directory is /opt/ncdata and the path exists.

I know I need to change /opt/ncdata to “your data location in the mount point”, but I have no idea how to figure out where that is? I also don’t know what the mount point is or where I can figure that out.

Hoping you or someone else can tell me where to find that, because I’m at a loss for the answer so far.