If you have a Unifi CloudKey Gen2+ controller with existing video footage and want to preserve that as well as any configuration settings that might be stored there, but upgrade the capacity of the default HDD from 1TB to something more usable, this article is for you.
Get a larger 2.5" HDD, I used the internal drive from this external USB drive. It is by far the cheapest option I could find to get a 5TB drive.
Turn off the CloudKey
Remove the 1TB drive (source) from the CloudKey and connect it to a PC.
Connect the new 5TB (target) drive to a PC
Issue the following command from MacOS / Linux: dd if=/dev/diskA of=/dev/diskB bs=1m
(Make sure A is the SOURCE and B is the TARGET, on macOS use diskutil list to find the right drive)
Once the copy is done (mine took 2 hours or so) run GParted - you can boot it from a Live ISO.
Accept the recommendation to extend the partition to fill the disk
Edit the large partition by moving the partition slider to the right to occupy all space and apply
This resize might take 10 - 20 minutes
Once done eject both disks.
Gently pry open the red top from the black base using a small spatula.
Remove the HDD
Remove the metal shroud and small USB to SATA adapter.
Pop out the 1TB from the carriage from the CloudKey and snap in the new one
Boot up the CloudKey and give the OS about 10 - 20 minutes to recognize the extra space. Everything should be preserved.