Nhà thông minh
Geek Playground
  • Welcome to my HomeLAB
    • Script: Thiết lập toàn bộ dịch vụ smarthome cơ bản
    • Script: Thiết lập các dịch vụ để làm media server
    • Script: Thiết lập dịch vụ theo dõi và tự động hoá
    • Docker Compose Template - Manual Setup
  • Kiến thức nền tảng - Cần biết trước khi bắt đầu
    • Bảng thống kê chi phí đầu tư thiết bị phục vụ SmartHome
    • Các phương án chơi nhà thông minh tính tới hiện tại
  • Cài đặt (Install)
    • Cài đặt HomeBridge - Đưa thiết bị lên HomeKit
    • Một HUB kết nối được toàn bộ thiết bị Zigbee của tất cả các hãng
    • Apple HomeKit - Cho thiết bị không hỗ trợ
      • Scrypted - Đưa camera lên Apple HomeKit
      • Đưa samsungTV lên Apple Home
      • Mở cửa cuốn bằng eWeLink (SonOFF) 4CH Pro
    • DIY thiết bị hỗ trợ Apple HomeKit
      • Cảm biến hiện diện bằng bất cứ thiết bị bluetooth nào (đồng hồ, xe hơi...)
      • Cảm biến hiện diện chia theo khu vực
      • Biến quạt thường thành quạt thông minh full chức năng
      • Hướng dẫn làm bộ điều khiển máy lạnh thông minh hoạt động trên Apple HomeKit và có tính năng phản hồ
  • Những dự án thú vị với HomeLAB
    • Hệ thống giải trí, xem phim tại nhà miễn phí
      • Tự động tìm kiếm phim ảnh và subtitle có trên internet
      • Tự động tải về phim yêu thích
      • Cài đặt Plex Media Server
    • Thiết lập hệ thống dashboard (theo dõi hiệu năng, tiền điện, cảm biến)
      • Hiển thị dữ liệu lên Grafana với Prometheus và InfluxDB
      • Tự động thu thập dữ liệu từ cảm biến thông qua NodeRED
      • Theo dõi sử dụng mạng
        • Sử dụng Window/MacOS/Linux
      • Theo dõi tiền điện
        • Thực tế sử dụng điện của một số thiết bị vận hành 24/7
    • Chia sẻ file trong mạng LAN, backup dữ liệu
      • Chia sẻ file trong mạng LAN - Hệ thống NAS nhà làm
      • Backup toàn bộ hệ điều hành trên Cloud, phòng trường hợp lỗi thẻ nhớ
    • Làm đẹp - trang trí không gian làm việc, giải trí
      • Cấu hình Ambilight LED cho TV, gia tăng trải nghiệm xem
      • Cài server chạy Ambilight
  • Pro Tips
    • Các lỗi thường gặp và cách xử lý
      • Sub directory not working
      • Adguard Home: Sửa lỗi fail to bind on port 53
    • Frequently used command
      • Thao tác với Caddy Proxy
      • Thao tác với ổ cứng
      • Thao tác với Docker
    • Pin thủ nhào vào đây
      • Biến sạc thường thành sạc nhanh PD
      • Tự làm bộ sạc nhiều cổng hỗ trợ PD siêu rẻ, có thể gắn lên xe máy & oto để sạc nhanh
      • Tận dụng pin cũ của điện thoại
    • Use memory card as RAM
    • Xử lý phân quyền trên linux
      • Tự động phân quyền trên linux
Powered by GitBook
On this page
  • Tạo NAS server với Samba
  • Cấu hình theo mẫu như sau ở dưới cùng của file smb
  • Thiết lập để SAMBA đọc được thiết bị
  • Allow the Raspberry Pi to read and interpret exFAT drives
  • Mounting the Drive to the Raspberry Pi
  • Cấp riêng quyền đọc ghi cho pi trong folder bất kỳ
  • Kiểm tra phân quyền
  • Thêm user vào nhóm đã được phân quyền
  • Thêm user khác
  • Tạo mật khẩu cho user SMB
  • Setup mount ổ đĩa tự động
  • Cài đặt NAS để có thể backup được time machine
  • Reload lại samba
  • Configuring Avahi deamon
  • Restart Avahi daemon:
  • Automated start of the services

Was this helpful?

Edit on GitHub
  1. Những dự án thú vị với HomeLAB
  2. Chia sẻ file trong mạng LAN, backup dữ liệu

Chia sẻ file trong mạng LAN - Hệ thống NAS nhà làm

Tạo NAS server với Samba

$ sudo apt install samba samba-common-bin -y

$ sudo nano /etc/samba/smb.conf

Cấu hình theo mẫu như sau ở dưới cùng của file smb

Nhớ chỉnh path đúng thực tế

[NAS]
path = /mnt/sda1
writeable = yes
guest ok = yes
create mask = 0777
directory mask = 0777
NASpath = /mnt/sda1

$ sudo /etc/init.d/smbd restart

Thiết lập để SAMBA đọc được thiết bị

Allow the Raspberry Pi to read and interpret exFAT drives

sudo apt install exfat-fuse | sudo apt install exfat-utils -ys

Nếu không setup theo định dạng này thì bỏ qua để không làm giảm tốc độ đọc

Mounting the Drive to the Raspberry Pi

  • Kiểm tra danh sách ổ đĩa: $ lsblk -f or lsblk

  • Format disk (Optional): sudo mkfs -t ext4 /dev/sdb1

  • Tạo điểm mount: $ sudo mkdir -p /mnt/sda1

  • Mount: $ sudo mount /dev/sda1 /mnt/sda1

  • Cấp quyền: $ sudo chown -R pi:pi /mnt/sda1

Cấp riêng quyền đọc ghi cho pi trong folder bất kỳ

$ sudo chown -R pi:pi /mnt/sda1

Kiểm tra phân quyền

$ ls -l /mnt/sda1

Thêm user vào nhóm đã được phân quyền

$ sudo usermod -aG pi leolion

Thêm user khác

$ sudo useradd leolion

Tạo mật khẩu cho user SMB

$ sudo smbpasswd -a leolion

Setup mount ổ đĩa tự động

$ sudo nano /etc/fstab

UUID=a63e1694-79fe-4d7d-9e69-a9d4f67ce28a /mnt/sda1 ext4 defaults,auto,users,rw,nofail,noatime 0 0
UUID=03055c59-3346-451a-be85-7ac95c4ae633 /mnt/sda2 ext4 defaults,auto,users,rw,nofail,noatime 0 0
UUID=586a5114-39ee-4aae-bc0a-30b6ae315949 /mnt/sda3 ext4 defaults,auto,users,rw,nofail,noatime 0 0
UUID=fba61038-e998-4254-b795-519716f393d4 /mnt/sda4 ext4 defaults,auto,users,rw,nofail,noatime 0 0

Lấy mã UUID theo thông tin trả về trong câu lệnh: lsblk -f

Cài đặt NAS để có thể backup được time machine

sudo apt-get install samba avahi-daemon

Cần bổ sung cấu hình file samba để support định dạng time machine hiểu được

sudo nano /etc/samba/smb.conf

[Backup]
path = /mnt/sda4
fruit:time machine = yes
vfs objects = catia fruit streams_xattr
writeable = yes
guest ok = yes
create mask = 0777
directory mask = 0777

Reload lại samba

sudo service smbd reload

Configuring Avahi deamon

In order to let MacOS automatically detect our new Time Machine we’ll need to configure Avahi. For that edit the following file:

sudo nano /etc/avahi/services/samba.service

And paste this configuration in:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">%h</name>
  <service>
    <type>_smb._tcp</type>
    <port>445</port>
  </service>
  <service>
    <type>_device-info._tcp</type>
    <port>9</port>
    <txt-record>model=TimeCapsule8,119</txt-record>
  </service>
  <service>
    <type>_adisk._tcp</type>
    <port>9</port>
    <txt-record>dk0=adVN=backups,adVF=0x82</txt-record>
    <txt-record>sys=adVF=0x100</txt-record>
  </service>
</service-group>

With this we tell MacOS that in fact our Raspberry Pi is a 8th Gen Time Capsule and it will appear like one in the sidebar in Finder.

Restart Avahi daemon:

sudo service avahi-daemon restart

Automated start of the services

We need to edit crontab with:

sudo crontab -e

We’ll mount the USB drive and start the needed services on a boot/reboot:

@reboot sleep 30 && mount /mnt/sda4 && sleep 30 && umount /mnt/sda4 && sleep 30 && mount /mnt/sda4 && sleep 30 && service avahi-daemon start && service smbd start
PreviousChia sẻ file trong mạng LAN, backup dữ liệuNextBackup toàn bộ hệ điều hành trên Cloud, phòng trường hợp lỗi thẻ nhớ

Last updated 7 months ago

Was this helpful?