07-26-2017 11:47 AM - edited 01-31-2018 06:17 PM
** Important update to this post **
If you're cloning a hard drive for backup purposes that will only be used in the original NVR appliance (e.g. hard drive failure) from where it came, this guide is fine as-is. If you're cloning your drive to replace a failed drive in another NVR appliance, you're better off installing Ubuntu Server x64, and installing the Unifi Video controller Debian package. You can use the same CLI instructions posted in the blog for the initial install. After that, upgrades will be offered through the web UI as normal if you prefer. The reason is, the NVR comes from the factory with a preassigned ID in the mongo DB. This is built into the recovery image and not generated on first boot or during configuration (which is a mistake IMO). This becomes an issue when you try to cloud connect the device, and the original NVR exists that uses the same ID and also cloud connects. This ID gets cloned along with everything else, and the cloud service gets confused by multiple NVR's with the same ID. The result is the cloud connect service doesn't work, and each owner will be getting notifications about all the NVR's using that ID constantly connecting and disconnecting. @UBNT-Cody helped me get this sorted today. There is no method as of this writing to fix this without involving Ubiquiti support.
As far as I am aware, UBNT doesn't offer a replacement drive for their NVR. They also do not offer an OS image to be used in case of drive failure, nor a higher capacity hard drive. The included hard drive in this appliance is 500GB. These steps indicate how to clone the supplied hard drive to a new drive as a backup, and optionally upgrade to a higher capacity hard drive for more recording space.
- Remove the hard drive from NVR and attach it along with the new or backup drive to a spare computer.
- Boot the machine to CloneZilla or your favorite clone utility and clone the drive.
- If the destination hard drive is the same size as the source, you’re done once CZ has finished operations. Put the new hard drive in the NVR to test and store the original as backup. If the destination hard drive is larger, proceed to step 4.
- Now boot the machine to GParted and the GParted GUI utility should open automatically.
- Right-click either of the two locked partitions and choose Deactivate.
- Now select /dev/sda2 (extended) to extend partition to the new disk size and save.
- Right-click either of the two locked partitions again and choose Deactivate.
- Now select /dev/sda7 (lvm2 pv) to extend the LVM partition to the new extended partition size and save.
- It seems the GParted GUI only changes the partition entries. We will use the shell commands below to expand the partitions to the newly available space. Open a terminal and run the following commands:
$ lvdisplay # verify LV Path $ lvresize -l+100%FREE /dev/lvm/data0 # resize extended $ e2fsck -f /dev/lvm/data0 # fs check required $ resize2fs /dev/lvm/data0 # resize LVM2 $ lvdisplay # verify LVM2 size
That’s it. Put the new hard drive back in the UniFi NVR and test. Use steps 1-3 above to make a backup of your larger drive if desired. If someone knows of a simpler method, please share. My NVR has been operating with a 1TB drive in it for months now.
07-26-2017 12:02 PM
Very nice - I'm sure this will help a lot of folks...
"Humans are allergic to change..They love to say, ‘We’ve always done it this way.’ I try to fight that. "Admiral Grace Hopper, USN, Computer Scientist
"It's not Rocket Science! - Oh wait, Actually it is... "NASA bumper sticker
"Just because you can do something doesn't mean you should."my mantra in the Programming classes I used to teach once upon a time...
01-28-2018 09:43 AM - edited 04-05-2018 12:30 AM
i have just changed the 512g disk to a 2tb disk on my nvr.
but my partion layout is different from yours. /dev/sdX2 was swap. i left it as it was, /dev/sdX4 was my lvm partition.
gparted immediately told me that the disk was not completely used and offered to extend the lvm partion. after that it said it had also grown the filesystem, but after mounting the drive back in the nvr the partition still was only 512g in size.
after a manual
lvresize -l+100%FREE /dev/lvm/data0
and an additional reboot the partion was the expected size. the nvr system configuration took about 20 seconds and then also showed the new size.
everything looks fine and working now.
04-05-2018 01:28 AM
as far as i know there is currently non that will physicaly fit into the case if you still want to close it.
also the seagate barracuda 2tb is even the only 7mm 2tb drive availabe as far as i know. all others are 9mm.
04-25-2018 10:27 AM
Very good and handy manual to replace disk. worked fine upto clone. I tried to resize with GParted but let me alone resize boot partition which is useless i suppose.
/dev/sdd1 ext2 can be resized
//dev/sdd2 locked and no possibility to unlock cannot be resized
/dev.sdd7 lvm2 locked and no resize possible
Any idea how to solve?? - sorry for quality of pics - no possibilty for screenshot
02-13-2019 01:19 PM
@mikesg I've got 2 Unifi NVR appliances w/ the 2TB disk each that have been up for about a year each.
Just noticed today that each has 1 reallocated sector reported in smart data (smartctl -a /dev/sda)
Will need to replace the drives at some point.
It appears they run Debian 7 with an updated kernel and perhaps a few other minor updates UBNT has done.
It sounds like my best way of getting these back online if the drives completely fail is to put in a new drive and install either Debian 7 or Ubuntu and install unifi video deb package? Can anyone here confirm if plain old Debian 7 installed on a replacement disk on a unifi appliance will work? I like the simplicity of Debian 7 and that is what the unifi appliance is based on.
I've built several Intel NUC based NVRs and loaded stock Debian 7 with unifi video deb package and they work great -- I'm comfortable doing that. I will lose the small nginx base web GUI that lets you configure the IP address and start/stop unifi video or shut the unit down but I don't care about that.
I don't think I'm going to get the opportunity to clone the drives on these before they totally die. I'll probably wait til they completely die and then replace the drive as that is a lot cheaper than full replacement.
Thanks for any tips and thanks for writing this howto on cloning and also thank you for sharing the warning on the unique ID issue w/ cloning!
02-14-2019 05:06 PM
Ubnt staff have recommended Ubuntu 16.04 when I have asked and in other posts. 3.10 is out now however and 18.04 should be supported. I would always recommend the most current/stable supported path.
If you’re able, clone these drives to a new drive. As long as you’re using the clone of the original in the same NVR as the original drive you won’t have any trouble. Just don’t have the original and it’s clone in operation at the same time. Bad juju. The benefit here is you keep the NVR original. It was said in the beginning that the NVR’s would be upgradable to Protect. If this does happen, it may be a requirement that the NVR is running the original OS. Though it would be nice to get a couple of my NVR appliances that have been converted to Ubuntu back on Protect some day. Likely will only happen if DIY happens for Protect though.
02-14-2019 05:25 PM
Thanks @mikesg I appreciate the input. If I don't get to clone them before they die completely I'll go with Ubuntu 16.04 per your advice or try 18.04. Debian 7 on the NUC versions I've built has been rock stable and I think that is what the appliance runs, but I don't know if stock Debian 7 as opposed to stock + updates UBNT adds for the appliance will work (I know they run a newer kernel at least). Since 16.04 or 18.04 is the sure thing I'll go w/ that.
Glad to hear drive failure scenario for these has already been shared w/ great advice. Thanks!