Hikvision value IP cameras (such as the IPC-B120, IPC-B121H, and IPC-B120-D-W) feature onboard motion detection, infrared night vision, and H.265+ compression, but lack internal hard drives. Rather than purchasing an expensive commercial NVR, you can attach an external USB hard disk to a Raspberry Pi configured as an SMB/CIFS Network Attached Storage (NAS) target for continuous or motion-triggered video archiving.
1. Installing and Configuring Samba on the Raspberry Pi
sudo apt-get update
sudo apt-get install samba samba-common-bin -y
# Create recording directory on mounted external drive
sudo mkdir -p /media/cctv_storage/hikvision
sudo chown -R nobody:nogroup /media/cctv_storage/hikvision
sudo chmod -R 0777 /media/cctv_storage/hikvision
2. Samba Share Definition (/etc/samba/smb.conf)
Hikvision firmware requires specific Samba dialect and locking settings to format network drives successfully:
[hikvision]
comment = Hikvision CCTV Storage
path = /media/cctv_storage/hikvision
browseable = yes
writeable = yes
guest ok = yes
read only = no
create mask = 0777
directory mask = 0777
force user = nobody
Restart Samba:
sudo systemctl restart smbd
3. Mounting the Drive in Hikvision Web GUI
- Log into your camera's web interface → Configuration → Storage → Storage Management → Net HDD.
- Set Type to NAS / SMB/CIFS, enter the Raspberry Pi's IP address, set File Path to
/hikvision, and save. - Under HDD Management, select the newly added network disk and click Format / Init. Once status changes to Normal, motion recordings will save directly to your Pi.