UniFi Video - How to Add a Network Volume to the NVR Appliance?

Overview


The following article takes the user through general steps to use additional file system space for the NVR appliance. This article is focused on setting up an iSCSI initiator (client) configured to use a remote storage device (iSCSI LUN target). Not included within this how-to guide are details for troubleshooting network access, file server permissions, nor setup errors.

Table of Contents


  1. Introduction on Storage
  2. Steps: How to Add a Network Volume to the NVR Appliance
  3. Housekeeping
  4. Related Articles

Introduction on Storage


Back to Top

There are 4 main types of external storage you can use:

  • Samba (Windows File Sharing). It won’t be covered at any point due to its limits in throughput compared to the rest.
  • NFS (Network File Sharing)
  • iSCSI (Internet Small Computer System Interface)
  • USB 3.0

Samba, NFS, and iSCSI are predominantly NAS based storage protocols whereas USB 3.0 would be used for a dedicated, individual storage unit. If ordered by speed: NFS is the fasted, then iSCSI, then USB 3.0, then Samba (protocol version dependent). However, depending on network and storage, these speeds may vary. See related articles below for information about alternative extra storage options.


Steps: How to Add a Network Volume to the NVR Appliance


Back to Top

Step 1
Use SSH to login to the NVR appliance for CLI access. The default password is ubnt.

ssh root@ip.address.of.nvr

Step 2
Install the iSCSI initiator package.

# apt-get update ; apt-get install open-iscsi

Step 3
Update /etc/iscsi/iscid.conf to auto-start the initiator upon system reboot.

# vi /etc/iscsi/iscsid.conf

Change the following:

# To manually startup the session set to "manual". The default is manual.
#node.startup = manual
node.startup = automatic

Step 4

Restart the open-iscsi initiator.

# /etc/init.d/open-iscsi restart
[....] Unmounting iscsi-backed filesystems: Unmounting all devices marked _netde[.ok
[ ok ] Disconnecting iSCSI targets:.
[ ok ] Stopping iSCSI initiator service:.
[ ok ] Starting iSCSI initiator service: iscsid.
[....] Setting up iSCSI targets:
iscsiadm: No records found
. ok
[ ok ] Mounting network filesystems:.

Step 5
Create a mount point for the network volume.

# cd /srv
# mkdir /srv/synology
# chown airvision:airvision ./synology # <- For airVision
# chown unifi-video:unifi-video ./synology # <- For UniFi-Video
# ls -l
/srv
total 32
drwxr-xr-x 5 root root 4096 Jan 29 21:30 .
drwxr-xr-x 33 root root 4096 Jan 13 20:11 ..
drwx------ 2 root root 16384 Aug 12 21:07 lost+found
drwxr-xr-x 2 airvision airvision 4096 Jan 29 21:30 synology # <- Proper output for airVision
drwxr-xr-x 2 unifi-video unifi-video 4096 Jan 29 21:30 synology # <- Proper output for UniFi-Video

Step 6
Setup an iSCSI LUN. The following is based on Synology:

  1. Log in to the Synology DSM admin console: http://<NAS_IP>:5000/
  2. Open the storage manager dialog
  3. Click the iSCSI LUN tab
  4. Create a LUN (skipping details here)
  5. Click the iSCSI Target tab to confirm Service Status is Ready

 

Step 7
Confirm the remote iSCSI target is discoverable by the NVR appliance. For example:

# iscsiadm -m discovery -t st -p <NAS_IP>:3260
<NAS_IP>:3260,0 iqn.2000-01.com.synology:av-office-nas.demo

Where, port 3260 is the registered port for iSCSI or Internet SCSI, and used to contact the Synology NAS at its assigned IP address.

Step 8
Connect to the iSCSI target.

# iscsiadm -m node --targetname "iqn.2000-01.com.synology:av-office-nas.demo" --portal "<NAS_IP>:3260" --login
Logging in to [iface: default, target: iqn.2000-01.com.synology:av-office-nas.demo, portal: <NAS_IP>,3260] (multiple)
Login to [iface: default, target: iqn.2000-01.com.synology:av-office-nas.demo, portal: <NAS_IP>,3260] successful.

Step 9
List the current disks and partitions. For example (where /dev/sdb is a 1 TB iSCSI LUN):

# fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000a0551
Device Boot Start End Blocks Id System
/dev/sda1 * 4096 1957887 976896 83 Linux
/dev/sda2 1957888 976773119 487407616 f W95 Ext'd (LBA)
/dev/sda5 1959936 9771007 3905536 82 Linux swap / Solaris
/dev/sda6 9773056 15624191 2925568 83 Linux
/dev/sda7 15626240 976773119 480573440 8e Linux LVM
Disk /dev/mapper/lvm-data0: 492.1 GB, 492105105408 bytes
255 heads, 63 sectors/track, 59828 cylinders, total 961142784 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/lvm-data0 doesn't contain a valid partition table
Disk /dev/sdb: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 cylinders, total 2147483648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table

Step 10
Create a partition.

# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x19b96a16.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-2147483647, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2147483647, default 2147483647):
Using default value 2147483647
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 83
Command (m for help): p
Disk /dev/sdb: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 cylinders, total 2147483648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x19b96a16
Device Boot Start End Blocks Id System
/dev/sdb1 2048 2147483647 1073740800 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

Step 11
Create a filesystem for the new partition.

# mke2fs /dev/sdb1

Step 12
Mount the network volume.

# mount -t ext4 /dev/sdb1 /srv/synology
# chown airvision:airvision /srv/synology # <- For airVision
# chown unifi-video:unifi-video /srv/synology # <- For UniFi-Video

Step 13
Update /etc/rc.local to preserve setup steps between reboots.

# vi /etc/rc.local

Add the following lines:

# Setup external iSCSI target after system reboot.
# For airVision
mount -t ext4 /dev/sdb1 /srv/synology
chown airvision:airvision /srv/synology

# For UniFi-Video:
mount -t ext4 /dev/sdb1 /srv/synology
chown unifi-video:unifi-video /srv/synology

Step 14
Reboot the NVR appliance, log in using SSH, and confirm that the network volume is mounted.

# mount -l
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=503449,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=403780k,mode=755)
/dev/disk/by-label/boot on /boot type ext2 (ro,noatime,errors=continue,user_xattr,acl) [boot]
/dev/loop0 on /mnt/.rofs type squashfs (ro,relatime)
/dev/disk/by-label/user.0 on /mnt/.rwfs type ext4 (rw,noatime,data=ordered) [user.0]
aufs-root on / type aufs (rw,relatime,si=3a448c58db75ada3)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=1588660k)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime,nodiratime,size=807560k)
/dev/mapper/lvm-data0 on /srv type ext4 (rw,noatime,nodiratime,data=ordered) [data]
/dev/sdb1 on /srv/synology type ext4 (rw,relatime)
tmpfs on /srv/synology/videos/temp type tmpfs (rw,relatime,size=1048576k)

Also look at the end of the system log for kernel/driver messages:

# dmesg
...
[ 18.053611] Loading iSCSI transport class v2.0-870.
[ 18.076880] iscsi: registered transport (tcp)
[ 18.444836] scsi4 : iSCSI Initiator over TCP/IP
[ 18.702584] scsi 4:0:0:0: Direct-Access SYNOLOGY iSCSI Storage 3.1 PQ: 0 ANSI: 5
[ 18.702882] sd 4:0:0:0: Attached scsi generic sg1 type 0
[ 18.703817] sd 4:0:0:0: [sdb] 2147483648 512-byte logical blocks: (1.09 TB/1.00 TiB)
[ 18.705417] sd 4:0:0:0: [sdb] Write Protect is off
[ 18.705428] sd 4:0:0:0: [sdb] Mode Sense: 3b 00 00 00
[ 18.706113] sd 4:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 18.726016] sdb: sdb1
[ 18.737119] sd 4:0:0:0: [sdb] Attached SCSI disk
[ 21.424863] EXT4-fs (sdb1): mounted filesystem without journal. Opts: (null)

Step 15

  1. Log in to UniFi Video and click Settings > NVR Settings > Configure tab > Recording Path.
  2. Change the path and click Save.

Note: The videos sub-directory must be created and given the correct permissions on the newly created file system before changing the Recording Path in NVR Settings.


Housekeeping


Back to Top

If you used the internal hard drive of the NVR for recording, it's important that you're aware of the following information:

  • Space to Keep Free (Storage based purging): This applies to the current storage location only and cannot be disabled. It will purge the oldest recordings to keep xGB (default of 10GB) free on the storage partition specified at all times.  Note that if you're using an external drive or storage larger than 500GB total, you should set this to 5% of the overall storage of the drive (overall storage of the drive * 0.05).  Each filesystem has a specified "reserved file space" that is supposed to be kept empty so the filesystem can use this space for deleting, copying, moving, etc.
  • Time-Based Purging: This applies to all recordings regardless of their storage location and can be disabled/enabled (disabled by default). It will purge any recordings older than the time you specify.

If you used the internal hard drive for recording and have now switched to external storage, it is strongly recommended to use Time-Based Purging temporarily so the recordings that remain on the internal drive are properly purged.  Although you have moved the location of the recordings using this article to external storage, the database still uses the internal storage. Therefore, there need be ample storage on the internal drive at all times.

 


Related Articles


Back to Top

Powered by Zendesk