• Contact
  • About Me
  • Privacy Policy
  • Disclaimer
DefenceDev
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools
No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools
No Result
View All Result
DefenceDev
No Result
View All Result
Home Projects Nextcloud

How to Replace a Nextcloud Data Hard Drive on Ubuntu

by neo
November 28, 2025
in Nextcloud
0
Nextcloud: Change – Replace Hard Drive for the Data on Ubuntu

Nextcloud: Change – Replace Hard Drive for the Data on Ubuntu

0
SHARES
112
VIEWS
Share on FacebookShare on LinkedIn
Table of Contents
  • Introduction
  • Steps to be Done to Change or Replace Hard Drive for the Data
    • Step 1: Backup All Data
    • Step 2: Install new Hard Drive to the Server and Reboot it
    • Step 3: Check Install Disks to Find Logical Name
    • Step 4: Create partition on the new HDD
    • Step 5: Stop Nextcloud Application
    • Step 6: Move all data from NextCloud data location to the new disk (temp location)
    • Step 7: Demount the old NextCloud Hard Drive
    • Step 8: Edit /etc/fstab, Remove Old Hard Drive and Reboot the Server
    • Step 9: Edit /etc/fstab, and Mount new Hard Drive
    • Step 10:Change Ownership of the Data
    • Step 11: Start Nextcloud Application

Introduction

In this guide, we’ll walk you through the step-by-step process of change or replace the hard drive for Nextcloud data storage on your Ubuntu Server. From backing up your data to updating configurations, this article covers everything you need to know to perform a smooth and safe migration.

Steps to be Done to Change or Replace Hard Drive for the Data

Step 1: Backup All Data

To backup all Nextcloud data copy you need to execute following command:

rsync -av /path/to/nextcloud/data /path/to/backup  

REMEMBER: If you’re unsure where Nextcloud stores your user data, you can find the location specified in the configuration file, typically located at /var/www/html/config/config.php.

more /var/www/html/config/config.php

Output:

  'datadirectory' => '/opt/data/disk2',

Step 2: Install new Hard Drive to the Server and Reboot it

Install new hard drive in your environment and reboot your server.

Step 3: Check Install Disks to Find Logical Name

To checked install disks in your Ubuntu, you need to execute the following command:

lshw -C disk
root@nextcloud:~# lshw -C disk
  *-disk:0
       description: SCSI Disk
       product: Virtual disk
       vendor: VMware
       physical id: 0.0.0
       bus info: scsi@32:0.0.0
       logical name: /dev/sda
       version: 2.0
       size: 16GiB (17GB)
       capabilities: gpt-1.00 partitioned partitioned:gpt
       configuration: ansiversion=6 guid=ee8a8a6e-fc7e-47a8-919b-530d08a6097b logicalsectorsize=512 sectorsize=512
  *-disk:1
       description: SCSI Disk
       product: Virtual disk
       vendor: VMware
       physical id: 0.2.0
       bus info: scsi@32:0.2.0
       logical name: /dev/sdb -> New Hard Drive
       version: 2.0
       size: 100GiB (107GB)
       capabilities: partitioned partitioned:dos
       configuration: ansiversion=6 logicalsectorsize=512 sectorsize=512 signature=3e350404

New hard drive is located under:

logical name: /dev/sdb

More information how to add a new HDD you can find at this link.

Step 4: Create partition on the new HDD

Create a partition, format it and mount it to new location. More information how to do this steps you can find in this link.

Step 5: Stop Nextcloud Application

To shut down the Nextcloud application, you need to stop both the web server and the MySQL service. You can accomplish this by running the following commands:

systemctl stop apache2  
systemctl stop mysql  

Step 6: Move all data from NextCloud data location to the new disk (temp location)

To copy the data to the new hard drive:

cp -a /opt/data/disk2/. /opt/data/disk3
  • /opt/data/disk2 → Old hard drive
  • /opt/data/disk3 → New hard drive

It is very important to check if all data are copied. To compare the number of files on two locations you can use the following command:

find /opt/data/disk2 -type f | wc -l
find /opt/data/disk3 -type f | wc -l

Output must be the same!

Step 7: Demount the old NextCloud Hard Drive

To unmount the old hard drive, you need to execute the following command:

 sudo umount /opt/data

How to find where is old disk mounted? Execute the following command:

root@nextcloud:/var/www/html/config# df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           794M  2.5M  792M   1% /run
/dev/sda2        16G   12G  3.4G  78% /
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/sdb1        98G   54G   40G  58% /opt/data/ -> Drive with old data
tmpfs           794M  4.0K  794M   1% /run/user/1000

Step 8: Edit /etc/fstab, Remove Old Hard Drive and Reboot the Server

Edit /etc/fstab and remove line where is the disk mounted.

sudo nano /etc/fstab

Output is something like:

UUID=589bb1bc-1c83-46fe-83e9-ed84053c7cbe / ext4 defaults 0 0
/dev/sdb1 /opt/data/disk2 ext4 defaults 0 1

/swap.img       none    swap    sw      0       0

Step 9: Edit /etc/fstab, and Mount new Hard Drive

Edit /etc/fstab and add line to mount new disk to the data location

sudo nano /etc/fstab

I added the following line in the file sudo nano /etc/fstab file

/dev/sdc1 /opt/data/disk2 ext4 defaults 0 1

I mounted it to the same location so I do not need to change Nextcloud configuration file.

Step 10:Change Ownership of the Data

Change the ownership of the data, executing the following command:

chown -R www-data:www-data /opt/data/disk2

Step 11: Start Nextcloud Application

To start Nextcloud application, execute the following commands:

systemctl start apache2  
systemctl start mysql 
Tags: nextcloud
Previous Post

Add and Mount New HDD or SSD on Ubuntu – Easy Tutorial

Next Post

AdGuard Home: Install DNS Server on Ubuntu and Configure It

neo

Related Posts

Nextcloud Access with Multiple Domains – Redirect and SSL Issues (Proxy Manager & Direct Port Forwarding)
Nextcloud

Nextcloud Access with Multiple Domains – Redirect and SSL Issues (Proxy Manager & Direct Port Forwarding)

Self-Hosted Nextcloud Hub 10 on Ubuntu – My Top 5 Apps
Nextcloud

Nextcloud: My Top 5 Must-Have Apps

NextCloud: Port Forwarding - Essential Ports for Smooth Functionality
Nextcloud

NextCloud: Port Forwarding – Essential Ports for Smooth Functionality and Remote Access

Nextcloud: Manual Upgrade from 25.0 to 26.0 on Ubuntu 22.04
Nextcloud

Nextcloud Manual Upgrade on Ubuntu 22.04: Step-by-Step Guide

Nextcloud: Security Concept with FortiGate Firewall
Nextcloud

Nextcloud: Security Concept with FortiGate Firewall

NextCloud dashboard screenshot
Nextcloud

Nextcloud: How to Upgrade Nextcloud via the Web Interface

Next Post
AdGuard Home: Install DNS Server on Ubuntu and Configure It

AdGuard Home: Install DNS Server on Ubuntu and Configure It

Recommended

Fortinet FortiGate: Equal Cost Multipath Routing (ECMP) Configuration

Fortinet FortiGate: Equal Cost Multipath Routing (ECMP) Configuration

WordPress: Change Port from 433 to 8443

WordPress: Change Port from 433 to 8443

Get Instant SSH Login Alerts on Ubuntu with Bash and Telegram

Get Instant SSH Login Alerts on Ubuntu with Bash and Telegram

Terminal Colors in Bash: How and When to Use Them

Terminal Colors in Bash: How and When to Use Them

Solution: Ubuntu Internet Connection Monitoring Script (Create a Log File, Possible to Send per Email)

Ubuntu Internet Connection Monitoring Script: Log Creation and Email Alerts

Categories

  • Blog
  • Cloud
    • Private
  • Linux Tutorials
    • Bash Scripting Tutorials
    • Commands
    • Networking
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Solutions
    • Docker
  • Video Tutorials
    • MikroTik Videos
  • Web Tools

DefenceDev Tutorials

defencedev Logo

Whether you’re just starting or looking to expand your skills, I hope you find useful information and engaging discussions here. Let me take you through my journey and the goals behind this space!

Follow Us

Recent News

Get Instant SSH Login Alerts on Ubuntu with Bash and Telegram

Get Instant SSH Login Alerts on Ubuntu with Bash and Telegram

Terminal Colors in Bash: How and When to Use Them

Terminal Colors in Bash: How and When to Use Them

  • Site Map
  • Privacy Policy
  • Facebook Page
  • GitHub
  • Disclaimer
  • Contact
  • About Me

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools

© 2025 defencedev.com - All rights reserved.