The best way to replace external storage

Hello,

I’m using a 1TB external HDD as external storage and I would like to replace it with an 8TB external HDD.
What’s the safest way to do this migration?

Thanks!

Do you use the external HDD as nextcloud-data-dir or as external data in nextcloud?
Please post interesting parts from:

  • config/config.php
  • mount point for external HDD
  • file system type (ext4, …)

I use it as nextcloud’s data directory.

What exactly do you mean by interesting parts from config/config.php?
The mount point is /media/some_long_serial_number/
File system is btrfs.

How I would do it is image the 1 TB onto the 8 TB and then extend the partition.

Check the btrfs manuals, you can easily do a btrfs replace followed by a btrfs resize max and dont have to care about anything else later on…

Another possibility is to format the new HDD with btrfs (perhaps also other types like ext4) and then copy all files in the same structure from the old HDD to the new HDD. You must the the rights of the files to www-data (nextcloud user). Then you can change the HDDs and mount the new HDD on the same position.

Way too complicated, you dont need to format anything and during the replace process the filesystem is fully accessible.

sudo bash

will open bash as su

btrfs filesystem show 

will list you the current filesystem, you will need the deviceid.

btrfs replace start 1 /dev/sdb /media/myCloudDrive/ -f

This is how i did it, this moves the complete content of the old drive (1) to the new device (sdb), /media/myCloudDrive/ is the mountpoint of the filesystem, -f means to force overwrite any content on the target drive.

With

btrfs replace status

you can get the progress, the operation will take a while and after that a

btrfs filesystem resize myCloudDrive max

will expand the filesystem onto the full drive

Ok, I’ll give this a try.
Thank you!

Keep us informed… :wink: ah, and dont forget to replace myCloudDrive with that long serial number you mentioned

1 Like

Hey @conectionist did you that go well?

Hey, sorry I haven’t managed to do this yet because my 8TB HDD hasn’t arrived yet. There seem to be a lot of delays during this crazy period.
But I promise I’ll let you guys know how it went when I finally do it.
Thanks for asking!

1 Like

Ok, my 8TB HDD finally arrived and I began the process of migrating my data to it.
Unfortunately, it was not a straightforward operation.
Long story short:
I’m using NextcloudPi, so I figured it would be easier to do the migration via the integrated backup/restore tools that it has integrated in it. It was not. :smiley:
I’m going to skip the problems (unless anyone is interested) and just say what I did that actually worked:

  • I put the server in maintenance mode
  • I created a Nextcloud backup (via GUI nc-backup)
  • I copied that backup from my old HDD to my new one (via rsync)
  • I copied my entire data folder from my old HDD to my new one (manually)
  • I “restored” my data from the backup I made earlier (via GUI nc-restore)
  • the nc-restore operation included some weird warnings/errors, but the overall process was successful, so I ignored them (hopefully I won’t regret it :smiley: )
  • for some reason, the restoration process put my data directory on my server’s internal HDD, instead of my external one, so I had to move it (using the GUI datadir option)
  • maintenance mode was automatically turned off after the data folder migration was successful
  • my desktop sync started soon after and it was working ok
  • I also checked the other apps and they seem to be working ok

That’s all!
Hopefully this helps someone in the future.

Thanks a lot for your support guys!

You definitely would have saved you a lot of trouble by using btrfs replace, this is a filesystem level operation and seamless, you could even have used your nc during that operation, i have done exactly that two weeks before your first post.

1 Like