# AFP File Server with Netatalk3 in Jail on ZFS



## marcel (Mar 5, 2014)

Hello FreeBSD community,

It would like to have my own server at home, so that I have the full control over it and to figure out how servers are working. Because of that I started my first server project with the advise to use FreeBSD. It was a good decision because of the advantages like ZFS and jails. My port installation was PlexMediaServer. It was easy and worked immediately. I went on and wanted to have a file server where I can store files and do TimeMachine backups on it. The web said that Netatalk is the solution for this problem. But I didn't find a tutorial for FreeBSD which fixed it.

To my issue: my Macbook does not find the server.
What I am looking for: a How-to for Netatalk3 on FreeBSD which explains the steps detailed.

What I tried yet: (all in jail)

```
cd /usr/ports/net/netatalk3
make install
```
Here is where my problem starts. The window pops up and I don't know where I have to make my [X] correctly. But I cannot find any tutorial. I used this configuration files from http://winkenschuerfel.de/freebsd-zfs-netatalk/. It didn't work.

I hope you can help me. If you can, thank you very much. Otherwise thanks for reading!


----------



## acheron (Mar 6, 2014)

Hi,

I haven't tried to to this on a jail but it should works fine.
I have kept the default options for net/netatalk3.

Make sure your network configuration is correctly configured on both side (client and server).

This is the content of /usr/local/etc/afp.conf on my machine:

```
[Global]
        ; see /System/Library/CoreServices/CoreTypes.bundle/Contents/Info.plist 
        ; search for TimeCapsule6
        mimic model = TimeCapsule6,116

        ; You can remove these 2 lines when your setup is working
        log level = default:warn
        log file = /var/log/afpd.log

; Uncomment these 2 lines if you want to share your home directory
;[Homes]
;       basedir regex = /home

; Make sure /usr/stuff/afp_share and /usr/stuff/timemachine exists and your user have read/write/execute access on it
[My AFP Volume]
        path = /usr/stuff/afp_share

[TimeMachine]
        path = /usr/stuff/timemachine
        time machine = yes
```

Don't forget to launch `afpd`: `service netatalk start`

The TimeMachine share can now be used to backup your Mac.


----------



## zitlo (Apr 26, 2018)

Hello,

This is an older post, do someone have a working timachine afp.conf?

My configuration is not working with present OSX + FreeBSD 11.1-RELEASE-p9
I'm using an iocage jail + ZFS dataset
Read, write + execute permissions are fine.
Time Machine starts to backup, but it fails and I can't restart it because I get "volume in use" error in TimeMachine


```
[Global]
hostname = data
vol preset = default_for_all_vol
log level = default:warn
log file = /var/log/netatalk.log
afp listen = 192.168.182.5
mimic model = TimeCapsule6,116
zeroconf = yes
uam list = uams_dhx.so uams_dhx2.so

[default_for_all_vol]
cnid scheme = dbd
ea = ad

[documents]
path = /zroot/data/Documents
valid users = example

[media]
path = /zroot/data/media
valid users = example

[TimeMachine]
path = /zroot/data/tm
time machine = yes
```

I followed this examples:
https://dan.langille.org/2017/04/19/creating-an-apple-time-capsule-using-freebsd/
https://blog.rotzoll.net/2017/05/freebsd-nas-als-apple-timemachine-fuer-backups-nutzen/
https://www.davd.eu/posts-freebsd-time-machine-backup-server-with-netatalk/


----------



## Bobi B. (Apr 26, 2018)

I'm running this at home (FreeBSD 11.1, ZFS, afp + timemachine) and here are my notes on how I did it. However I'm using an older Mac mini and I'm two Mac OS X versions behind.

Did Time Machine succeeded to create any files in /zroot/data/tm?


----------



## zitlo (Apr 26, 2018)

thank you, I will try it.
yes

everyone is using "TimeMachine" as user, is that obkigatory? maybe thats my mistake.


----------



## pming (Apr 26, 2018)

zitlo said:


> everyone is using "TimeMachine" as user, is that obkigatory? maybe thats my mistake.



No, you can use whichever user you like. It just needs to exist on the system, have the correct access rights and Netatalk must be configured to give that user access to the Time Machine share.


----------



## zitlo (Apr 26, 2018)

Hey pming, thank you.
Access rights are correct, because time machine starts to backup and interrupts then. So maybe it's a network issue or something else.


----------



## pming (Apr 28, 2018)

I'm not sure about some of your configuration values. Especially about "cnid scheme" and "ea". Maybe you just need to restart the service. Maybe you want to try to delete your backup file and start a new backup.
Also, maybe you need to do the following:
`zfs set aclinherit=passthrough zroot/data/tm` and
`zfs set alcmode=passthrough zroot/data/tm`
It's written in the official Netatalk documentation for when ZFS is used.

Here is an excerpt from my configuration (that's working for me at least):

```
[Global]
; Global server settings
  hostname = server
  mimic model = Xserve
  zeroconf = yes
  uam list = uams_dhx2.so
  map acls = mode
  ea = auto
  unix priv = yes

  log file = /var/log/afpd.log

[Backup]
  path = /pudge/share/backup
  time machine = yes
  valid users = @admin, @sharing
  rwlist = @admin, @sharing
```


----------



## zitlo (Apr 30, 2018)

Hello pming,

thank you for your help.

The first backup is finished, when I try to do the next one I every time get the error "cant find backup volume" or sometimes "backup volume is in use", then I restart nettalk and everything is working fine until I start the next backup. I will try your configuration.

I will try to get debug logs of both machines.


----------



## pming (Apr 30, 2018)

Which macOS are you using? I am using 10.13.4.
I just got the same error. Kind of funny. I have been using this without any problems for almost 2 years.
This is the first time though, I'm not sure if the issue will remain.


----------



## zitlo (May 2, 2018)

Im using macOS 10.13.4 and still have the problem. When I restart nettalk everything is fine util the next backup begins.


----------



## pming (May 3, 2018)

I recently changed my configuration to use "server.domain.tld" as the hostname. Then I had the issue too. When I switched back to use just "hostname = server", the issue went away. Also have a look at the Netatalk logs, which are at /var/log/afpd.log, if you configured Netatalk like that. I think there is also a setting to increase verbosity of the logs to be able to dig deeper. Maybe you also want to try not running Netatalk in a jail, I could imagine that leading to problems.

Greetings, Philipp


----------



## gkontos (Aug 10, 2018)

Hi guys, sorry for resurrecting this again! I have been trying all day to set up a similar setup. After putting netatalk in debug mode I get the following error:


```
Aug 10 15:05:14.598862 afpd[4512] {netatalk_conf.c:1557} (debug:AFPDaemon): load_volumes: loading: /usr/local/etc/afp.conf
Aug 10 15:05:14.598958 afpd[4512] {netatalk_conf.c:1138} (debug:AFPDaemon): readvolfile: BEGIN
Aug 10 15:05:14.598990 afpd[4512] {netatalk_conf.c:1141} (debug:AFPDaemon): readvolfile: sections: 3
Aug 10 15:05:14.599043 afpd[4512] {netatalk_conf.c:1145} (debug:AFPDaemon): readvolfile: default_preset: default_for_all_vol
Aug 10 15:05:14.599113 afpd[4512] {unix.c:444} (debug:AFPDaemon): realpath() cannot resolve path "/datastore/macbook"
Aug 10 15:05:14.599142 afpd[4512] {netatalk_conf.c:1588} (debug:AFPDaemon): load_volumes: END
```

Exactly the same set up as above, the dataset exists!

Thanks for your suggestions.


----------



## gkontos (Aug 10, 2018)

I finally did it by setting the mountpoint of the DATASET to my home directory.


----------

