Replacing USB drive for Nextcloud

I have follow this tuto: for installing Nextcloud with Dietpi. As I wanted to test it for a while I have connect a USB stick before having a bigger HDD. Everything is working fine but now I would like to replace my USB stick by a USB HDD drive. I also would like to keep the actual files stored on the USB stick. Do someone knows how to do so ?
Data are actually saved under /mnt/dietpi_userdata/nextcloud_data.


did you stored your entire dietpi-user data on the USB stick?

hi Joulinar,
not sure about that, how can I check ?

As mentioned in :

root@DietPi:~# readlink -f /mnt/dietpi_userdata

root@DietPi:~# df /mnt/dietpi_userdata
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/root       61116684 1637228  56971888   3% /

root@DietPi:~# df /mnt/dietpi_userdata/nextcloud_data
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/sda1      119266264 24428236  94821644  21% /mnt/dietpi_userdata/nextcloud_data

did you installed your entire system on that USB stick?

can you share lsblk -o name,fstype,label,size,ro,type,mountpoint,partuuid,uuid

No this tutorial interested me because only the data were stored on an external drive.

root@DietPi:~# lsblk -o name,fstype,label,size,ro,type,mountpoint,partuuid,uuid
sda                     116.1G  0 disk
└─sda1     ext4         116.1G  0 part /mnt/dietp 02c06ec7-01                          f00aa157-7137-4087-a1e9-1b491750e891
mmcblk0                  59.5G  0 disk
│          vfat   boot    256M  0 part /boot      907af7d0-01                          4AD7-B4D5
           ext4   rootfs
                         59.2G  0 part /          907af7d0-02                          2887d26c-6ae7-449d-9701-c5a4018755b0

ah ok you mounted the USB stick directly to /mnt/dietpi_userdata/nextcloud_data

Let’s verify to be sure :slight_smile: cat /etc/fstab

root@DietPi:~# cat /etc/fstab
# You can use "dietpi-drive_manager" to setup mounts.
# NB: It overwrites and re-creates physical drive mount entries on use.

tmpfs /tmp tmpfs size=1938M,noatime,lazytime,nodev,nosuid,mode=1777
tmpfs /var/log tmpfs size=50M,noatime,lazytime,nodev,nosuid,mode=1777

# MISC: ecryptfs, vboxsf (VirtualBox shared folder), gluster, bind mounts


PARTUUID=907af7d0-02 / ext4 noatime,lazytime,rw 0 1
PARTUUID=907af7d0-01 /boot vfat noatime,lazytime,rw 0 2
UUID=f00aa157-7137-4087-a1e9-1b491750e891 /mnt/dietpi_userdata/nextcloud_data ext4 noatime,lazytime,rw,nofail,noauto,x-systemd.automount
#UUID=c2b04798-8023-41df-bd1a-f9402db8f8bc /mnt/c2b04798-8023-41df-bd1a-f9402db8f8bc ext4 noatime,lazytime,rw,nofail,noauto,x-systemd.automount

ok it should be easy to copy all data to your new HDD

  1. connect your HDD to your system
  2. go to dietpi-drive_manager
  3. I assume your HDD is empty and we are going to format it before usage
  4. select the new HDD and check Format
  5. follow the dialog and mount the HDD to /mnt/hdd at the end
  6. leave dietpi-drive_manager
  7. run dietpi-services stop to stop all services
  8. let’s check and install rsync
  9. run apt update && apt install rsync -y
  10. let’s copy files now rsync -avH --progress /mnt/dietpi_userdata/nextcloud_data/ /mnt/hdd/
  11. now we need to switch disk and mount points. go to dietpi-drive_manager
  12. select your HDD and unmount the device
  13. select your USB stick and unmount the device
  14. hopefully this is working and both device are not in use/blocked
  15. if all is working well and both devices are not mounted anymore, select your HDD and mount it to /mnt/dietpi_userdata/nextcloud_data/
  16. leave dietpi-drive_manager
  17. run dietpi-services start to start all services
  18. if there are no error messages, NextCloud should be using data on HDD now.
  19. do a reboot and removed the USB stick
  20. check inside NextCloud if you are able to access/store/remove data

thank you Joulinar, i can not have access to the system today, i will test it tomorrow and let you know. thank you anyway for your help.

Hello Joulinar,
So I have followed your procedure and everything went well until step 15. i have had an error because drive_manager didn’t let me mount the new drive to /mnt/dietpi_userdata/nextcloud_data because the folder was not empty.
I have still restarted the services (step17) and I have decided to edit the /etc/fstab and uncomment the line corresponding to the new drive and write /mnt/dietpi_userdata/nextcloud_data manually.
After remove the USB stick and done a reboot the new drive was mount. I have check with Nextcloud and my data were there and everything is fully functionnal. Great !!! :smiley:
You should mark your procedure as tutorial for those who would like to change their drive with a similar configuration than mine. thank you very much for your kind cooperation.

yes that was one of the steps having the potential to fail. I guess the USB stick was not fully unmounted. And indeed changing /etc/fstab would be the other option. At the end drive manager is not doing anything else :wink: Good that it was working this way at the end.