Summary of the issue you are facing:
My goal is to set up Nextcloud on an Intel NUC with less than 500GB of storage, using a 2TB external SSD to store the Nextcloud data instead of the NUC’s internal storage. I want to access Nextcloud only via a local IP (e.g., 192.x.x.x or 10.x.x.x) without exposing it to the internet.
The Basics
Here are my installation steps:
- Install Ubuntu Server 24 LTS
- sudo apt update
- sudo apt upgrade -y
- reboot
- Install Nextcloud Steps
sudo snap install nextcloud
sudo nextcloud.enable-https self-signed
(Same steps for renew -3 Months by default)sudo ufw allow 80,443/tcp
- Attach External Drive
-
3.1 Insert External Drive
-
3.2. List all of the storage device
sudo fdisk -l
-
3.3. Make a Folder
sudo mkdir /mnt/ssd
-
3.4. Mount the external drive
sudo mount /dev/sdb1 /mnt/ssd
Note: Type
df -h
to check if it mounted. -
3.5. Change the permissions on disk
sudo chmod ugo+rw /mnt/ssd
-
3.6. Get the UUID for external drive
sudo blkid
Note: Copy the UUID
-
3.7. Make an entry fstab
sudo nano /etc/fstab
-
3.8. Entry to paste
UUID=xxxx-xxxx-xxxx-xxxx /mnt/ssd ext4 defaults 0 0
-
3.9. Test it
Unmount:
sudo umount /mnt/ssd
Mount:sudo mount -a
Check:df -h
- Move Nextcloud Data Directory to External Hard-Drive
-
4.1 Connect the removable-media plug
sudo snap connect nextcloud:removable-media
Connecting that interface gives Nextcloud permission to access things in /media/, so you can edit /var/snap/nextcloud/current/nextcloud/config/config.php and make sure the datadirectory is pointing to the right place.
-
4.2 Now we need to change entry in config.php from
'datadirectory' => '/var/snap/nextcloud/common/nextcloud/data',
to
'datadirectory' => '/mnt/ssd/nextcloud/data',
But currently, that entry doesn’t exist in config.php
Hence:
- Setup initial Nextcloud via UI:
- 5.1 Go to https://192.x.x.xxx/
- 5.2 Provide ‘New admin account name’ and ‘New admin password’
- 5.3 Click Install
- Move Nextcloud Data Directory to External Hard-Drive
-
6.1 Change entry in config.php from
'datadirectory' => '/var/snap/nextcloud/common/nextcloud/data',
to
'datadirectory' => '/mnt/ssd/nextcloud/data',
-
6.2 Create directories in /mnt/ssd
mkdir /mnt/ssd/nextcloud
-
6.3. Disable the snap:
sudo snap disable nextcloud
-
6.4 Move (or copy) the current data directory to the new location:
sudo mv /var/snap/nextcloud/common/nextcloud /mnt/ssd/nextcloud
-
6.5 Re-enable the snap:
sudo snap enable nextcloud
- Access Nextcloud via GUI
- 7.1 Go to https://192.x.x.xxx/
Error
Your data directory is invalid.
Ensure there is a file called ".ncdata" in the root of the data directory. It should have the content: "# Nextcloud data directory"
Cannot create "data" directory.
This can usually be fixed by giving the web server write access to the root directory. See https://docs.nextcloud.com/server/31/go.php?to=admin-dir_permissions
Steps to replicate it (hint: details matter!):
- Follow the above steps in order
Web Browser
PASTE
Configuration
Nextcloud
Sensitive information replaced with XXXXX:
sudo cat /var/snap/nextcloud/current/nextcloud/config/config.php
<?php
$CONFIG = array (
'apps_paths' =>
array (
0 =>
array (
'path' => '/snap/nextcloud/current/htdocs/apps',
'url' => '/apps',
'writable' => false,
),
1 =>
array (
'path' => '/var/snap/nextcloud/current/nextcloud/extra-apps',
'url' => '/extra-apps',
'writable' => true,
),
),
'supportedDatabases' =>
array (
0 => 'mysql',
),
'memcache.locking' => '\\OC\\Memcache\\Redis',
'memcache.local' => '\\OC\\Memcache\\Redis',
'redis' =>
array (
'host' => '/tmp/sockets/redis.sock',
'port' => 0,
),
'log_type' => 'file',
'logfile' => '/var/snap/nextcloud/current/logs/nextcloud.log',
'logfilemode' => 416,
'maintenance_window_start' => 1,
'instanceid' => 'XXXXX',
'passwordsalt' => 'XXXXX',
'secret' => 'XXXXX+XXXXX',
'trusted_domains' =>
array (
0 => '192.168.1.XXX',
),
'datadirectory' => '/mnt/ssd/nextcloud/data',
'dbtype' => 'mysql',
'version' => '31.0.8.1',
'overwrite.cli.url' => 'https://192.168.1.XXX',
'dbname' => 'nextcloud',
'dbhost' => 'localhost:/tmp/sockets/mysql.sock',
'dbport' => '',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'XXXXX',
'dbpassword' => 'XXXXX',
'installed' => true,
);