<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>source code bean &#187; UNIX</title>
	<atom:link href="http://sourcecodebean.com/archives/category/unix/feed" rel="self" type="application/rss+xml" />
	<link>http://sourcecodebean.com</link>
	<description>giving you tricks and tips of good coding</description>
	<lastBuildDate>Sun, 06 Jun 2010 16:40:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ZFS for home NAS?</title>
		<link>http://sourcecodebean.com/archives/zfs-for-home-nas/323</link>
		<comments>http://sourcecodebean.com/archives/zfs-for-home-nas/323#comments</comments>
		<pubDate>Mon, 07 Dec 2009 19:58:36 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Storage]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://sourcecodebean.com/?p=323</guid>
		<description><![CDATA[I have been doing some research on NASes for home use. I basically want a NAS that offers redundancy (some form of raid), the ability to add disks as I go. It should also support at least SMB as file sharing protocol (but preferable others as well), and of course not be too expensive. All [...]]]></description>
			<content:encoded><![CDATA[<p>I have been doing some research on NASes for home use. I basically want a NAS that offers redundancy (some form of raid), the ability to add disks as I go. It should also support at least SMB as file sharing protocol (but preferable others as well), and of course not be too expensive. All home NASes I have found yet has been lacking on at least one of the above criteria.</p>
<p>I have read about people using ZFS on FreeBSD or OpenSolaris for their storage servers. ZFS is a open source file system developed by Sun Microsystems which has some features that makes it very compelling for a file storage server. Unfourtanly ZFS is not available on Linux at the time of writing (i think it is some licensing issues that is preventing a port of it), if it were I would definitely go for it. </p>
<p>To give it a try, i downloaded OpenSolaris 2009.6 and installed it as a virtual machine in VMware Fusion. Instead of having to add several virtual disks to the VM, i decided to test the features of ZFS using regular files (ZFS can use files as disk devices). An easy way to create some &#8220;disks&#8221; is to use the <code>mkfile</code> command, it will create a file that can be used a disk device:</p>
<blockquote><p><code># mkfile 100m /tmp/disk1<br />
# mkfile 100m /tmp/disk2<br />
# mkfile 100m /tmp/disk3<br />
# mkfile 100m /tmp/disk4</code></p></blockquote>
<p>ZFS has tree leveles. The highest level is a ZFS pool, which can consist of several ZFS filesystems. A ZFS filesystem consists of one or more devices. Filesystems within a pool share its resources and are not restricted to a fixed size. You can add or remove devices to a pool (for example to increase your storage space), while the pool is running. Devices in a filesystem can be configured in mirrored mode or in RAIDZ mode to offer redundancy. ZFS also supports filesystem level snapshots and cloning from existing file systems.  The two main ZFS commands are:</p>
<blockquote><p><code><strong>zpool</strong> - Manages the pools and the devices within them<br />
<strong>zfs</strong> - Manages ZFS filesystems</code> </p></blockquote>
<p>Ok, so lets create a pool from the disks we created earlier:</p>
<blockquote><p><code># zpool create storage /tmp/disk1 /tmp/disk2</code></p></blockquote>
<blockquote><p><code># zpool list<br />
NAME      SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT<br />
rpool    7.94G  4.28G  3.66G    53%  ONLINE  -<br />
storage   191M  74.5K   191M     0%  ONLINE  -</code></p></blockquote>
<p>As you can see we combined two disks into one pool. The filesystem automatically gets mounted on /storage (this is the default mount point, it can be changed). No volume management, configuration or formatting is needed. Lets destoy this pool to create a more interesting one. </p>
<blockquote><p>
<code># zpool destroy storage</code></p></blockquote>
<blockquote><p><code># zpool list<br />
NAME    SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT<br />
rpool  7.94G  4.36G  3.58G    54%  ONLINE  -</code></p></blockquote>
<p>As you can see, it is gone. Lets create a new pool using RAIDZ (a form of raid, similar to RAID5):</p>
<blockquote><p><code># zpool create storage raidz /tmp/disk1 /tmp/disk2 /tmp/disk3</code></p></blockquote>
<blockquote><p><code># zpool list<br />
NAME      SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT<br />
rpool    7.94G  4.38G  3.56G    55%  ONLINE  -<br />
storage   286M   140K   286M     0%  ONLINE  -<br />
</code></p></blockquote>
<p>One thing that’s a little different in a ZFS raidz pool versus other RAID-5 filesystems is that the reported available disk space doesn’t subtract the space required by parity. Of course parity will take up space, so this is something to keep in mind when monitoring the disks. We can monitor the status of the pool by using the <code>zpool status</code> command:</p>
<blockquote><p><code># zpool status storage<br />
  pool: storage<br />
 state: ONLINE<br />
 scrub: none requested<br />
config:</p>
<p>        NAME            STATE     READ WRITE CKSUM<br />
        storage         ONLINE       0     0     0<br />
          raidz1        ONLINE       0     0     0<br />
            /tmp/disk1  ONLINE       0     0     0<br />
            /tmp/disk2  ONLINE       0     0     0<br />
            /tmp/disk3  ONLINE       0     0     0</p>
<p>errors: No known data errors</code></p></blockquote>
<p>After some playing around with ZFS i certainly think it would be a great choice for a storage server. It is way easier to use than the software/LVM solutions i have tried on Linux. The biggest drawback would be OpenSolaris itself, I just find the GNU application userland easier to use compared to the Solaris one. Maybe I should give Nexenta (OpenSolaris Kernel, GNU application userland) a chance?</p>
<p>Read more:<br />
<a href="http://en.wikipedia.org/wiki/ZFS">ZFS on Wikipedia</a><br />
<a href="http://blogs.sun.com/bonwick/entry/raid_z">RAID-Z</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sourcecodebean.com/archives/zfs-for-home-nas/323/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
