Skip to main content

Install netatalk on SmartOS

·

This tutorial will show you how to install netatalk on SmartOS. Netatalk is an open-source implementation of the Apple Filing Protocol, which used to be the default file-sharing protocol on Macs . It has since been replaced as the default file-sharing protocol on Macs by SMB/CIFS.

Netatalk can be used to build your own NAS from commodity hardware instead of buying one , which is also an option.

SmartOS supports AMD Ryzen and AMD EPYC CPUs since a while back, in addition to the long-supported Intel CPUs, such as the Intel Xeon .

This article assumes you have a working SmartOS host and are logged in as root.

Create a SmartOS Zone #

Find the latest base-64 image, in this case, f3a6e1a2-9d71-11e9-9bd2-e7e5b4a5c141:

# imgadm avail | grep base-64

Import the SmartOS image:

# imgadm import f3a6e1a2-9d71-11e9-9bd2-e7e5b4a5c141

Next, we’ll create the container based on the imported SmartOS image. The following command line will create a new SmartOS container with 2048 MB RAM, 32 GB disk, and a statically configured NIC (change the NIC settings to match your network setup). It’ll also pass a ZFS dataset from the host system to the container (/tank/data); this is useful to give netatalk access to files stored on the host.

Create the container:

# vmadm create << EOL
{
  "alias": "netatalk",
  "hostname": "netatalk",
  "brand": "joyent",
  "image_uuid": "f3a6e1a2-9d71-11e9-9bd2-e7e5b4a5c141",
  "max_physical_memory": 2048,
  "max_locked_memory": 2048,
  "max_swap": 2048,
  "quota": 32,
  "filesystems": [
    {
      "type": "lofs",
      "source": "/tank/data",
      "target": "/tank/data"
    }
  ],
  "nics": [
    {
      "nic_tag": "admin",
      "ip": "10.0.2.5",
      "netmask": "255.255.0.0",
      "gateway": "10.0.0.1"
    }
  ],
  "resolvers": ["8.8.8.8", "8.8.4.4"]
}
EOL

This will generate a message: Successfully created VM <UUID>. Make a note of the container UUID; we’ll need it next.

Build and Install netatalk #

Next, we’ll log in to the newly created container (remember the UUID from earlier):

# zlogin <UUID>

Update the pkgsrc package manager:

# pkgin up

Install the compiler, build tools and cryptographic dependencies:

# pkgin in gcc47 gmake libevent libgcrypt openssl

Next, we’ll download and extract the latest version of netatalk. This guide uses version 3.1.12. You can find the latest version at SourceForge. Run:

# cd ~
# wget http://sourceforge.net/projects/netatalk/files/netatalk/3.1.12/netatalk-3.1.12.tar.gz
# tar xfvz netatalk-3.1.12.tar.gz
# cd netatalk-3.1.12

Configure the netatalk source before building:

# ./configure --with-ssl-dir=/opt/local --with-libevent-header=/opt/local --with-libevent-lib=/opt/local --with-libgcrypt --with-bdb=/opt/local --with-init-style=solaris --with-init-dir=/var/svc/manifest/network/ --without-pam --prefix=/opt/locals

Building netatalk requires a symbolic link for 64-bit libraries:

# ln -s /opt/local/lib /opt/local/lib/64

Finally, let’s build netatalk (this will likely take a little while):

# make && make install

Configure netatalk #

Edit the configuration file /opt/local/etc/afp.conf:

# vim /opt/local/etc/afp.conf

And add the following, changing to match your specific configuration:

[Global]
server name = NAS
log file = /var/log/netatalk.log
uam list = uams_dhx.so,uams_dhx2.so
mimic model = RackMac

[Data]
path = /tank/data
valid users = user
rwlist = user

[Time Machine]
path = /tank/data/timemachine
valid users = user
rwlist = user
time machine = yes
vol size limit = 512000
  • mimic model = RackMac sets the icon displayed in Finder; for available options, see the file on a Mac: /System/Library/CoreServices/CoreTypes.bundle/Contents/Info.plist
  • The [Time Machine] section enables support for Time Machine on your netatalk server

Configure Permissions #

Make sure the correct user and group have permissions to access your storage:

# groupadd -g 1000 nas
# useradd -u 1001 -g 1000 -s /usr/bin/false user
# chown -R user:nas /tank/data

Set the password for your user user:

# passwd user

Start Services #

And finally, start the required services:

# svcadm enable svc:/network/dns/multicast:default
# svcadm enable svc:/network/netatalk:default

That’s all! You should now be able to access your server via netatalk from your Mac , logging in with the credentials you configured above! 😀

Revision #

2023-08-31 Revised language