3 Nextcloud USB Drive
Drew edited this page 2026-05-01 21:02:06 -04:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Nextcloud USB Drive

Status: archived. I don't run Nextcloud anymore. The partitioning and fstab steps still apply to any Linux box, but the Nextcloud-specific framing is no longer current for me.

Setting up an external USB drive as the data directory for Nextcloud. Walks through partitioning, formatting, mounting, and fstab so the drive comes back automatically on reboot.

Preparing the drive for Nextcloud

Identify the intended drive

Use lsblk to identify the drive you want to use for Nextcloud. In this example, well assume the drive is /dev/sda.

Partitioning the drive

  1. Install parted

    sudo apt install -y parted
    
  2. Create a GPT partition table

    sudo parted /dev/sda mklabel gpt
    
  3. Create a partition

    sudo parted /dev/sda mkpart primary ext4 0% 100%
    
  4. (Optional) Name the partition

    sudo parted /dev/sda name 1 my-data
    
  5. Format the partition

    sudo mkfs.ext4 /dev/sda1
    

Mount the partition

  1. Create a mount point

    sudo mkdir /nextcloud-data
    
  2. Mount the partition

    sudo mount /dev/sda1 /nextcloud-data
    
  3. Add to /etc/fstab for automatic mounting

    echo '/dev/sda1 /nextcloud-data ext4 defaults 0 0' | sudo tee -a /etc/fstab
    
  4. Set proper permissions

    sudo chown www-data:www-data -R /nextcloud-data
    sudo chmod 0750 -R /nextcloud-data
    

Final steps

Once these steps are completed, you can use the USB drive as the data drive during the Nextcloud installation.