preface
Linux+Netatalk is an implementation for many home routers that provide Mac TimeMainche cloud backup. Raspberry PI 4 is the official system based on Debian Linux. The power of the Raspberry PI 4 lies in the new Typce C power supply (meaning the larger input current (officially 5V 2.5a) means it is possible to mount A removable hard drive without additional power supply); USB 3.0 + GIGABit network port means that data transmission bandwidth is no longer a bottleneck. After testing, after the completion of building Nas, the transmission of large files can basically reach 80M+ speed, this speed has basically been able to run the writing speed of ordinary mobile mechanical hard disk; In addition, since the owner of the building uses a 2.5-inch 2.0T removable hard disk, if you need to use a 3.5-inch removable hard disk, it may need additional DC 12 volt power supply;
reference
- Netatalk basic configuration documents
Raspbian Lite (no desktop)
1. Download Raspbian Buster Lite through your official connection
www.raspberrypi.org/downloads/r…
2. Burn images to TF cards using burn software. Etcher is recommended for MAC
Select your TF card and click Flash
3. Enable SSH, locate the IP address of the raspberry PI system through routes, and connect to raspberry PI over SSH
Generate an SSH file randomly on MAC, enable 777 permission and copy it to the boot directory of the tf card that has just been burned
sudo mkdir ssh
sudo chmod 777 ssh
Copy the code
Insert the TF card into the raspberry PI, connect the network cable and power supply, find the RASPberry PI IP through the router, connect through SSH, the initial official system account is PI, and the default password is Raspberry, remember to change the password after login.
SSH [email protected] (Enter the IP of raspberry PI)Copy the code
SSH connection to Raspberry PI is successful.
2. Install TimeMachine package, Netatalk, Avahi – Daemon
1. Update apt-get first
sudo apt-get update
Copy the code
2. Install required tools
Netatalk builds TimeMachine Server,avahi lets macBook automatically discover raspberry pie
sudo apt-get install netatalk avahi-daemon
Copy the code
Hfsprogs and HFSPlus are installed to enable Raspberry PI to read Mac formatted drives. If NSFS,ext3 and other formats are required, please query the required packages by yourself.
sudo apt-get install hfsprogs hfsplus
Copy the code
3. Create a user and mount disks automatically
Create a user to mount the TimeMachine disk without using the default account
useradd -c "Time machine" -m -s /bin/bash tm
Copy the code
Set a password for the user
sudo passwd tm
Copy the code
To prepare the folder to mount the hard drive, I have two sections, one for the regular Nas
mkdir /home/tm/TimeMachine
sudo chown -R tm /home/tm/TimeMachine
mkdir /home/tm/MacData
sudo chown -R tm /home/tm/MacData
Copy the code
Configure fstab to enable automatic disk mounting
sudo nano /etc/fstab
Copy the code
Add the following at the bottom of the file, depending on the number of partitions
UUID=7fc30fac-660e-303d-9778-6326602ff216 /home/tm/TimeMachine hfsplus force,rw,user,auto 0 0
UUID=ecb5d47d-f906-302b-8723-e840938d25e8 /home/tm/MacData hfsplus force,rw,user,auto 0 0
Copy the code
You can run the following command to query the partition UUID
ls -l /dev/disk/by-uuid
Copy the code
/dev/sda2,/dev/sda3,/dev/sda3,/dev/sda3
Start to mount the hard disk and do not need to mount it again.
sudo mount -a
Copy the code
As shown in the figure, two partitions have been mounted successfully (the specific number depends on the person)
4. Configuration Avahi Netatalk
To enable MAC to automatically discover Linux AFP services, you need to install avahi software and start the Avahi -daemon service
Configuration avahi config
sudo nano /etc/avahi/services/afpd.service
Copy the code
Copy the following and save it
<? The XML version = "1.0" standalone = 'no'? > <! DOCTYPE service-group SYSTEM "avahi-service.dtd"> <service-group> <name replace-wildcards="yes">%h</name> <service> <type>_afpovertcp._tcp</type> <port>548</port> </service> <service> <type>_device-info._tcp</type> <port>0</port> <txt-record>model=TimeCapsule</txt-record> </service> </service-group>Copy the code
Configuration netatalk
sudo nano /etc/netatalk/afp.conf
Copy the code
; ; Netatalk 3.x configuration file ; [Global] ; Global Server Settings Mimic model = TimeCapsule6,106 hosts allow = XXX.XXX.x.xx // Enter your IP address [MacData] path = /home/tm/MacData valid users = tm [TimeMachine] path = /home/tm/TimeMachine time machine = yes valid users = tm ; The following parameters are optional to limit the maximum available capacity of the Time machine, in MB. I have partitioned it, so I do not limit it. vol size limit = 1400000Copy the code
Start Avahi, Netatalk, and set the boot automatically
sudo service avahi-daemon start
sudo service netatalk start
systemctl enable avahi-daemon
systemctl enable netatalk
Copy the code
5. Connect the AFP server for nas and TimeMachine
Connecting to the Afp Server
Before connection, check whether user permissions are set on the mobile hard disk to allow all users to read and write. Otherwise, the mapped server may not be writable but only readable, which may also affect TimeMachine connection failure
Ensure that each partition is as shown in the figure above and everyone needs to be read & Write (default: read only).
Open Finder, and a Raspberry PI server should already appear in the Network column
Double-click raspberrypi and hit Connect As or Command + K
Enter AFP ://xxx.xx.xx.x Raspberry PI’s IP address
Enter your account and password to connect to the server
A successful connection to this home Nas server is successful.
Connection TimeMachine
System preferences ->Time Machine, and then Select the drive as Time Machine backup. If no hard Disk is available, click Select Disk to start backup
Time Machine will run the first backup, followed by hourly backups if the macbook is plugged in. (Tips: It is better to connect the macbook to the Internet and use the same gigabit switch as the Raspberry PI, otherwise use wifi or cable through the router, if the router is too bad, it may drag down the Internet speed at home)