HikVision SMB/CIFS Issues - A Summary of Fixes

Discussion in 'Hikvision' started by SamboNZ, Jul 31, 2016.

Share This Page

  1. SamboNZ

    SamboNZ n3wb

    Joined:
    Apr 30, 2016
    Messages:
    4
    Likes Received:
    4
    I have just wasted a few hours of my life wrestling with SMB/CIFS formatting issues with my Hikvision DS-2CD2332-I v5.2.5 build 141201 and since the information required to fix it was scattered across the entire Internet I thought I'd create a post to consolidate it all to hopefully save others the same pain in future.

    I am by no means an expert at this and I've only ever setup one camera, so please feel free to contribute with either additional tips, or corrections if you think I have my facts wrong! All constructive input gladly accepted! If any new / corrected information comes to light I will update this post to make it as accurate as possible.

    This information may be relevant to Hikvision models other than mine, but I can't confirm / test this.

    kyphos has written up a great guide for OSX users which builds on this information.


    The Unbendable Rules

    1) You must use a drive which is dedicated to the camera recordings. (Also see 'Flexible Rule' #2)
    - If any changes are made to the amount of free space on the recordings drive, other than by the camera, the storage status will revert to 'uninitialized'.
    - NOTE: In this case, 'drive' refers to a 'logical' drive, not necessarily an entire 'physical' drive, ie; you can use a partition which is part of a larger drive if you like.
    - NOTE 2: As per rpc's suggestion, you can also use virtual drives such as a VHD or VHDX volume in Windows, which allows for additional flexibility and removes the requirement to dedicate an entire physical volume or partition for recording.

    2) To successfully 'format' a target storage 'HDD', the camera must be able to delete ALL files and folders underneath the shared folder to make it COMPLETELY EMPTY.
    - This means that the target share on a Windows system cannot be the root of the drive, because there are hidden system folders which the camera can't delete and so the format will fail.
    - NOTE: The 'Format' process won't actually wipe the entire logical drive, but it WILL DELETE ALL FILES AND FOLDERS under the target share, including previous recordings!
    - NOTE 2: Another reason why a format might fail is that the user you have configured on the camera doesn't have at least 'Modify' permissions on the target share and or folder and all it's sub-folders (if any).
    - Also see 'Flexible Rule' #2

    3) You must refer to the share name on your target system with a leading backslash '\'.
    - Apparently this should be a forward slash '/' if your target system is linux based, but I can't confirm this.
    - You must use a IP address or DNS resolvable name to refer to your target system. NetBIOS / WINS / Workgroup machine names will not work. If in doubt, use an IP.

    HikVision.png

    4)
    If you make any changes to the setup of your 'NAS' configuration profile, you will need to re-enter the password (even if it 'shows' as dots in the password field).
    - If the 'HDD' connect test doesn't pass, there's something wrong.
    - NOTE: Don't forget to save using the 'Save' button after any changes!
    - NOTE 2: If in doubt, or if it's just not working, despite all entries being correct, 'delete' the 'NAS' HDD profile (see #6)

    5) If you make any changes to the target system's storage configuration, you will need to delete the 'NAS' HDD profile (see #6)

    6) To 'Delete' a 'NAS' HDD profile, you need to delete all text from all the fields, set the Mounting Type to 'NFS', and save using the 'Save' button. (Also see 'Flexible Rule' #1)

    7) Quotas (set on the 'Storage Management' page, are not able to be changed after the 'HDD' has been 'Formatted', they must be changed before the 'Format' is started to be effective.


    The Flexible Rules

    1) To refresh a screen / tab (especially the 'Storage Management', one), I have found that you need to click on another tab and wait for 5 seconds. Refreshing the browser page may also work.

    2) While there seems to be no conclusive consensus about the size limitations of a target drive, the following is the closest I could find:
    - Minimum size: 10GB
    - Maximum size: 'just under' 250GB*
    - Symptoms due to violation of these size limits include being unable to 'Format' the 'HDD', or reversion to 'Uninitialized' status after a period of time, after an apparently successful 'Format'.
    - * NOTE: This limitation may be able to be overcome by using the '525 NAS Patch' (origins unknown) which can be found here. While I have installed this patch, I haven't tested it beyond my 249GB recording drive, but there are reports of others using this successfully with up to 4TB drives.


    Hopefully this helps someone out in future!

    Please let me know if anyone has anything to add / correct!
     
    Last edited by a moderator: Aug 18, 2016
  2. edmscan

    edmscan n3wb

    Joined:
    Jul 6, 2016
    Messages:
    12
    Likes Received:
    0
    Thank you .. I had the same findings when recording to my Windows 10 PC. Btw .. Hikvision did not have a clue as to why it kept on going to 'initialized' state and not staying on normal. They recommended buying one of 3 brands of supported NAS devices.

    In my case .. I tried first with a shared folder which did not work and then tried a separate partition which was fine.

    But I gave up .. as I found that my 2432-IW camera did not record well at all when going to the NAS storage. It did not do probably over 50% of the recordings even though the logs showed that the alarm events were triggered. As I only have one camera I was not willing to buy a dedicated NAS device. Mine is not a 'Chinese' camera and is running the latest firmware.

    I have since been recording to my SD card and no problems at all .. everything records fine.
     
  3. SamboNZ

    SamboNZ n3wb

    Joined:
    Apr 30, 2016
    Messages:
    4
    Likes Received:
    4
    Yeah, I guess we're getting what we pay for in terms of:
    - Coding quality
    - QA testing
    - Support

    Which is a pity, because the hardware and picture quality appear to be excellent and the software is well featured; it's just that last 1% 'polish' that's missing.

    I don't seem to have any issues with the unit not recording; the logs match up well with the recorded footage, but that's good to know.
     
    Last edited by a moderator: Aug 11, 2016
  4. rpc

    rpc n3wb

    Joined:
    Jul 4, 2015
    Messages:
    16
    Likes Received:
    5
    Recording also works well with virtual drives. I'm using Microsoft's VHD-/VHDX-feature in Windows. It's quite flexible this way, and not that limited as with real HDD-partitions.

    My config assigns each cam its own vhdx-file, as smb/cifs-share, all on the same real HDD. I'm doing it this way for more than a year now, no problems.
     
  5. SamboNZ

    SamboNZ n3wb

    Joined:
    Apr 30, 2016
    Messages:
    4
    Likes Received:
    4
    Thanks for that input rpc, that's a really good idea! I'll add it in the main post and credit you.
     
  6. TD22057

    TD22057 n3wb

    Joined:
    Mar 14, 2015
    Messages:
    22
    Likes Received:
    1
    FYI I use an Ubuntu server and have two cameras writing to SMB shares that are just folders on a single disk. I created a SMB user for each camera and gave that user write permissions to the folder. Then I added a disk quota to the folder for whatever size I wanted to limit the camera to. Then I enabled that folder as an SMB share for the camera and configured the camera to use it. Works fine - no logical volumes, partitions, etc. were needed.
     
    Gul-Dukat likes this.
  7. kyphos

    kyphos n3wb

    Joined:
    Aug 10, 2016
    Messages:
    14
    Likes Received:
    1
    Like SamboNZ, I also spent a few hours of my life wrestling with SMB mount/format issues so my new DS-2CD2112F-I (with V5.3.0 firmware) could save video to my file server. In my case, the desired destination is an old Mac mini running OSX 10.6.8. After a lot of trial and error, I was successful. This thread was extremely helpful - my thanks to SamboNZ for posting it.

    For the benefit of others with a Mac environment, here's a roadmap that may help you in your quest...

    My Mac mini already was already equipped with a large external hard drive, but Unbendable Rule #1 (above) indicates that one should use a hard drive dedicated to camera recordings. Further, the Hikvision firmware expects to be able to use the entire volume.

    OSX is capable of supporting the NAS file storage protocol, but it's not enabled by default. Ms. Google can tell you more if you're interested in it. I'm not, so I decided to use SMB, which is easy to enable in Sharing preferences.

    OSX is also capable of establishing per-user volume quotas, something that Hikvision seems to require. This is not a feature that is made visible by default in OSX -- some wizardry in the Terminal is required. For those inclined to pursue quotas, here's one reference that Ms. Google found:
    http://www.cnet.com/news/how-to-limit-user-disk-space-with-partitions-and-quotas-in-os-x/

    I decided to use a hardware solution to establish a fixed quota for the SMB volume. (Hard drives are cheap). I dusted off an old 120 GB drive, and partitioned it as two 60GB volumes (formatted as HFS+ Extended (Journalled)). I have two new Hikvision cameras, and will dedicate one partition to each camera. The drive connects to the Mac mini with Firewire 400.

    Some may question whether 60GB is adequate storage for HD security video. My intent is to use motion detection in the camera and only record triggered video. However, if I find that 60 GB per cam is not enough, I'll just replace the 120 GB hard drive with a TB or two.

    Thanks to the invaluable guidance in Unbendable Rule #2, I created a folder at the top level of each partition (/CAMERA1 and /CAMERA2).

    Next step: create a userid on the Mac mini to be used by the cameras to authenticate with the server. I prefer not to reveal my primary userid and password to observers at hikvision.cn, so I set up a new userid 'hik' (using Sys Preferences/Accounts) with Sharing Only permissions. There's no need for that account to log in to the Mac mini as a regular user, and it doesn't need a Home folder. The Sharing Only configuration allows the cameras to authenticate with the server and access the shared volumes.

    Publishing the folder/volume for access by the camera is configured in Sys Preference/Sharing:
    First, ensure that SMB protocol is enabled, by clicking Options
    on the Sharing pane. Then:

    • select Share files and folders using SMB
    • click the checkbox next to the 'hik' user
    • click Done
    Now share the folder that will become the mount point used by the camera:

    • click the +sign under Shared Folders to add another share point.
    • navigate to the partition on the external hard drive, and select the top-level folder (eg. "CAMERA1").
    • click on CAMERA1 in the list of Shared Folders to select it.
    • click +sign below the list of Users and add 'hik' to the users authenticated to access the CAMERA folder, assigning Read & Write permissions.
    • close the Sys Preferences window

    If you're a Mac user, no doubt you'll have another Mac on your network. It's a good idea to check that you can mount the /CAMERA1 share on your server using user hik's credentials using SMB.
    - from the Finder, enter Cmd-K to bring up the Connect to Server dialog.
    - enter smb://<ip-of-server>/CAMERA1
    - click Connect
    - enter the credentials for user 'hik' to authenticate.
    A Finder window should appear showing the empty CAMERA folder (which is the mount point that will be used by the camera).

    Configuring the camera to access this SMB volume is as described in SamboNZ's tutorial. Be sure to specify the File Path with a backslash (e.g., \CAMERA1).

    I find the Hikvision firmware very finicky when entering the data in the NAS page. On several occasions, I would correctly enter the Mac mini's IP, file path, userID and password, yet the Test would fail. I'd erase the data, re-enter them, save them, test again, etc etc. Eventually I was able to get the Test to succeed, but there are definitely bugs in this part of the camera's NAS code.

    Once the Test succeeded, I then opened the Storage Management page and 'formatted' the \CAMERA1 volume. If it succeeds, you can see what the 'format' is doing by viewing the /CAMERA1 folder on the Mac mini. You'll find it preloaded with a series of .MP4 and .PIC files.

    My 2112 domecam is now recording motion-triggered video and pictures to the Mac mini.

    Roadmap 2
    Earlier in this thread, member roc indicated success with Microsoft's VHD virtual drive technology. I don't do Windows, but that post gave me the idea of trying something similar with OSX disk images. Alas, I've not been successful. Using Disk Utility, I created a number of disk images on the Mac mini, of various sizes (10GB, 15GB, 20GB) and with various partition schemes. As described above (and in Unbendable Rule #1), I then put a top-level folder in the virtual disk, and shared it. I've been able to get the camera to recognize it as an SMB volume (the Test on the NAS page succeeds), but the Format always fails. After a few hours messing with disk images, I abandoned the approach.

    If someone figures out how to use OSX disk images with Hikvision cameras, please share the secret.


    A caveat
    As noted at the top, my (old) Mac mini is running (old) 10.6.8. That vintage of OSX implemented version 1 of the SMB protocol. In 10.9 (Mavericks), Apple migrated to SMB2, a 'new and improved' protocol stack. Your results may vary if you're running 10.9 or later. The Hikvision cameras might well be using SMB1, and might not play nicely with an OSX system using SMB2.

     
    Last edited by a moderator: Aug 12, 2016
  8. SamboNZ

    SamboNZ n3wb

    Joined:
    Apr 30, 2016
    Messages:
    4
    Likes Received:
    4
    Thanks kyphos, that's a really great guide. I've added a reference to your post in my original post. Thanks for contributing!
     
  9. kyphos

    kyphos n3wb

    Joined:
    Aug 10, 2016
    Messages:
    14
    Likes Received:
    1
    This is a follow-up to my recipe posted here last week on how to configure a Mac as an SMB file server for camera-to-NAS recording. After having a 2032 camera in service for a few days (configured for motion-activated recording), I've encountered some significant problems.

    1) The timeline at the bottom of the Playback window often fails to indicate (with tiny red lines) that motion-activated video was captured. Many of the recordings that were captured are not revealed on the timeline. I've had instances where the timeline was completely blank (making it look like there was no activity overnight), when in fact a number of motion events had occurred (and video clips captured).

    2) More seriously, upon clicking the Play button, significant portions of the recorded video clips are missing. Typically, I find that the camera plays the first second or so (sometime less than a second) of the first clip, then abruptly jumps to the next clip. It plays a second or two of that clip, then jumps to next. Rinse and repeat. Sometimes, it will play a clip in its entirety (5 seconds or more, depending on the duration of the motion event). It seems to be random which clips get played in full, and which get truncated, but I'd say well over half of them are impacted.

    My first thought was that the problem was during recording: perhaps Mac mini too slow, its SMB implementation buggy, the FW400 hard drive not fast enough, etc. But subsequent investigation reveals that the entire video clip is getting recorded to the Mac's hard drive. The problem is with playback. At this point, I don't think this is due to the Mac-ness of my SMB file server, but rather due to bugs in the Hikvision firmware.

    Full details are here:
    https://www.ipcamtalk.com/showthread.php/13110-Does-Hikvision-really-support-SMB
     
  10. PattoLFC

    PattoLFC n3wb

    Joined:
    Dec 16, 2015
    Messages:
    6
    Likes Received:
    0
    Does anyone know if there is a fix for 5.3.0 firmware? This bug is so frustrating.
     
  11. anderson110

    anderson110 n3wb

    Joined:
    Nov 20, 2016
    Messages:
    17
    Likes Received:
    1
    Very helpful summary. I am trying to help a neighbor set up a low cost system and using existing hardware is a real cost cutter.
     
  12. jukemaster

    jukemaster n3wb

    Joined:
    Jan 4, 2017
    Messages:
    4
    Likes Received:
    0
    I don't even recall exactly when I purchased my US DS-2CD2042WD-I but I've been tinkering ever since. Many thanks to the above authors for taking the time to create a summary here and I especially liked the "since the information required to fix it was scattered across the entire Internet" part - I know this to be true.

    I've taken a different approach and connected an external drive to my ASUS AC66U and am attempting to use this as a dedicated NAS. I've yet to get it working correctly with the browser interface and I too experience the constant reverting to 'uninitialized'. Most likely because the spare hdd I put in the enclosure is 2TB (or 1 - I forget) but I refuse to believe this is the culprit.

    *I wanted to be able to shutdown my pc and have the device still record - which I did get to 'work' by using FTP but that only works for images so I had/have no video but figured if there ever was a reason to review all the images I would take time to sort through them all. Far from a solution long term but I have the camera aimed at the front of the house and driveway.

    Sambo's post pointed out that changes to the hdd drive/folders would cause the uninitialized error so I am in the process of reformatting now with FTP disabled. I did have FTP and hdd management assigned to two separate folders but I am willing to try anything at this point.

    I had the old drive sitting around and rather than invest in a actual NAS I figured this would save a few dollars - many actually.

    Everything was working beautifully with iSpy but again I wanted to save power costs and be able to shut machine off. If I come across an old pc my next attempt will be with zoneminder but thereto I don't care for the paying for the constant power - and from what I've gathered such software (iSpy, BlueIris, etc) is pretty demanding on the pc.

    One last note, I've yet to dial in my sensitivity settings on my FTP images but I seem to get many many more night images than I do day. Darn little nats set the thing off constantly - oh and I use filezilla to grab images from 'nas'.. the whole process is a pain.

    Thanks again and my $.02
     
  13. jukemaster

    jukemaster n3wb

    Joined:
    Jan 4, 2017
    Messages:
    4
    Likes Received:
    0
    Update - Well its a 2TB drive and took the trash out and came back to see my first ever little red lines indicating recording in the 'Playback' tab. Not sure how long it will last but PROGRESS!
     
  14. jukemaster

    jukemaster n3wb

    Joined:
    Jan 4, 2017
    Messages:
    4
    Likes Received:
    0
    D.i.d.n.t l.a.s.t l.o.n.g
     
  15. jukemaster

    jukemaster n3wb

    Joined:
    Jan 4, 2017
    Messages:
    4
    Likes Received:
    0
    And I decided to call HikVision USA - they were unable to retrieve my camera information after providing my serial number. Either I purchased a counterfeit camera from Amazon or more likely it was not from a 'authorized dealer'. This blew my mind as they wouldn't provide any more technical assistance and was told to search YouTube. I' remember making sure it was a USA camera but I'm guessing they tack on 'tech support' charges when selling to dealers who in turn price that in as well. Makes sense.

    Needless to say I'm back to FTP
     
  16. alastairstevenson

    alastairstevenson Staff Member

    Joined:
    Oct 28, 2014
    Messages:
    9,744
    Likes Received:
    2,865
    Location:
    Scotland
    I'm sure that will encourage you to strongly recommend the Hikvision brand to your friends, family and colleagues.
     
  17. Anders Gunnarsson

    Anders Gunnarsson n3wb

    Joined:
    Apr 30, 2018
    Messages:
    1
    Likes Received:
    0
    With reference to the unbendable rule 2 I realized today that creating a shared folder on my QNAP NAS with firmware 4.3.4 also means that a new snapshots folder is created inside the shared folder. To be able to format the shared folder from the NAS this snapshots folder must be deleted.
     
  18. kyphos

    kyphos n3wb

    Joined:
    Aug 10, 2016
    Messages:
    14
    Likes Received:
    1
    For those trying to use an SMB share to store video from Hikvision cameras, this thread is an oldie but a goodie.
    Two years ago, I posted my recipe for using an old Mac mini as an SMB server for a couple of Hik cameras. See post #7, above.
    The setup has been working fine for 2 years:)

    Last week, I was compelled to upgrade the OS on the Mac mini from Snow Leopard (10.6) to Lion (10.7.5). This was done so I could run another server-type application on the mini that required Lion or better (Indigo home automation). Lion is the last version of OSX that will run on my old-vintage Mac mini. So I bid farewell to Snow Leopard. The upgrade to Lion went smoothly. However, I soon discovered that the Hik cameras could no longer access the SMB shares hosted on Lion.

    A long discussion with Ms. Google ensued. I eventually learned that Apple dropped support for SMB v1 on Lion. They decided to implement their own (perhaps buggy) version of SMB v2. A query to Hikvision tech support revealed that their firmware doesn't support SMB v2.

    More discussions with Ms. Google followed. She found a vast number of posts from 2012-13 on the topic. Many new users of Lion found themselves high and dry without an SMB paddle. She also found a solution. An intrepid soul (I think in Spain) created an application to install an instance of Samba on Lion. It's called SMBUp, and you'll find it here:
    http://eduo.info/apps/smbup

    The implemention of Samba installed by this package still supports SMB v1. A helpful guide to installing/configuring it is here:
    Tweaking4All.com - Mac OS X SMB Fix, or How to install SMBUp
    This is also useful:
    Don Morris on SMB and Mac OS X Lion

    After following all the advice in these resources, my cameras still wouldn't connect. Fortunately, I discovered one additional detail that needed attention. The old version of SMB connects to port 139 ("NETBIOS session service"). The new version uses port 445 ("SMB over TCP"). The Hik cameras are hard-coded to use 139, and by default, SMBUp creates a config file that specifies port 445. It's easy to change - deep within the SMBUp "Advanced Server Configuration" page is a place where the port number is specified. I changed 445 to 139, and with that, the Hik cameras are back in service, recording video and stills to the SMB shares published by the Mac mini.
     
    alastairstevenson likes this.