Skip to content

Instantly share code, notes, and snippets.

@gustavorv86
Last active July 11, 2023 08:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gustavorv86/8c6e19823b57b6784028bc36695c2a50 to your computer and use it in GitHub Desktop.
Save gustavorv86/8c6e19823b57b6784028bc36695c2a50 to your computer and use it in GitHub Desktop.
How to configure a low-cost NAS server for a Xiaomi MI Home Security Camera

Samba Server configuration for Xiaomi MI Home Security Camera

This manual explains how to set up a low-cost NAS server to store videos from a Xiaomi camera, model MI Security Camera.

You can use a development board Linux based such as Raspberry PI or similar, an old PC, Barebone etc.

NAS Server Configuration

Install samba.

apt install samba

Create a user without password.

useradd smbcamrec

Create a SMB password from the user.

smbpasswd -a smbcamrec

Recommend: Use an external USB or hard disk to store the videos.

Format the external storage device.

mkfs.ext4 /dev/sdXY

Edit fstab.

cp /etc/fstab /etc/fstab.bak
echo '/dev/sdXY /media/sdXY ext4 defaults 0 0' >> /etc/fstab

Check fstab and mount.

mount -a

Edit the /etc/samba/smb.conf configuration file with the smb.conf file below.

Check the configuration.

testparm

Make the mount directory and change propietary and group.

/media/sdXY/smb/smbcamrec/cam01
/media/sdXY/smb/smbcamrec/cam02
chown -R smbcamrec:smbcamrec /media/sdXY/smb/smbcamrec

Restart service.

systemctl restart smbd.service

Smartphone Configuration

Open the Xiaomi Home app in your smartphone and configure the NAS server.

NOTE: The camera and the samba server must be on the same LAN.

Optional: Mount the NAS shared folder in Linux

Install the cifs-utils package.

apt install cifs-utils

Mount the NAS shared folder (replace the NAS_SERVER_IP_ADDRESS).

mkdir -p /media/smb/smbcamrec
mount -t cifs -o user=smbcamrec //NAS_SERVER_IP_ADDRESS/smbcamrec /media/smb/smbcamrec

Enjoy! :)

[global]
workgroup = WORKGROUP
log file = /var/log/samba/log.%m
max log size = 1000
logging = file
panic action = /usr/share/samba/panic-action %d
server role = standalone server
obey pam restrictions = Yes
unix password sync = Yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
pam password change = Yes
map to guest = Bad User
usershare allow guests = Yes
client max protocol = NT1
client min protocol = NT1
server min protocol = NT1
ntlm auth = ntlmv1-permitted
idmap config * : backend = tdb
invalid users = root
[smbcamrec]
comment = Samba Camera Recorder
create mask = 0660
directory mask = 0770
valid users = smbcamrec
force user = smbcamrec
guest ok = Yes
path = /media/sda1/smb/smbcamrec
read only = No
[cam01]
comment = Camera 01
create mask = 0660
directory mask = 0770
valid users = smbcamrec
force user = smbcamrec
guest ok = Yes
path = /media/sda1/smb/smbcamrec/cam01
read only = No
[cam02]
comment = Camera 02
create mask = 0660
directory mask = 0770
valid users = smbcamrec
force user = smbcamrec
guest ok = Yes
path = /media/sda1/smb/smbcamrec/cam02
read only = No
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment