Categories

Building an OpenSolaris Server: A Better CIFS Server than Windows?

With the capabilities that ZFS brings to the table, I’m beginning to think that OpenSolaris just might make a better CIFS server than Windows. Sun has built CIFS support into the kernel, which helps with some of the interoperability challenges faced with Samba in a mixed Windows/*nix environment. Here’s how to set it up.

First things, first. Install the CIFS server:


james@opensolaris:~# pkg install SUNWsmbskr
DOWNLOAD                                  PKGS       FILES    XFER (MB)
Completed                                  2/2       35/35      2.0/2.0

PHASE                                        ACTIONS
Install Phase                                  90/90

Start the idmap and smb/server services:


james@opensolaris:~# svcadm enable idmap
james@opensolaris:~# svcadm enable smb/server
james@opensolaris:~# svcs | egrep "idmap|smb/server"
online         10:50:07 svc:/system/idmap:default
online         10:50:08 svc:/network/smb/server:default

Now let’s create a ZFS file system with the proper permissions and share it out:


james@opensolaris:~# zfs create -o casesensitivity=mixed -o nbmand=on rpool/test
james@opensolaris:~# chmod 777 /rpool/test
james@opensolaris:~# chmod -R A=everyone@:full_set:fd:allow /rpool/test
james@opensolaris:~# zfs set sharesmb=name=test,guestok=true rpool/test
james@opensolaris:~# sharemgr show -v
default
zfs
    zfs/rpool/test
          /rpool/test
                  test=/rpool/test       smb=(guestok="true")


I've enabled guest access on this share (i.e., no password required; you'll probably want to do this on a home network). This requires build snv_118 or later. If you decide to forgo guest access, you'll need to generate SMB compatible passwords for your user accounts. This can be done by simply resetting their passwords. Connect to the share from a Windows box and create a file:

Now take a look at it back on the OpenSolaris box:


james@opensolaris:/rpool/test# ls -al test.txt
-rwxrwxrwx+  1 2147483649 2147483650       0 Dec 17 10:38 test.txt


Uh-oh. OpenSolaris doesn't know how to translate the Windows users/groups. Let's fix that:


james@opensolaris:/rpool/test# idmap add winuser:Guest@opensolaris unixuser:nobody
add     winuser:Guest@opensolaris       unixuser:nobody
james@opensolaris:/rpool/test# idmap add "wingroup:Domain Users@opensolaris" unixgroup:staff
add     "wingroup:Domain Users@opensolaris"     unixgroup:staff


You'll need to reboot for this change to take effect. There may be a way around this, but restarting idmap and/or smb/server doesn't seem to work. Check out the permissions now:


james@opensolaris:/rpool/test# ls -al test.txt
-rwxrwxrwx+  1 nobody   staff          0 Dec 17 10:38 test.txt

Looks good on the Windows side as well:

idmap might not be especially exciting in a home environment, but it does work quite well when integrated into an AD infrastructure. More on that in a future post.

One last thing: ZFS snapshots are recognized by Windows as well:

Building an OpenSolaris Server: Fixing Page Up/Down, etc.

The Page Up/Down, Home, and End keys don’t work out of the box.  Very annoying when you’re trying to scroll through a man page.  Fortunately, it’s an easy fix.

Export the existing terminfo description:


james@opensolaris:~# env TERMINFO=/usr/share/lib/terminfo /bin/infocmp xterm > /tmp/xterm.ti

Add the missing key definitions:


james@opensolaris:~# echo '\tknp=\\E[6~, kpp=\\E[5~, kend=\\EOF, khome=\\EOH,' >> /tmp/xterm.ti

Compile the file:


james@opensolaris:~# env TERMINFO=/tmp /bin/tic -v /tmp/xterm.ti

And replace the existing xterm description:


james@opensolaris:~# mv /tmp/x/xterm /usr/share/lib/terminfo/x/xterm

Building an OpenSolaris Server: Mirroring rpool

During the install, OpenSolaris creates a ZFS pool, called rpool, and installs to it.  Let’s set up two hard drives for redundancy (i.e., RAID-1).

Before (note that rpool consists of a single drive):


james@opensolaris:~# zpool status
  pool: rpool
 state: ONLINE
 scrub: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        rpool       ONLINE       0     0     0
          c5t0d0s0  ONLINE       0     0     0

errors: No known data errors

Attaching the second hard drive to the pool:


james@opensolaris:~# zpool attach -f rpool c5t0d0s0 c5t1d0s0
Please be sure to invoke installgrub(1M) to make 'c5t1d0s0' bootable.
Make sure to wait until resilver is done before rebooting.

Need to install grub to the second hard drive to make it bootable should the primary go offline:


james@opensolaris:~# installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c5t1d0s0
Updating master boot sector destroys existing boot managers (if any).
continue (y/n)?y
stage1 written to partition 0 sector 0 (abs 16065)
stage2 written to partition 0, 273 sectors starting at 50 (abs 16115)
stage1 written to master boot sector

And we’re done…


james@opensolaris:~# zpool status
  pool: rpool
 state: ONLINE
 scrub: none requested
config:

        NAME          STATE     READ WRITE CKSUM
        rpool         ONLINE       0     0     0
          mirror-0    ONLINE       0     0     0
            c5t0d0s0  ONLINE       0     0     0
            c5t1d0s0  ONLINE       0     0     0

errors: No known data errors

Building an OpenSolaris Server: The Hardware

One of the primary functions of the server is to host my collection of DVDs/Blu-rays for streaming to a Windows Media Center PC.  That said, I need a lot of disk space.  It’s predecessor had 6.75TB of disk space; this one will have 16TB.  Here’s the hardware list:

A few notes about the build:

  • The case is awesome.  Room for 10 hard drives in vibration-isolation mounts, completely tool-less, good cooling, and it looks cool.
  • I added the Cooler Master cage so I could squeeze in two more drives.  It has a cheesy blue LED fan.  Fortunately the case has a front cover that hides it.
  • Went with AMD since Intel doesn’t support ECC RAM with recent (consumer-level) processors.
  • Newegg doesn’t know how to ship hard drives.  The drives were simply wrapped in a layer of bubble wrap then dropped loosely in the box.  2 were DOA.  Unfortunately, this isn’t the first time this has happened to me with a Newegg order.
  • The Supermicro SATA controller is intended to be an add-on module for their motherboards/systems.  As such, it won’t fit into a standard case without some modification.  Fortunately, all you need are a couple of plastic spacers from Home Depot.

Overall, there was nothing all that special about the build.  I dropped in an OpenSolaris LiveCD and had the system up and running in minutes.

Building an OpenSolaris Server

My existing Linux server, which I use for file storage, email, and web hosting, ran out of disk space.  Driven by a desire to play with ZFS, I decided that its replacement would run OpenSolaris.  This is the first in a series of posts detailing the build and what I’ve learned along the way.