格式化磁盤

因在 mac 下建立的 hfs+ 磁盤自帶 journal,需要手動掛載為可讀,為方便起見,在 linux 下格式化即可。

# yum -y install kmod-hfs kmod-hfsplus hfsplus-tools #添加組件
# mkfs.hfsplus -v TimeCapsule /dev/sda1 #建立 hfs+ 分區
# mount -t hfsplus -o force,rw /dev/sdc2 /mnt/sdc/
# lsblk -f

netatalk

# yum install -y netatalk
# yum install -y avahi #用於自動發現,也可以不配置
# vim /etc/netatalk/afp.conf
# vim /etc/nsswitch.conf
# systemctl enable avahi-daemon
# systemctl start avahi-daemon
# systemctl enable netatalk
# systemctl restart netatalk
# netstat -tulpn #檢查監聽肆否正常,完成後注意開放端口
tcp6       0      0 :::548                  :::                    LISTEN      7036/afpd

Conf

!/etc/netatalk/afp.conf

;
; Netatalk 3.x configuration file
;

[Global]
 mimic model = TimeCapsule6,106 #偽裝為基地台,可註釋
 log level = default:warn
 log file = /var/log/afpd.log
 hosts allow = 192.168.1.0/24 #允許訪問的主機
 hostname = TimeCapsule #主機名
 
[Homes]
 basedir regex = /home #列出登入用戶目錄,可註釋
 
[TimeMachine]
 path = /path/TimeMachine #數據目錄
 time machine = yes #支持 Time Machine
 spotlight = no #关闭 spotlight 索引
 rwlist = senra #指定可讀寫用戶,可註釋
 valid users = timemachine #允許用戶
 force user = senra #強制指定用戶

[Server-AFP] #用於數據訪問,實測在 macOS 下相比 smb, WevDAV 性能更好
 path = /path
 valid users = afp

!/etc/nsswitch.conf

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns