Solving some NFS issues on Hikvision cameras

matter

n3wb
Joined
Nov 30, 2015
Messages
1
Reaction score
0
this is crazy, it worked for me for more then a year on Lenovo Iomega ix2, now I'm stuck,

any hint for 5.3 software?
I tried cifs insted of nfs with Quota but the same issue..
 

gav28uk

n3wb
Joined
Dec 12, 2015
Messages
13
Reaction score
2
Hi guys, I have just taken delivery of an HikVision DS-2CD2032F-I running firmware 5.3. As others, I can't get the NAS storage to initialise. I have a 1TB ReayNAS that is presenting the total capacity to the HikVision. The storage configurator utility is :puke:ing when I format the storage! So any ideas if/when HikVision are going to fix this bug?

As a workaround I attached a 300GB USB Drive to my Ready NAS. This then allowed me to create a 300GB share that the HikVIsion could then use! I now have NAS storage working :) Hopefully this little trick helps others until HikVision get their act together.

cheers
 

alastairstevenson

Staff member
Joined
Oct 28, 2014
Messages
15,950
Reaction score
6,785
Location
Scotland
Here is a skeleton of a method that was first suggested by another member (sorry but I forget who, so I can't attribute) and will only be useful to those who are Linux or NAS savvy. Which may be quite a lot.
And it will only work on a NAS that has reasonably good embedded Linux, not on those low-end models with very a very limited implementation.
It's not a recipe to follow by rote - it's an indication of a method, to be understood and adapted for potentially many different environments.
But maybe others will chip in with some ideas or results or other experience.

Summary:
Create a large file, sized for the volume size limitation of the specific camera firmware. 200GB should work for most.
Format the file as a file system, say ext2
Mount the file at a suitable mount point, add an entry to fstab for permanence.
Share the mount point using the NFS protocol.

A worked example is as follows, with some extraneous stuff removed:
Create the file.
Code:
[EMAIL="alastair@Mint64"]alastair@Mint64[/EMAIL] ~ $ dd if=/dev/urandom of=testfile bs=512 count=500k
512000+0 records in
512000+0 records out
262144000 bytes (262 MB) copied, 30.0246 s, 8.7 MB/s
[EMAIL="alastair@Mint64"]alastair@Mint64[/EMAIL] ~ $ ll testfile
-rw-rw-r-- 1 alastair alastair 262144000 Dec 13 12:48 testfile
Format as a file system:
Code:
[EMAIL="alastair@Mint64"]alastair@Mint64[/EMAIL] ~ $ mkfs -t ext2 testfile
mke2fs 1.42.9 (4-Feb-2014)
testfile is not a block special device.
Proceed anyway? (y,n) y
Discarding device blocks: done                            
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
64000 inodes, 256000 blocks
12800 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
32 block groups
8192 blocks per group, 8192 fragments per group
2000 inodes per group
Superblock backups stored on blocks: 
 8193, 24577, 40961, 57345, 73729, 204801, 221185
Allocating group tables: done                            
Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done 

[EMAIL="alastair@Mint64"]alastair@Mint64[/EMAIL] ~ $ file testfile
testfile: Linux rev 1.0 ext2 filesystem data, UUID=d8cdd56e-c16a-4355-b56b-474ad2bc6805
Create the mount point and mount the file:
Code:
[EMAIL="alastair@Mint64"]alastair@Mint64[/EMAIL] ~ $ mkdir testpoint
[EMAIL="alastair@Mint64"]alastair@Mint64[/EMAIL] ~ $ sudo mount -t ext2 testfile testpoint
[EMAIL="alastair@Mint64"]alastair@Mint64[/EMAIL] ~ $ mount
[snip]
nfsd on /proc/fs/nfsd type nfsd (rw)
/home/alastair/testfile on /home/alastair/testpoint type ext2 (rw)
[EMAIL="alastair@Mint64"]alastair@Mint64[/EMAIL] ~ $
The mount point needs to be added to the NFS /etc/exports list, using your favourite text editor, and exported.
Code:
[EMAIL="alastair@Mint64"]alastair@Mint64[/EMAIL] ~ $ cat /etc/exports
# /etc/exports: the access control list for filesystems which may be exported
#  to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#
/home/alastair/testpoint 192.168.1.0/24(rw,sync,no_root_squash,no_subtree_check)
[EMAIL="alastair@Mint64"]alastair@Mint64[/EMAIL] ~ $ 
[EMAIL="alastair@Mint64"]alastair@Mint64[/EMAIL] ~ $ sudo exportfs -v -a
exporting 192.168.1.0/24:/home/alastair/testpoint
At this point - the share should be available to a camera or NVR via NFS.
To make the mount permanent, to survive a reboot, the mount will need to be added to /etc/fstab
 

honzik

n3wb
Joined
Dec 29, 2015
Messages
1
Reaction score
0
Thank you gav28uk! I had the same problem with initialization as you had with firmware version 5.3.0 on my Hikvision ds-2cd2032-i 3MP Bullet IP Camera. I had no problem with firmware version 5.1.6: My ReadyNas Core 2 Duo could be formatted and was working fine. When I upgraded to firmware version 5.3.0 build 150814, I could no longer get my system to work. Whenever I would try to initialize my 1TB (out of 2TB total) share, it would return as "Normal" only to bounce back to "Uninitialized" once I switched to a different tab and back. Reading your solution, I bought a $40 dollar 512 GB USB drive from Amazon (originally intended for DVR storage), set it up for CIFS and NFS, mounted it and found I could initialize it with no problem.

My final problem was that the playback continued to read "No Record File", but the problem boiled down to not setting the enable record schedule checkbox on the Configuration/Storage/Record Schedule page. I'm wondering if that checkbox was not there originally, because I don't remember having to set it. Also, I may go back to see if I can reduce the share size on my regular drives and see if I can get it to initialize, although I'm so happy it's working I don't think I'll mess with it for a while....

One other thing: before figuring out the last problem, I was able to use FTP to my directory 192.168.x.xxx/ftpserver/NamedCam. It only seemed to work with the Smart Events though. I used the child directory setting with the parent setting set to the custom value of: ftpserver. Once, though, I got the video working, the FTP stopped; I'm guessing it can't simultaneously record video and FTP images.

Lastly: I do like this firmware version. I like being able to turn my IR light off, I like the options for testing FTP and other things, I like the options for custom folder names. And, the ntp time servers seem to work without an issue (pool.ntp.org port 123). I would have been really happy, though, if it worked with my NAS "out of the box" without so many problems.

Anyway, thanks so much gav28uk! I couldn't have done it without your help! :)
 
Last edited by a moderator:

denisl

n3wb
Joined
Jan 17, 2016
Messages
9
Reaction score
2
Hi, everyone.
Here is the patch for 5.2.5.

DCC09DE54900001A0B005CE14700001A - original
DCC09DE5000000000B005CE100000000 - patched

Pay attention on packing davinci back to davinci.tar.gz. This is not a gzip! This is LZMA! You can check it in /dav/initrun.sh. There is an instruction tar -axf, where -a key means lzma.
So, the right way to pack davinci.tar.gz is:

Code:
[COLOR=#000000][FONT=Tahoma]# tar -cf davinci.tar davinci[/FONT][/COLOR]
[COLOR=#000000][FONT=Tahoma]# lzma davinci.tar[/FONT][/COLOR]
[COLOR=#000000][FONT=Tahoma]# mv davinci.tar.lzma davinci.tar.gz[/FONT][/COLOR]
UPD: By default shedule has type other on each day and hour. Set this into "Continious" and it'll be allright.

Here is the link for 5.2.5 patched davinci.tar.gz with NFS patch.
If you can read russian, more info you can find here.
I'm running V5.2.5 build 141201 on a DS-2CD2232-I5.
Has anyone successfully implemented this patch? I opened the davinci file with HexEdit and the original one on my system doesn't appear to have the hex string "DCC09DE54900001A0B005CE14700001A" listed above which needs to be replaced.
I also extracted the link badbob posted and opened with HexEdit and cannot find the patched "DCC09DE5000000000B005CE100000000" hex code provided above. I think I'm doing something wrong.

Thanks
 

pila

n3wb
Joined
Sep 28, 2015
Messages
25
Reaction score
2
Location
Croatia
p1/2 Saving 4 different ways: 2x Asustror NAS, and direct 2x

As recordings work well for me, my experience might be of use to someone :)

I have NAS Asustor AS-202TE, Hikvisions are all 3 MPixels IP: 3 different models, firmware v5.2.5 and v.5.3.0. Cameras are CH (Chinese) and one is World (WR). All 3 sound variants are also covered (None, 1 way, 2 way). I am currently recording fullHD 1080p 10, 25 and 30 fps. They all work the same for me!

Currently: 2 cameras are recored by NAS program itself. 3 Cameras record directly to NAS. One camera records to a MicroSD. I have 4 cameras. Ones from the first sentence are also recording by themself at the same time. All using LAN (not WLAN).

Recording to the NAS using its own program

1. Recording to the Asustor NAS using its own program called Surveillance center. Unfortunately, current unusable.

When I configure cameras as Hiks, recording is mostly useless: smears, ghosts, empty spaces where movement is.... Terrible. As I am in EU, my cameras are set to PAL 50 HZ and 1/25. Surveillance center changes that to NTSC 60 Hz, and does not even offer Eu settings (25 fps).

VBR (changed on camera) is unusable, and CBR 30 FPS (set by Asustor) is partially usable. Problem is probably with the current FFMPG library they use to (obviously) recode stream.

When i set cameras as ONVIF, settings all seem nice, I can see both streams, but nothing gets recorded to NAS. Hmm, I lied in the title :) about 2x Asustor recording

On the plus side, recordings are saved to the perfectly reasonable file structure with perfectly understandable file names and I can watch them normally with my Raspberry Pi 2 (Kodi) on anything (TV, tablet, phone, computer).

Asustor program breaks for Live viewing on PC, shows recordings nice and even offers some nice search capabilities, but they do not work (probably need some ultra fast and strong computer). UI is clear and would be very nice for reviewing recordings if it actually worked. NAS has HDMI: displays 1 frame from the camera every 2 seconds (0,5 FPS). I will complain to their support after this post.

Now, I normally watch recordings using Raspberry Pi 2 and Kodi.

If all worked normally, Asustor Surveillance center would be my preffered way to record, search for and watch recordings. For now, it is unusable.
 
Last edited by a moderator:

pila

n3wb
Joined
Sep 28, 2015
Messages
25
Reaction score
2
Location
Croatia
p2/2 Saving 4 different ways: 2x Asustror NAS, and direct 2x

To save cameras directly to NAS, first the NAS must be configured, then the cameras. To save to MicroSD, only 2 steps are needed.

2. When trying to make cameras directly save to my NAS, I first tried NFS - did not work. Then switched to CIFS and tried to set cameras to the subfolders (/cameras/doors, /cameras/garden...), no go. Then I did open separate root folders for each cameras and tried with a common user. No go (% for recordings and stills would not stay as I wanted them at 100% and 0%). Giving each camera its own user with a quota and own root folder work perfectly. For test, I inserted an 8 GB MicroSD into one Hikvision DS-2CD2432F-IW and it is saving to this internal card, not the NAS. Procedure was the same for all the cameras, regardless of the firmware or models.

2.1. Create folders fore each camera using my NAS software. Assign rights to existing accounts - Admin and others - as needed (RW).

2.2. Create users for each camera, assign the folder to it and assign Quota to it. This is all done in one go in Asustor. Access Control -> Local Users -> Add New User. There I enter username and pwd, then Next, Next, select the folder from the previous step (I used the same name for the camera, user and folder) and simply clicl RW (allow Read Write rights to that user for that folder). Next step in Asustor is: Assign User Quota. Same is possible when editing existing accounts. I assigned 30 GB for cameras with small traffic, and 100 for larger needs. Done on server side.

Any NAS worth its salt must be able to assign User Quota. This is part of Unix for probably 50 years. Procedure will differ. but terms will be more or less the same.

Then we switch to the cameras.

3. Storage -> NAS: Server address: 192.168.1.5 (adapt the address, this is my NAS), File path: \Room. Camera is called Room, user, folder, everything has the same name for a single camera. Does not need to be so, but is easier. Mounting -> SMB/CIFS, enter username (Room from my example) and pwd. Button Test shows if all is good. If not, fix it.

4. Storage -> General -> Update, just click several times on Update. If it shows the assigned user quota here (e.g. 100 GB or 30 GB for my system), it will work perfectly. If it shows entire hard drive capacity (1837 GB for my system), it will not work at all (unless the drive is used only for this camera).

5. Select your NAS disk on top, Set Quota ration for Recording and Pictures (I set 100% and 0% respectively). I recommend changing them for at least 1%. Click very ill named button Format (should have been e.g. Prepare). In few minutes, done. Click Save.

6. If Quota ration for Recording and Pictures reverted to 75:25 and you set it differently, it will not work, something is wrong. Click Test several times, applies all written at step 4.

7. Activate alarming. Event -> Motion Detection -> Enable Motion Detection and Enable Dynamic Analysis for Motion and set Sensitivity (trial and error method). There is much more precise way for Motion detection if Configuration is changed to Expert. Notify Surveillance Center and Trigger Channel are both of use here but with different functions, simply click them both.

8. Activate Recording. If using Web interface, it is below Motion settings. If using iVMS-4200 it is Event -> Schedule. Activate it (click Local Recordings on iVMS), and make sure it is set to Alarm Template (not blue All Day Template). Lots of differences visually between Web and iVMS. I prefer iVMS. Click Save. Only steps 7. and 8. are needed for saving onto MicroSD inside the camera.

9. Recheck step 6. If all is correctly displayed as per step 4 and 6. you are guaranteed to have succeeded!


Problem: iVMS-4200(v2.4.1.3) works usably, but displays recordings at half speed (shows 1x but 1 second is displayed for 2 seconds). Any other command will freeze pic, no skipping, no rewinding. Terrible UI. RP2: I can not identify files, so I must use iVMS or Web interface for viewing.

Tidbits:
- Web interface -> configuration: where a file will be saved when copied from the camera
- iVMS-4200 v2.4.1.3 System -> General -> Overwrite Record File -> Yes - I Strongly suspect this setting is used for what its name suggests :) This item is not visible in Web interface on my computer.
- System, Time setting: I entered 192.168.1.5, port 143 - meaning take tame from my local Asustor NAS server. My NAS is the only device making external time synch. All other devices, Raspberries, cameras, computers... synch from it so all have the same time. Curiosity: Web config did not see I adjusted Time zone using iVMS-4200!
- Web interface: On my cameras I have 2 versions of WebComponents.exe. Older is 1.7 MB (on cams v5.2.5) and newer is 2,2 MB (on cams v5.3.0). Older 1.7 MB one works perfectly in my Firefox, newer breaks display completely.
 
Last edited by a moderator:

thejipster

n3wb
Joined
Feb 26, 2016
Messages
5
Reaction score
1
Here is a skeleton of a method that was first suggested by another member (sorry but I forget who, so I can't attribute) and will only be useful to those who are Linux or NAS savvy. Which may be quite a lot.
And it will only work on a NAS that has reasonably good embedded Linux, not on those low-end models with very a very limited implementation.
It's not a recipe to follow by rote - it's an indication of a method, to be understood and adapted for potentially many different environments.
But maybe others will chip in with some ideas or results or other experience.

Summary:
Create a large file, sized for the volume size limitation of the specific camera firmware. 200GB should work for most.
Format the file as a file system, say ext2
Mount the file at a suitable mount point, add an entry to fstab for permanence.
Share the mount point using the NFS protocol.

A worked example is as follows, with some extraneous stuff removed:
Create the file.
Code:
alastair@Mint64 ~ $ dd if=/dev/urandom of=testfile bs=512 count=500k
512000+0 records in
512000+0 records out
262144000 bytes (262 MB) copied, 30.0246 s, 8.7 MB/s
alastair@Mint64 ~ $ ll testfile
-rw-rw-r-- 1 alastair alastair 262144000 Dec 13 12:48 testfile
Format as a file system:
Code:
alastair@Mint64 ~ $ mkfs -t ext2 testfile
mke2fs 1.42.9 (4-Feb-2014)
testfile is not a block special device.
Proceed anyway? (y,n) y
Discarding device blocks: done                            
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
64000 inodes, 256000 blocks
12800 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
32 block groups
8192 blocks per group, 8192 fragments per group
2000 inodes per group
Superblock backups stored on blocks: 
 8193, 24577, 40961, 57345, 73729, 204801, 221185
Allocating group tables: done                            
Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done 

alastair@Mint64 ~ $ file testfile
testfile: Linux rev 1.0 ext2 filesystem data, UUID=d8cdd56e-c16a-4355-b56b-474ad2bc6805
Create the mount point and mount the file:
Code:
alastair@Mint64 ~ $ mkdir testpoint
alastair@Mint64 ~ $ sudo mount -t ext2 testfile testpoint
alastair@Mint64 ~ $ mount
[snip]
nfsd on /proc/fs/nfsd type nfsd (rw)
/home/alastair/testfile on /home/alastair/testpoint type ext2 (rw)
alastair@Mint64 ~ $
The mount point needs to be added to the NFS /etc/exports list, using your favourite text editor, and exported.
Code:
alastair@Mint64 ~ $ cat /etc/exports
# /etc/exports: the access control list for filesystems which may be exported
#  to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#
/home/alastair/testpoint 192.168.1.0/24(rw,sync,no_root_squash,no_subtree_check)
alastair@Mint64 ~ $ 
alastair@Mint64 ~ $ sudo exportfs -v -a
exporting 192.168.1.0/24:/home/alastair/testpoint
At this point - the share should be available to a camera or NVR via NFS.
To make the mount permanent, to survive a reboot, the mount will need to be added to /etc/fstab
Can you possibly provide a screen shot of how the configuration on the IP cam looks like?
Are you specifying the "File Path" on the cam configuration screen as "/home/alastair/testpoint" or / ? I tried following your example in creating ext2 file system mount pt and exported it via NFS, but I can't seen to get the mounting to work properly still.
 

alastairstevenson

Staff member
Joined
Oct 28, 2014
Messages
15,950
Reaction score
6,785
Location
Scotland
but I can't seen to get the mounting to work properly still.
Check out the system logs of your NAS/Linux box for any clues as to why the mount attempt failed.

With the caveat that:
NFS implementations and configurations will vary, and Hikvision NFS support is different between the NVRs and the cameras, and probably also the firmware versions ...
And my QNAP NAS names NFS shares as just the bottom-level exported folder of the /Shares folder, and my Linux Mint box names them as the full multi-level file path ...
So what works for me may not necessarily work for you ... such is the world of the ipc experimenter.

I revisited this, and created a slightly more realistic file size (as it takes ages to create), and grabbed some screenshots:

NFS_1.jpgNFS_2.jpg

And some command-line stuff:

The camera
Code:
login as: root
[EMAIL="root@192.168.254.11's"]root@192.168.254.11's[/EMAIL] password:

BusyBox v1.19.3 (2014-07-11 11:25:54 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.
# mount
rootfs on / type rootfs (rw)
/dev/root on / type ext2 (rw,relatime)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
ramfs on /home type ramfs (rw,relatime)
udev on /dev type tmpfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
/dev/ubi1_0 on /dav type ubifs (rw,relatime)
/dev/ubi3_0 on /davinci type ubifs (rw,relatime)
/dev/ubi4_0 on /config type ubifs (rw,relatime)
192.168.1.201:/cctv1 on /mnt/nfs00 type nfs (rw,sync,relatime,vers=3,rsize=4096,wsize=4096,namlen=255,acregmin=0,acregmax=0,acdirmin=0,acdirmax=0,soft,noac,nolock,proto=tcp,port=65535,timeo=70,retrans=3,sec=sys,local_lock=all,addr=192.168.1.201)
192.168.1.96:/home/alastair/testpoint on /mnt/nfs01 type nfs (rw,sync,relatime,vers=3,rsize=4096,wsize=4096,namlen=255,acregmin=0,acregmax=0,acdirmin=0,acdirmax=0,soft,noac,nolock,proto=tcp,port=65535,timeo=70,retrans=3,sec=sys,local_lock=all,addr=192.168.1.96)
# ls -alR /mnt/nfs01
/mnt/nfs01:
drwxrwxrwx    3 65534    nogroup       4096 Feb 26 15:20 .
drwxrwxrwx   13 root     root          1024 Feb 26 15:18 ..
drwxr-xr-x    2 root     root          4096 Feb 26 15:19 datadir0
-rwxr-xr-x    1 root     root            68 Feb 26 15:20 info.bin
/mnt/nfs01/datadir0:
drwxr-xr-x    2 root     root          4096 Feb 26 15:19 .
drwxrwxrwx    3 65534    nogroup       4096 Feb 26 15:20 ..
-rw-r--r--    1 root     root           512 Feb 26 15:20 HIKWS
-rw-r--r--    1 root     root          1120 Feb 26 15:19 backupinfo00.bin
-rw-r--r--    1 root     root          1120 Feb 26 15:19 backupinfo01.bin
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00000.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00000.pic
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00001.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00002.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00003.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00004.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00005.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00006.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00007.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00008.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00009.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00010.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00011.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00012.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00013.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00014.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00015.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00016.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00017.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00018.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00019.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00020.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00021.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00022.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00023.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00024.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00025.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00026.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00027.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00028.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00029.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00030.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00031.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00032.mp4
-rw-r--r--    1 root     root             0 Feb 26 15:19 hiv00033.mp4
-rw-r--r--    1 root     root        698688 Feb 26 15:19 index00.bin
-rw-r--r--    1 root     root        328992 Feb 26 15:19 index00p.bin
-rw-r--r--    1 root     root        698688 Feb 26 15:19 index01.bin
-rw-r--r--    1 root     root        328992 Feb 26 15:19 index01p.bin
-rw-r--r--    1 root     root      16002048 Feb 26 15:22 logCurFile.bin
-rw-r--r--    1 root     root      32004192 Feb 26 15:20 logMainFile.bin
#
The Linux box
Code:
[EMAIL="alastair@Mint64"]alastair@Mint64[/EMAIL] ~ $ sudo exportfs -v
/home/alastair/testpoint
                <world>(rw,wdelay,no_root_squash,no_subtree_check,sec=sys,rw,no_root_squash,no_all_squash)
[EMAIL="alastair@Mint64"]alastair@Mint64[/EMAIL] ~ $
 

thejipster

n3wb
Joined
Feb 26, 2016
Messages
5
Reaction score
1
I have been able to SMB mount it without issues. i had followed another persons suggestion of creating a file based partition using ext2 format.
The I mounted that as a new partition with my Rasp Pi, exported it SMB and NFS

Created a generic file
dd if=/dev/urandom of=videos.ext2 bs=512 count=1800000

mkfs -t ext2 videos.ext2

/etc/fstab

/home/cam2/videos.ext2 /home/cam2/videos ext2 defaults,usrquota,grpquota 0 6

/etc/samba/smb.conf
[backyard]
guest ok = no
create mask = 0755
comment = Security Camera 01
browsable = yes
path = /home/cam2/videos/recordings
write list = cam2
writable = yes


/etc/exports

/home/cam2/videos/recordings 192.168.10.12(rw,sync,no_root_squash,no_subtree_check)





I can SMB mount, but can't initialize. A lot of people mentioned that I need to make sure the partition is completely empty, which I did.
NFS mount to my Pi NFS server is using the IP /home/cam2/videos/recordings, but doesn't seen to connect at all.

Checked /var/log and cant' find any NFSD related logs.

hmmmm......
 

alastairstevenson

Staff member
Joined
Oct 28, 2014
Messages
15,950
Reaction score
6,785
Location
Scotland
Hmmm... indeed.
What does the 'Test' button show?
The action is to write a file and delete it, to confirm availability and access control.
 

thejipster

n3wb
Joined
Feb 26, 2016
Messages
5
Reaction score
1
Hmmm... indeed.
What does the 'Test' button show?
The action is to write a file and delete it, to confirm availability and access control.
I got my NFS issue worked out related to rpcbind not starting. So now I get a "testing succeeded"
However, when I tried format, I still get a "Device Error" returned.

I must be missing something......
 
Last edited by a moderator:

alastairstevenson

Staff member
Joined
Oct 28, 2014
Messages
15,950
Reaction score
6,785
Location
Scotland
Well, that's at least a step along the way.
"Device Error" certainly doesn't help.
I'm not sure what to suggest, sorry.
 

thejipster

n3wb
Joined
Feb 26, 2016
Messages
5
Reaction score
1
Well, that's at least a step along the way.
"Device Error" certainly doesn't help.
I'm not sure what to suggest, sorry.
Here is what finally solved it on the exportfs configuration
/home/cam2/videos 192.168.0.0/16(insecure,rw,all_squash,anonuid=1002,anongid=1003,no_subtree_check)

The cams use NFS v2, Macs uses NFS v3, and modern Unix uses NFS v4.
In the earlier version, the high ports are used from the source IP (> 1024), in order for NFS to support this, the "insecure" word had to be used.

I hope this helps someone out there.
 

alastairstevenson

Staff member
Joined
Oct 28, 2014
Messages
15,950
Reaction score
6,785
Location
Scotland
Excellent! Full marks for problem solving, and kudos for sharing to help others.
I wonder if Hikvision will be changing how the devices store to a 'NetHDD'? It's not one of the better designed parts of the firmware.
all_squash
So you've gone for anonymous access - any particular reason? Was it one of the changes needed to make it work?
 

thejipster

n3wb
Joined
Feb 26, 2016
Messages
5
Reaction score
1
Excellent! Full marks for problem solving, and kudos for sharing to help others.
I wonder if Hikvision will be changing how the devices store to a 'NetHDD'? It's not one of the better designed parts of the firmware.

So you've gone for anonymous access - any particular reason? Was it one of the changes needed to make it work?
We all can agree that the NetHDD implementation is less than ideal. NFS V2, V3 doesn't support authenticated access. For now, I will continue to use NFS until I can get SMB to work properly. I will have to go back to packet capture analysis for SMB when I have time.
 
Joined
May 6, 2016
Messages
4
Reaction score
2
Hi everybody!
After 1 week of poking around NFS/Samba I finally managed to set it up correctly with SAMBA (because NFS version used by the cameras does not support user authentication (you'll see later on why we need this)!

Here is my setup:
  1. 4 Hikvision IP cameras, 3x DS-2CD2T22-I5, firmware V5.3.0 build 151016 and 1x DS-2CD2622FWD-IZS, firmware V5.3.6 build 151105
  2. powered through a POE switch
  3. 24h running Linux Fedora 22 X64 server (used for hosting Plex, BOINC, Seafile and other stuff), kernel 4.4.8-200
  4. RAID LVM partition of 8TB mounted under /storage where I want my cameras to write in
  5. Samba server ver. 4.2.11
  6. Quota ver. 4.03

Steps:
  1. Enabling quota - credits here.
    • look into etc/fstab for the words usrquota or grpquota next to the line mounting your desired partition. If it's not there, add it like this:
    • Code:
      /dev/mapper/alph--lvm-home    /storage    ext4    defaults[COLOR=#ff0000],usrquota,grpquota[/COLOR]    1 2
      (no space after the ,)
    • restart or remount if you don't have files in use
  2. Create one user for each camera with settings like below (8 character passwords, home directory and private group). I created 4 users camera1...4:
    • Screenshot from 2016-05-13 12-32-56.png
  3. Create one directory for each camera on your desired partition/location. I created 4 directories /storage/camera1...4
  4. Change owner and group of each directory to each corresponding user created above.
    • camera1 directory belongs to user and group camera1 and so on
  5. Create the quota files (aquota.user and aquota.group) using:
    Code:
    quotacheck -cug /storage
    - it has to be done under /storage
  6. Generate the table of current disk usage per file system with quotas enabled using:
    Code:
    quotacheck -avug
  7. Assign quota per user:
    • Code:
      edquota camera1
      replace the 0 under hard column with your desired value; for 400GB it is 419430400, for 200GB is 20971500. You can compute your own as another user on this thread was kind to tell us by using:
      Code:
      python -c "print [COLOR=#ff0000]XXX[/COLOR]*1024**"2"
      where XXX is your desired GB
    • do it for the other users as well
  8. Check if it's ok with
    Code:
    quota camera1
    . If you want to add more options like time limits etc... please look into the credits link.
  9. Now let's setup SAMBA. I used the GUI /usr/bin/system-config-samba. If you don't have it, install it.
    • click on Preferences, Samba Users and add all users created before, camera 1...4
    • click on Preferences, Server Settings, Security and make sure, you have it like this:
    • Screenshot from 2016-05-13 13-14-58.png
    • Click on add a Samba share and point to the directories created before, camera 1...4, assign a short name like camera1 and check Writable and Visible:
    • Screenshot from 2016-05-13 13-17-31.png
    • On tab Access select "Give access to these users and check one corresponding user for each camera
    • restart the Samba server by using
      Code:
      service smb restart
    • make it run at boot by using
      Code:
      systemctl enable smb
      and start it by using
      Code:
      systemctl start smb
    • check if it's OK by using
      Code:
      service smb status
  10. Going back to the camera storage setup. You have to use a short path in the File path exactly like this /camera1...4 with a / not a \. Click on test, then on save, then on HDD Management tab where you'll see the HDD without the values yet. Click again on NetHDD tab and again on test and on save and after you finally get back to HDD Management tab you can select the new HDD and format it.
    • Printscreen01.jpg
  11. Restart everything
  12. In conclusion, you don't need to set it at around 200GB you can go as much as 400GB or even higher, thing is the camera needs to see all the free space and the capacity for itself, this is why you need to setup the quotas.
 

alastairstevenson

Staff member
Joined
Oct 28, 2014
Messages
15,950
Reaction score
6,785
Location
Scotland
Great write-up, thanks for sharing!

Just a small comment :
"you don't need to set it at around 200GB you can go as much as 400GB"
I believe this varies with the camera firmware version.
But easy to test with user quotas as you've explained.
When I first used an NFS or SMB/CIFS NetHDD destination on a 5.2.3 version camera, it was bad at 250GB but OK at 200GB.
I think there have been posts where it's been OK at 500GB, so it looks like the exact ceiling varies.
 

Optimus Prime

Getting the hang of it
Joined
Sep 29, 2014
Messages
280
Reaction score
30
Hi all. I just looked through this thread and cannot find a clear answer. Is there a way to setup a windows share to receive the files?

We are unable to install Samba/Unix extensions on the Win7 Pro boxes. We can get the camera to speak to the windows share for a short time...and record triggered events, but then we lose it and have to start again.

I have 70 machines that each need a camera to access a windows share, and I am unable to install a software NVR nor a hardwae NVR.
 
Top