{"id":228,"date":"2015-06-18T22:50:12","date_gmt":"2015-06-19T03:50:12","guid":{"rendered":"http:\/\/www.edplese.com\/blog\/?p=228"},"modified":"2015-06-19T16:16:52","modified_gmt":"2015-06-19T21:16:52","slug":"setting-up-a-smartos-cifs-file-server","status":"publish","type":"post","link":"https:\/\/www.edplese.com\/blog\/2015\/06\/18\/setting-up-a-smartos-cifs-file-server\/","title":{"rendered":"Setting up a SmartOS CIFS File Server"},"content":{"rendered":"<p>This is a quick guide for setting up a CIFS\/SMB file server using Samba within a virtualized zone on SmartOS. \u00a0A couple of the many benefits of doing this on\u00a0SmartOS are that it can utilize <a href=\"https:\/\/en.wikipedia.org\/wiki\/ZFS\">ZFS<\/a>\u00a0for 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.<\/p>\n<p>On to the setup steps&#8230;<\/p>\n<ol>\n<li>From an installed and running SmartOS system setup a JSON config file for the zone. \u00a0I tend to create a directory <code>\/opt\/vmcfg<\/code> and place the file there, in this case named <code>samba01.json<\/code> with the following contents. \u00a0When placed in a directory under <code>\/opt<\/code> the files will persist across system reboots. \u00a0This sample config uses the base-64 15.1.1 image. \u00a0The 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. \u00a0The alias, hostname, quota, max_physical_memory, ZFS compression, and network configuration can be updated to your environment.\n<pre>{\r\n  \"brand\": \"joyent\",\r\n  \"alias\": \"samba01\",\r\n  \"hostname\": \"samba01\",\r\n  \"quota\": 50,\r\n  \"image_uuid\": \"0edf00aa-0562-11e5-b92f-879647d45790\",\r\n  \"max_physical_memory\": 1024,\r\n  \"delegate_dataset\": true,\r\n  \"zfs_data_compression\": \"on\",\r\n  \"zfs_root_compression\": \"on\",\r\n  \"dns_domain\": \"local\",\r\n  \"resolvers\": [\r\n    \"8.8.8.8\",\r\n    \"8.8.4.4\"\r\n  ],\r\n  \"nics\": [\r\n    {\r\n      \"nic_tag\": \"admin\",\r\n      \"ip\": \"10.1.1.211\",\r\n      \"netmask\": \"255.255.255.0\",\r\n      \"gateway\": \"10.1.1.1\",\r\n      \"primary\": true\r\n    }\r\n  ]\r\n}\r\n<\/pre>\n<\/li>\n<li>Create the zone from the configuration file.\n<pre># vmadm create -f samba01.json \r\nSuccessfully created VM 6153d789-5697-4ec6-a237-55198fe3c6b8\r\n<\/pre>\n<\/li>\n<li>Log into the zone and\u00a0install Samba.\n<pre># zlogin 6153d789-5697-4ec6-a237-55198fe3c6b8\r\n# pkgin update\r\n# pkgin install samba\r\n<\/pre>\n<\/li>\n<li>Setup the ZFS home directories and move the admin user home directory to a ZFS filesystem.\n<pre># zfs create zones\/6153d789-5697-4ec6-a237-55198fe3c6b8\/data\/home\r\n# zfs create zones\/6153d789-5697-4ec6-a237-55198fe3c6b8\/data\/home\/admin\r\n# cp -a \/home\/admin\/. \/zones\/6153d789-5697-4ec6-a237-55198fe3c6b8\/data\/home\/admin\r\n# rm -rf \/home\/admin\r\n# zfs set mountpoint=\/home zones\/6153d789-5697-4ec6-a237-55198fe3c6b8\/data\/home\r\n<\/pre>\n<\/li>\n<li>Create a new user with a separate filesystem for the home directory.\n<pre># zfs create zones\/6153d789-5697-4ec6-a237-55198fe3c6b8\/data\/home\/ed\r\n# chown ed:other \/home\/ed\r\n# useradd ed\r\n<\/pre>\n<\/li>\n<li>Set the user&#8217;s Samba password.\n<pre># smbpasswd -a ed\r\n<\/pre>\n<\/li>\n<li>Optionally edit the Samba config file in <code>\/opt\/local\/etc\/samba\/smb.conf<\/code>.<\/li>\n<li>Start up Samba. \u00a0This will also set it to be enabled at startup.\n<pre># svcadm enable -r smbd\r\n# svcadm enable -r nmbd<\/pre>\n<\/li>\n<li>From a Windows or other computer connect to the user&#8217;s home directory\/share as <code>\\\\10.1.1.211\\ed<\/code><\/li>\n<\/ol>\n<p>This will get you a basic file server setup. \u00a0From here you can add addition users, shared directories, etc.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a quick guide for setting up a CIFS\/SMB file server using Samba within a virtualized zone on SmartOS. \u00a0A couple of the many benefits of doing this on\u00a0SmartOS are that it can utilize ZFS\u00a0for file storage and also that the file server can be isolated off as a zone and be run in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[9,20,5],"_links":{"self":[{"href":"https:\/\/www.edplese.com\/blog\/wp-json\/wp\/v2\/posts\/228"}],"collection":[{"href":"https:\/\/www.edplese.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.edplese.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.edplese.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.edplese.com\/blog\/wp-json\/wp\/v2\/comments?post=228"}],"version-history":[{"count":7,"href":"https:\/\/www.edplese.com\/blog\/wp-json\/wp\/v2\/posts\/228\/revisions"}],"predecessor-version":[{"id":235,"href":"https:\/\/www.edplese.com\/blog\/wp-json\/wp\/v2\/posts\/228\/revisions\/235"}],"wp:attachment":[{"href":"https:\/\/www.edplese.com\/blog\/wp-json\/wp\/v2\/media?parent=228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.edplese.com\/blog\/wp-json\/wp\/v2\/categories?post=228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.edplese.com\/blog\/wp-json\/wp\/v2\/tags?post=228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}