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 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