~drscream

Setting up Samba on SmartOS

This article is based on Jonathans awesome Setting up Samba on SmartOS article, so thanks a lot. His blog post is more than two years old but still provided to all people who ask about setting up Samba on SmartOS. But things have changed, Jonathan implemented SMF support to pkgsrc which makes it a lot easier.

Creating a virtual machine

Be sure you’re using the latest base64 image from the official dataset server.

# Update imgadm image list and import the base64 image
imgadm update
imgadm import 62f148f8-6e84-11e4-82c5-efca60348b9f

# Create the zone
vmadm create << EOF
{
  "brand": "joyent",
  "image_uuid": "62f148f8-6e84-11e4-82c5-efca60348b9f",
  "autoboot": true,
  "alias": "samba.example.com",
  "hostname": "samba.example.com",
  "dns_domain": "example.com",
  "quota": 200,
  "resolvers": [
    "8.8.8.8",
    "8.8.4.4"
  ],
  "max_physical_memory": 1024,
  "max_swap": 1024,
  "nics": [
    {
      "nic_tag": "admin",
      "ip": "dhcp",
      "primary": true
    }
  ]
}
EOF

Modify the information to your needs, for example hostname, quota and nics.

Install Samba package

The best package manager pkgin is already bootstraped in the base64 image. You only need to login to your new zone and install samba.

# Use zlogin from the global zone
zlogin <uuid>

# Or use SSH :-)
ssh root@<hostname>
# Update the pkg information to have the latest version ready
pkgin -y up

# Install latest samba package
pkgin -y install samba

Configure Samba

This depends on your needs, there are lots of default configs everywhere. I only provide a small example with an full access share.

# Create share folder
mkdir /share
chown nobody:nobody /share

The smb.conf is located in /opt/local/etc/samba. Modify the config with your preferred editor.

[global]
  security = share
  load printers = no
  guest account = nobody

[share]
  path = /share
  public = yes
  only guest = yes
  writable = yes
  printable = no

Start the service

You don’t need to provide or create any rc.d start scripts because someone created an SMF manifest :-)

# Enable nmbd and smbd
svcadm enable svc:/pkgsrc/samba:nmbd
svcadm enable svc:/pkgsrc/samba:smbd

Multicast DNS

If you like auto discovery of your services enable multicast DNS. In the MacOS X Finder the samba service will appear automatically.

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

The End

Thanks a lot to Jonathan Perkin. This blog post is more or less a copy of his old one. Also thanks for implementing SMF support to pkgsrc.


Send your comment by mail.