├── LICENSE └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Bruno Tavares 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Apple Time machine on RaspberryPI 2 | 3 | The following step are the ones that enable Time Machine backups with Raspberry Pi plus a bit of polishing to my taste. 4 | 5 | ## 1. Format the hard drive 6 | I had a hard-drive serving as Time Machine disk. However, I couldn't mount the disk due to Apple Core Storage: 7 | 8 | ``` 9 | Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors 10 | Units: sectors of 1 * 512 = 512 bytes 11 | Sector size (logical/physical): 512 bytes / 512 bytes 12 | I/O size (minimum/optimal): 512 bytes / 512 bytes 13 | Disklabel type: gpt 14 | Disk identifier: DE07BD84-C4E1-4229-81CD-E146E04D46C6 15 | 16 | Device Start End Sectors Size Type 17 | /dev/sda1 40 409639 409600 200M EFI System 18 | /dev/sda2 409640 975539735 975130096 465G Apple Core storage 19 | /dev/sda3 975539736 975801879 262144 128M Apple boot 20 | /dev/sda4 975802368 1953523711 977721344 466.2G Microsoft basic data 21 | ``` 22 | 23 | StackOverflow thread [mounting hfs partition on arch linux](https://superuser.com/questions/961401/mounting-hfs-partition-on-arch-linux/1088110#1088110) didn't work for me. Since the backups on that disk were a bit outdated I decided to format the partition and give it a go. Another alternative would be to use Disk Utility to get rid of Apple Core Storage but in my case not worth the effort. 24 | 25 | So, format the HD on your Mac using Disk Utility. Settings used: 26 | * Name: `Time Machine` 27 | * Format: `Mac OS Extended (Journaled)` 28 | * Scheme: `GUID Partition Map` 29 | 30 | ## 2. Ensure Pi has permissions to control the drive 31 | Go to the Finder, then right-click the drive in the sidebar. Click “Get Info”. 32 | 33 | Click the lock at bottom right, then enter your password. Next, check `Ignore ownership on this volume.` and give `Read & Write`permissions to `everyone`. 34 | 35 | Linux cannot write data into `journaled hfs+` file system, so you also need to disable that: 36 | 37 | ``` 38 | diskutil list 39 | ``` 40 | 41 | Then find your drive and partition identifier (like: disk\*s\*), and run: 42 | 43 | ``` 44 | diskutil disableJournal /dev/disk*s* 45 | ``` 46 | 47 | Dont forget to replace the asterisks. You'll see: 48 | 49 | ``` 50 | Journaling has been disabled for volume MyTimeMachine on disk*s* 51 | ``` 52 | 53 | ## 3. Install tools for Apple-formatted drives 54 | Go to Pi (ssh'ed it!) and run: 55 | ``` 56 | $ sudo apt-get update 57 | $ sudo apt-get upgrade 58 | $ sudo apt-get --assume-yes install hfsprogs hfsplus 59 | ``` 60 | 61 | ## 4. Mount the drive 62 | 63 | #### Find the drive: 64 | 65 | ``` 66 | $ sudo fdisk -l 67 | 68 | ... 69 | 70 | Device Boot Start End Sectors Size Id Type 71 | /dev/mmcblk0p1 8192 3292968 3284777 1.6G e W95 FAT16 (LBA) 72 | /dev/mmcblk0p2 3292969 62333951 59040983 28.2G 5 Extended 73 | /dev/mmcblk0p5 3293184 3358717 65534 32M 83 Linux 74 | /dev/mmcblk0p6 3358720 3500031 141312 69M c W95 FAT32 (LBA) 75 | /dev/mmcblk0p7 3506176 62333951 58827776 28.1G 83 Linux 76 | 77 | 78 | Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors 79 | Units: sectors of 1 * 512 = 512 bytes 80 | Sector size (logical/physical): 512 bytes / 512 bytes 81 | I/O size (minimum/optimal): 512 bytes / 512 bytes 82 | Disklabel type: gpt 83 | Disk identifier: DE07BD84-C4E1-4229-81CD-E146E04D46C6 84 | 85 | Device Start End Sectors Size Type 86 | /dev/sda1 40 409639 409600 200M EFI System 87 | /dev/sda2 409640 975539735 975130096 465G Apple HFS/HFS+ 88 | /dev/sda3 975802368 1953523711 977721344 466.2G Microsoft basic data 89 | ``` 90 | 91 | In my case my HD is connected to USB and the device is `/dev/sda2`. A good hint is the fs type `Apple HFS/HFS+` or on other tools `hfsx`. 92 | 93 | #### Create your mounting point: 94 | 95 | ``` 96 | $ sudo mkdir -p /media/time_machine 97 | ``` 98 | 99 | #### Check if Pi already auto-mounted your drive: 100 | 101 | ``` 102 | $ sudo mount 103 | ``` 104 | 105 | If it's mounted, you need to un-mount it or give it write permissions. In my case I didn't want to have it mounted on `/media/pi/Time\ Machine` so I un-mounted it: 106 | 107 | ``` 108 | $ sudo umount /dev/sda2 109 | ``` 110 | 111 | #### Mount drive using your editor of choice: 112 | 113 | ``` 114 | $ sudo nano /etc/fstab 115 | ``` 116 | 117 | Add to the end of the file: 118 | 119 | ``` 120 | /dev/sda2 /media/time_machine hfsplus force,rw,user,noauto,x-systemd.automount 0 0 121 | ``` 122 | 123 | Mount the drive 124 | 125 | ``` 126 | $ sudo mount -a 127 | ``` 128 | 129 | Check if it's mounted by finding the line like the bellow: 130 | 131 | ``` 132 | $ sudo mount 133 | ... 134 | /dev/sda2 on /media/time_machine type hfsplus (rw,nosuid,nodev,noexec,relatime,umask=22,uid=0,gid=0,nls=utf8,user) 135 | ``` 136 | 137 | #### Install Netatalk 138 | Netatalk simulates AFP, the network protocol Apple currently users for Time Machine backups. 139 | 140 | Install dependencies 141 | 142 | ``` 143 | sudo aptitude install build-essential libevent-dev libssl-dev libgcrypt11-dev libkrb5-dev libpam0g-dev libwrap0-dev libdb-dev libtdb-dev avahi-daemon libavahi-client-dev libacl1-dev libldap2-dev libcrack2-dev systemtap-sdt-dev libdbus-1-dev libdbus-glib-1-dev libglib2.0-dev libio-socket-inet6-perl tracker libtracker-sparql-1.0-dev libtracker-miner-1.0-dev 144 | ``` 145 | 146 | Install Netatalk via apt-get 147 | 148 | ``` 149 | apt-get install netatalk 150 | ``` 151 | ``` 152 | whereis netatalk 153 | ``` 154 | 155 | ## 6. Configure Netatalk 156 | 157 | First let's set up `nsswitch.conf` by adding to the end of `hosts: files mdns4_minimal [NOTFOUND=return] dns` line ` mdns4 mdns`. 158 | 159 | ``` 160 | $ sudo nano /etc/nsswitch.conf 161 | ``` 162 | 163 | It should look like this: 164 | 165 | ``` 166 | # /etc/nsswitch.conf 167 | # 168 | # Example configuration of GNU Name Service Switch functionality. 169 | # If you have the `glibc-doc-reference' and `info' packages installed, try: 170 | # `info libc "Name Service Switch"' for information about this file. 171 | 172 | passwd: compat 173 | group: compat 174 | shadow: compat 175 | gshadow: files 176 | 177 | hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns 178 | networks: files 179 | 180 | protocols: db files 181 | services: db files 182 | ethers: db files 183 | rpc: db files 184 | 185 | netgroup: nis 186 | ``` 187 | 188 | This means your Time Machine drive will show up in Finder’s sidebar. 189 | 190 | Next set up `afp.conf` 191 | 192 | ``` 193 | $ sudo nano /usr/local/etc/afp.conf 194 | ``` 195 | 196 | add to the end 197 | 198 | ``` 199 | [Global] 200 | mimic model = TimeCapsule6,106 201 | 202 | [Time Machine] 203 | path = /media/time_machine 204 | time machine = yes 205 | ``` 206 | 207 | At last set `AppleVolumes.default` (might not be necessary)! I did it anyway... 208 | 209 | ``` 210 | $ sudo nano /etc/netatalk/AppleVolumes.default 211 | ``` 212 | 213 | and add to the end of the file 214 | 215 | ``` 216 | /media/time_machine "Time Machine" options:tm 217 | ``` 218 | 219 | ## 7. Launch network services 220 | ``` 221 | $ sudo service avahi-daemon start 222 | $ sudo service netatalk start 223 | ``` 224 | 225 | ``` 226 | $ sudo systemctl enable avahi-daemon 227 | $ sudo systemctl enable netatalk 228 | ``` 229 | 230 | ## 8. Give your Pi a static IP 231 | Go to your router and assign a static IP to your Pi. 232 | 233 | ## 9. Connect to time machine 234 | Go to your Mac Finder you should see your Raspberry Pi there. 235 | Click on `Connect as` and insert your credentials (user: timemachine). If doesn't work, connect to your Pi through its static IP. Open Finder, then hit Command+K on your keyboard and insert: 236 | ``` 237 | afp:// 238 | ``` 239 | 240 | ## 10. Configure your Mac Time Machine 241 | Go to `System Preferences > Time Machine` and clik on `Select Disk...`. Your Pi should show on the list. Select and use the settings that work best. 242 | 243 | ## Notice 244 | 245 | - Make sure that `erveryone` has permissions to read & write your disk drive. 246 | 247 | - If `aptitude install ...` at the last of step 5 shows an eror like `Package 'libmysqlclient-dev' has no installation candidate`, please try `default-libmysqlclient-dev`. 248 | 249 | ## Reference Articles 250 | * [How to make a Mac Time Capsule with the Raspberry Pi](http://www.techradar.com/how-to/computing/how-to-make-a-mac-time-capsule-with-the-raspberry-pi-1319989) 251 | * [How to Use a Raspberry Pi as a Networked Time Machine Drive For Your Mac](https://www.howtogeek.com/276468/how-to-use-a-raspberry-pi-as-a-networked-time-machine-drive-for-your-mac/) 252 | * [Use rPi as a Time Capsule - another method](https://www.raspberrypi.org/forums/viewtopic.php?f=36&t=47029) 253 | * [Mounting HFS+ drive (OS X Journaled)](https://www.raspberrypi.org/forums/viewtopic.php?t=18003) 254 | * [Mounting HFS+ partition on Arch Linux](https://superuser.com/questions/961401/mounting-hfs-partition-on-arch-linux/1088110#1088110) 255 | * [Time Machine on Raspberry Pi](http://lanjanitor.blogspot.co.uk/2013/12/time-machine-on-raspberry-pi.html) 256 | * [Time Capsule / Time Machine through Raspberry Pi](https://www.bersling.com/2017/01/02/time-capsule-time-machine-through-raspberry-pi/) 257 | * [DIY Time Capsule with a Raspberry Pi](http://www.calebwoods.com/2015/04/06/diy-time-capsule-raspberry-pi/) 258 | * [fstab - ArchWiki](https://wiki.archlinux.org/index.php/Fstab#Automount_with_systemd) 259 | --------------------------------------------------------------------------------