Transformer le Raspberry Pi en Time Machine

Warning : This article has been automatically translated by Google Translate

For those who have a Mac, you know Time Machine which allows to make incremental backups of your system to a hard drive or a Time Capsule. Nous allons voir comment transformer notre Raspberry Pi Home Server en une Time Capsule.

Transformer le Raspberry Pi en Time Machine

In l' article by preparing the hard disk We created an HFS partition. This is the format that should be used to back up your data from the Mac. We will see how to prepare and how to connect the Mac to the Raspberry POI.

  1. Install the avahi if service is not already (see l’article about AirPlay)
    apt-get install avahi-daemon libavahi-client-dev libdb5.3-dev db-util db5.3-util libgcrypt11 libgcrypt11-dev
  2. Download Netatalk 3.0 (with wget for example). At the writing of this article,It seems that the version 3.1 does not work
  3. Start the configuration, the compilation and installation
    cd netatalk-3.0  ./configure --with-init-style=debian --with-zeroconf  make  make install
  4. Install the packages containing tools for HFS partitions
    apt - get install hfsplus hfsutils hfsprogs
  5. Create the HFS partition
  6. Disable the journaling on the HFS partition, if not recording Time Machine won't work (and the disc will not be found)
    1. Go to the home
    2. Create a disable.c file copying the following content

      [code lang =”c”]#include ≪stdio.h>

      #include ≪STDLIB.h>

      #include ≪unistd.h>

      #include ≪sys/types.h>

      #include ≪sys/mman.h>

      #include ≪Fcntl.h>

      #include ≪byteswap.h>

      int main(int argc, char * argv[])


      int fd = open(argv[1], O_RDWR);

      if(FD ≪ 0) {


      return -1;


      unsigned char *buffer = (unsigned char *)mmap(NULL, 2048, PROT_READ|PROT_WRITE, MAP_SHARED, FD, 0);

      if(buffer == (unsigned char*)0xffffffff) {


      return -1;


      if((buffer[1024] != ‘H’) && (buffer[1025] != ‘ ’)) {

      fprintf(stderr, "%s: HFS signature not found — aborting.n", argv[0]);

      return -1;


      unsigned long attributes = *(unsigned long *)(&buffer[1028]);

      attributes = bswap_32(attributes);

      printf("attributes = 0x%8.8lxn", attributes);

      if(!(attributes & 0x00002000)) {

      printf("kHFSVolumeJournaledBit not currently set in the volume attributes field.n");


      attributes &= 0xffffdfff;

      attributes = bswap_32(attributes);

      *(unsigned long *)(&buffer[1028]) = attributes;

      buffer[1032] = ‘1’;

      buffer[1033] = ‘0’;

      buffer[1034] = ‘.’;

      buffer[1035] = ‘0’;

      buffer[1036] = 0;

      buffer[1037] = 0;

      buffer[1038] = 0;

      buffer[1039] = 0;

      printf("journal has been disabled.n");

      return 0;


    3. Compile the program
      GCC disable.c
    4. Disable the log
  7. Create a user TimeMachine. Memorize the password you are going to choose will be asked under Time Machine to access the disk
    adduser timemachine
  8. Create the mount point for the partition
  9. Change the rights of the mount point with the user and the group created in step 7
    chown timemachine:TimeMachine/media/usbdrive/timemachine
  10. Mount the partition /dev/sda1 with the user TimeMachine read/write. Add the following line to /etc/fstab
/dev/sda1/media/usbdrive/timemachine hfsplus force,rw,UID = timemachine,GID = timemachine   0       0
  • You can test the functioning of the Assembly

    The mount command should display you the following line (as a result of other mount points)

    /dev/sda1 on/media/usbdrive/timemachine type hfsplus (rw,relatime,umask = 22, uid = 1001 gid = 1002, nls = utf8)
  • At this stage, the drive is ready. It remains to make it available on the network. For this, We begin by configuring netatalk. Edit the file /usr/local/etc/AFP.conf to define where the directory for Time Machine
    UAM list =,,,
    [Time Machine Raspberry]
    path =/media/usbdrive/timemachine time machine = yes
  • Create the file /etc/avahi/services/afpovertcp.service. Raspberry Pi will appear with the icon of a Mac server.
    <?XML version ="1.0" standalone = 'no'?><!--*-nxml-*->
    <!DOCTYPE service-group SYSTEM "avahi - service.dtd">
    <group service>
      <name wildcards replace ="Yes">%h</name>
        <type>_device - info._tcp</type>
        <TXT-record>model = Xserve</TXT-record>
    </group service>
  • Restarting the services Netatalk and avahi
    update-rc.d netatalk defaults service netatalk restart service avahi-daemon restart
  • Now in the finder, You should see your Raspberry Pi

    Raspberry Pi in the Finder

    Raspberry Pi in the Finder

  • Open Time Machine preferences, Select the disk

    Choice of the Time Machine drive

    Choice of the Time Machine drive

  • Enter the user TimeMachine and password

    Input of user and password for Time Machine

    Input of user and password for Time Machine

  • And this is, the backup is in progress !

    Backup Time Machine current

    Backup Time Machine current

Voilà. A nice Time Capsule, certainly without the Nice logo Apple but not at the price of Apple nor ! 😉

You may also like...