Oct 3 2009

Great article about using ZFS for a home NAS

The following post is from someone who has used ZFS on his home fileserver for a year. It is very well-written and I recommend it to anyone considering doing this.

http://breden.org.uk/2009/05/01/home-fileserver-a-year-in-zfs/

Click here for a listing of all his posts on ZFS


Sep 9 2009

Apple has a great sense of humor

Due to a power failure, my NAS device was powered down. When the connection failed, the icon used to represent the NAS changed.

Normally it looks like a rack-mounted XServe, but when the connection was lost it showed up as an old-school CRT monitor with a Windows blue screen of death (BSOD).

Here’s a screenshot:
Mac icon of Windows BSOD

This is how the NAS normally appears:
The normal icon for the NAS

To see how to customize the icon used on Mac OS for a UPNP-advertised device, please read the earlier post: Using MDNS to advertise OpenSolaris NAS to Mac computers


Sep 5 2009

Automatic email alerting of zpool problems and weekly zpool scrub

Since I’m using consumer drives that are prone to failure (one already failed within 2 days, but ZFS prevented any data loss).

I am using the script located here:
http://www.sun.com/bigadmin/scripts/submittedScripts/zpadmin.txt.

This will script allows for regular monitoring and scrubs of the pool with email alerting.

These next bunch of steps may not be necessary for everyone. I’m essentially setting up sendmail to use a smarthost. Even if you do need to use a smarthost, there may be an easier way by just modifying one line in the script.

Set smarthost for sendmail email delivery since ATT blocks outgoing port 25 on home DSL connections.

Steps learned from:

Edited sendmail.mc
cd /usr/lib/mail/cf
nano sendmail.mc

This line only needed if relay not using port 25:
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl

Added:
define(`RELAY_MAILER',`esmtp')dnl
define(`SMART_HOST', `relay:[SmartHostAddressGoesHere]')dnl

Commented out by adding # the followng line:
#define(`confFALLBACK_SMARTHOST', `mailhost$?m.$m$.')dnl

Then at the command line:
m4 /usr/lib/mail/m4/cf.m4 sendmail.mc > /etc/mail/sendmail.cf

Restarted sendmail
svcadm restart sendmail

Then I had to get the script working:

Steps taken:

  • Created a directory called scripts
  • downloaded the script
  • renamed it
  • set it to be executable
  • edited settings
  • scheduled with cron

mkdir /scripts
cd /scripts
wget http://www.sun.com/bigadmin/scripts/submittedScripts/zpadmin.txt
mv zpadmin.txt zpadmin.pl
chmod ug+x zpadmin.pl

Edit script. Need to at minimum change:
my $log_path=
Set mine to "/var/log/zpool_adm_log"
my $mailto =
I had to set my $mailhost = "127.0.0.1" might be due to some sort of misconfiguration on my end. This also means that some of the steps above for configuring the smarthost could have been avoided. I still think they are worthwhile because sendmail may be needed to send other sorts of alerts in the future.

Add to cron:
crontab -e

Crontab uses vi, so we need to enter:
G goes to last line of file
o opens new line after line you’re on and gets you into edit mode

Enter the following. Feel free to omit the commented lines if you’d like.
# ZPOOL MONITOR ->
0 * * * * /scripts/zpadmin.pl
# ZPOOL WEEKLY SCRUB ->
0 5 * * 0 /scripts/zpadmin.pl -scrub

Press Esc to get out of edit mode
Then :wq which tells vi to write the file and then quit.

Now your pools will be checked every hour and will be scrubbed once a week on Sunday at 5AM.

See cron on Wikipedia for more information.


Sep 5 2009

Using MDNS to advertise OpenSolaris NAS to Mac computers

This step is not necessary, but it seems like a good idea if you have Mac computers.

Create the XML files that tell MDNS what to advertise. (Found this information from here, here, and here.

Create /etc/avahi/services/smb.service with the following content:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_device-info._tcp</type>
<port>548</port>
<txt-record>model=RackMac</txt-record>
</service>
<service>
<type>_smb._tcp</type>
<port>139</port>
</service>
</service-group>

The service that contains <txt-record>model=RackMac</txt-record> is only there so that on Mac computers the NAS shows up as an XServe server.

Enable mdns and the avahi-bridge-dsd service:
svcadm enable dns/multicast
svcadm enable avahi-bridge-dsd

I had to reboot the NAS after doing this before MDNS started working and properly advertising.

This is how the NAS appears on the Macs:
NAS normal icon


Aug 30 2009

Setting up a home NAS using OpenSolaris and ZFS

I got my inspiration for this project from reading the following posts on Adam Retter’s blog:

I particularly liked that he made every attempt to make the NAS energy efficient. The hardware he chose made sense, so I essentially bought the same parts he used.

Part suppliers used:

NewEgg has been a great supplier. I use them often and have always been provided great service. One of my hard drives went bad within two days and they made the RMA process painless. Lucky for me ZFS saved the day and I did not lose any data. OrbitMicro provided excellent service as well.

This post does not cover the parts used or steps for assembling the NAS. Please use the steps on Adam Retter’s blog. The posts are linked above.

Here are the steps that I took to set up OpenSolaris and turn it into a storage server for the house.

Downloaded and burned the OpenSolaris iso. I used version 2009.06 which was current at the time of writing. Downloads are available from http://www.opensolaris.com/get/

Tweaked BIOS settings:

  • Disabled all Serial ports
  • Enabled IDE Busmastering
  • Enabled hyperthreading

Booted up the NAS with the OpenSolaris CD in the drive and double-clicked on Install OpenSolaris. The install took some time, and then booted into the Gnome-based environment.

Downloaded the gani driver for my NICs. The built-in rge driver appears to have problems. To install it, I followed the directions in the README.txt file that was distributed with it.

Commands below assume that you are in a root shell. The easiest way seems to be using this command:

  • pfexec bash

This device is going to be a server and I did not want to use up resources having the graphical environment loaded, so I took the following steps:

  • Opened the terminal
  • Typed svcadm disable gdm to disable the graphical environment (you can always type the same command substituting enabled to bring back the GUI)

Then I logged in to the console

Now I disabled the graphical boot and sped up the boot process

  • nano /rpool/boot/grub/menu.lst
  • Changed timeout 30 to timeout 2
  • Removed:
    splashimage /boot/solaris.xpm
    foreground d25f00
    background 115d93
    ,console=graphics

Then I wiped out a lot of the system configuration to properly set up networking:

  • sys-unconfig

Now the system booted into a text-based setup where I set up networking. There are ways to do this all by hand, but the setup makes it easier.

I followed the directions in the Building my DIY NAS post on Adam Retter’s blog to:

  • set up my zfs pool
  • installed the solaris smb software
  • set up users*
  • created zfs file systems

* I set up the users a little differently. After using groupadd to add the groups, I modified the command used to create the users. I essentially removed creating a home directory for the user and changed their shell to /bin/false so they could not log in to the NAS at the console or using SSH:
useradd -c "Name" -g group -G vusers -s /bin/false name

If you have problems with permissions, it my be related to Solaris ACLs and inheritance. These links might help with that:

Performance tweaks I saw listed here and there on the internet.

  • nano /etc/system
  • added the following lines to the bottom of the file
    set pcplusmp:apic_intr_policy=1
    set zfs:zfs_txg_synctime=1

Then I rebooted the NAS. My understanding is the first line changes how interrupts are handled and may increase network IO. The second seems to tell zfs to sync changes to disk more often.

Before these changes I could not use gzip-2 compression on the pool. (Remember this is a very underpowered dual-core Intel Atom processor.) From time to time kernel CPU percentage would spike and file transfers would freeze. Now while writing a file, the kernel CPU % jumps up and down more frequently, but never goes as high.

Maybe someone else could chime in and give us further insight on the performance tuning.

Additional steps taken:
Automatic email alerting of zpool problems and weekly zpool scrub
Using MDNS to advertise OpenSolaris NAS to Mac computers

Please see the OpenSolaris and Storage categories for any future posts about this that may not be linked here.