Setup a Raspberry Pi Cloud Server With Nextcloud

Setup a Raspberry Pi Cloud Server With Nextcloud

Setting up the USB Drive

Before your USB drive can be used, it needs to be mounted properly so that it appears to the system the same way each time the Raspberry Pi boots. This is important because we’re going to be telling Nextcloud specifically where to store the data. If the drive mount point moves each time there’s a reboot then we’ll quickly be in trouble.

Plug in the USB drive, then open a Terminal window and type:

sudo lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL

This wil display all mounted drives on your system.

Here you can see that there are two disks connected to the system; the SD card that the Raspbery Pi boots from and a 320GB hard disk called sda, which has a partition called sda1.

Run the following command to confirm the location of the disk partition:

sudo blkid

In my case this showed the location to be “dev/sda1”, but yours may be different.

We’re going to create a folder to be the mount point for this disk. I’ll call mine “data”, but you can call yours whatever you’d like:

sudo mkdir /mnt/data

Next we need to mount the physical storage drive to the mount point above:

sudo mount /dev/sda1 /mnt/data

You can then verify this by running this command:

ls /mnt/data

Next we want to setup the system so that the above will happen automatically at reboot. This requires editing a configuration file, but first we need to find the universally unique identifier of the hard disk.

To do this run this command:

sudo blkid

Find the hard disk in the list and then make a note of the UUID shown.

Mine is “504d3da4-3dd1-4171-b1c3-45b36f23143c” – yours may be longer or shorter.

Next open the configuration file:

sudo nano /etc/fstab

Add the following line to the end of the file, replacing my UUID with your own:

UUID=504d3da4-3dd1-4171-b1c3-45b36f23143c /mnt/data ext4 defaults,auto,users,rw,nofail 0 0

Press ctrl+O to save the file, then ctrl+X to exit.

Your mount points should remain now even after a reboot.

2 Comments

  1. Bob

    Matt, thanks for the very complete and useful guide. Yours is the best one I’ve found when looking for help with installing nextcloud on my local server.

  2. Sorry dude but,
    ‘datadirectory’ => ‘/var/www/html/nextcloud/data’,

    Becomes:

    ‘datadirectory’ => ‘/mnt/data/nextcloud/data’,

Leave a Reply