Recently feel the use of mobile hard disk backup Mac computer is very inconvenient, because to take out the mobile hard disk, but also plug in the computer backup, looked at airport, but the price is too expensive, and can only be used for Mac backup and can not be used for other samba services, etc., feel less cost-effective, So I'm going to do a timemacheine and samba service, the Timemacheine service is used primarily for Mac backups, and samba is used to store some files on computers in the LAN.
Preparatory work:
Raspberry Pi
Mobile HDD
5V Power adapter and Cable
Wireless USB card or cable
SD Card (new version is TF card)
Operating system, about the operating system, you can go to the Raspberry official website to download and write through the Win32diskimager software.
Here my own device information is:
Raspberry Pi 2 Generation
West Digital mobile HDD 2TB self-powered
5V Power adapter and Cable
Wired Internet
SD Card 16GB Kingston
Raspbian Operating System
Operating system settings
To see if your mobile hard drive is loading, LSBLK results:
NAME maj:min RM SIZE RO TYPE mountpoint
SDA 8:0 0 1.8T 0 disk
|-SDA1 8:1 0 977.9G 0 part
'-sda2 8:2 0 885.1G 0 part
Mmcblk0 179:0 0 14.6G 0 disk
|-mmcblk0p1 179:1 0 56M 0 part/boot
'-mmcblk0p2 179:2 0 3G 0 Part/
Here I am dividing my hard drive into two partitions,/dev/sda1 NTFS format,/dev/sda2 for HFS format, if you need to partition can be partitioned by Fdisk and Cfdisk.
To format a partition:
Mkfs.ntfs-v "Samba"/dev/sda1 && mkfs.hfsplus-v "Timemacheine"/dev/sda2
To prepare the Mount directory for Timemacheine and samba:
Mkdir/srv/samba
Mkdir/srv/timemacheine
Samba Build
Install NTFS-3G, let raspberry support NTFS format
Apt-get Install ntfs-3g
Mount partitions to the specified directory
Mount-t Ntfs/dev/sda1/srv/samba
To see if the mount is successful, lsblk results:
NAME maj:min RM SIZE RO TYPE mountpoint
SDA 8:0 0 1.8T 0 disk
|-SDA1 8:1 0 977.9G 0 Part/src/samba (mounted successfully)
'-sda2 8:2 0 885.1G 0 part
Mmcblk0 179:0 0 14.6G 0 disk
|-mmcblk0p1 179:1 0 56M 0 part/boot
'-mmcblk0p2 179:2 0 3G 0 Part/
Installing Samba
Apt-get Install Samba Samba-common-bin
Modify the Samba configuration file
Vi/etc/samba/smb.conf
Adding shared configuration information
[BackupFolder] (Share name)
Comment = Backup Folder
Path =/srv/samba (path)
Valid users = @users
Force Group = Users
Create mask = 0660
Directory mask = 0771
Read Only = no
Add Samba Users
Useradd Backuser-m-G
USERSPASSWD Backuser
Smbpasswd-a Backuser
Restart Service
/etc/init.d/samba restart
TimeMachine Construction
Install the necessary software:
Apt-get Install Hfsplus hfsutils hfsprogs
Mount Directory:
Mount-t Hfsplus/dev/sda2/src/timemacheine
Modify the owning group, owner of the directory:
Chown-r Pi:pi/srv/timemacheine
To see if the mount is successful, lsblk results:
NAME maj:min RM SIZE RO TYPE mountpoint
SDA 8:0 0 1.8T 0 disk
|-SDA1 8:1 0 977.9G 0 Part/src/samba (mounted successfully)
'-sda2 8:2 0 885.1G 0 part/src/timemacheine (mounted successfully)
Mmcblk0 179:0 0 14.6G 0 disk
|-mmcblk0p1 179:1 0 56M 0 part/boot
'-mmcblk0p2 179:2 0 3G 0 Part/
Install Netatalk:
Netatalk is an open source AppleTalk communication protocol implementation, the Linux system can act as a Mac file server, AppleTalk routing, print server and so on.
Installation:
Apt-get Install Netatalk
Add the first set of directories to the configuration file:
echo "/srv/timemacheine \" timemacheine\ "Options:tm" >>/etc/netatalk/applevolumes.default
Or
Vi/etc/netatalk/applevolumes.default
Then add the/srv/timemacheine "Timemacheine" Options:tm to the last
The Samba server can also be set up here so that it can be accessed uniformly
Vi/etc/netatalk/applevolumes.default
Then add the/srv/samba "Samba" options:tm to the last
Installing Avahi-daemon and Libnss-mdns
Add the Avahi tool to allow Mac computers to discover disks in a Shared Finder toolbar
Apt-get Install Avahi-daemon Libnss-mdns
Configure the nsswitch.conf file to add MDNs after the original hosts row
Hosts:files mdns4_minimal [Notfound=return] DNS mdns4 MDNs
Let Avahi on LAN broadcast AFP share:
Vi/etc/avahi/services/afpd.service
Add the following content
<?xml version= "1.0″standalone= ' no '?>
<!-*-nxml-*->
<! 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= Xserve</txt-record>
</service>
</service-group>
Restart Avahi Service
/etc/init.d/avahi-daemon restart
Raspberry Pi Implementation Timemachin