Home > Uncategorized > Setting up a SmartOS CIFS File Server

Setting up a SmartOS CIFS File Server

June 18th, 2015

This is a quick guide for setting up a CIFS/SMB file server using Samba within a virtualized zone on SmartOS.  A couple of the many benefits of doing this on SmartOS are that it can utilize ZFS for file storage and also that the file server can be isolated off as a zone and be run in parallel with various other zones and virtual machines.

On to the setup steps…

  1. From an installed and running SmartOS system setup a JSON config file for the zone.  I tend to create a directory /opt/vmcfg and place the file there, in this case named samba01.json with the following contents.  When placed in a directory under /opt the files will persist across system reboots.  This sample config uses the base-64 15.1.1 image.  The delegate_dataset=true creates a ZFS filesystem that can be managed within the zone which is a nice feature to have on a file server for separating out users or shares to different filesystems.  The alias, hostname, quota, max_physical_memory, ZFS compression, and network configuration can be updated to your environment.
    {
      "brand": "joyent",
      "alias": "samba01",
      "hostname": "samba01",
      "quota": 50,
      "image_uuid": "0edf00aa-0562-11e5-b92f-879647d45790",
      "max_physical_memory": 1024,
      "delegate_dataset": true,
      "zfs_data_compression": "on",
      "zfs_root_compression": "on",
      "dns_domain": "local",
      "resolvers": [
        "8.8.8.8",
        "8.8.4.4"
      ],
      "nics": [
        {
          "nic_tag": "admin",
          "ip": "10.1.1.211",
          "netmask": "255.255.255.0",
          "gateway": "10.1.1.1",
          "primary": true
        }
      ]
    }
    
  2. Create the zone from the configuration file.
    # vmadm create -f samba01.json 
    Successfully created VM 6153d789-5697-4ec6-a237-55198fe3c6b8
    
  3. Log into the zone and install Samba.
    # zlogin 6153d789-5697-4ec6-a237-55198fe3c6b8
    # pkgin update
    # pkgin install samba
    
  4. Setup the ZFS home directories and move the admin user home directory to a ZFS filesystem.
    # zfs create zones/6153d789-5697-4ec6-a237-55198fe3c6b8/data/home
    # zfs create zones/6153d789-5697-4ec6-a237-55198fe3c6b8/data/home/admin
    # cp -a /home/admin/. /zones/6153d789-5697-4ec6-a237-55198fe3c6b8/data/home/admin
    # rm -rf /home/admin
    # zfs set mountpoint=/home zones/6153d789-5697-4ec6-a237-55198fe3c6b8/data/home
    
  5. Create a new user with a separate filesystem for the home directory.
    # zfs create zones/6153d789-5697-4ec6-a237-55198fe3c6b8/data/home/ed
    # chown ed:other /home/ed
    # useradd ed
    
  6. Set the user’s Samba password.
    # smbpasswd -a ed
    
  7. Optionally edit the Samba config file in /opt/local/etc/samba/smb.conf.
  8. Start up Samba.  This will also set it to be enabled at startup.
    # svcadm enable -r smbd
    # svcadm enable -r nmbd
  9. From a Windows or other computer connect to the user’s home directory/share as \\10.1.1.211\ed

This will get you a basic file server setup.  From here you can add addition users, shared directories, etc.

Tags: , ,
Comments are closed.