ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/www/trunk/documentation/zfs.html
Revision: 572
Committed: Sat Nov 22 18:29:12 2014 UTC (9 years, 5 months ago) by laffer1
Content type: text/html
File size: 8352 byte(s)
Log Message:
add an example for dealing with advanced format drives and zfs

File Contents

# Content
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5 <title>MidnightBSD ZFS Documentation</title>
6 <link rel="shortcut icon" href="/favicon.ico">
7 <link rel="stylesheet" type="text/css" href="../css/essence.css">
8 </head>
9 <body>
10 <div id="globe">
11 <div id="header"><h1 title="MidnightBSD Home"><a href="../" title="MidnightBSD Home">MidnightBSD: The BSD For Everyone</a></h1></div>
12 <!--#include virtual="/menu.html"-->
13 <div class="clear"></div>
14 <div id="text">
15 <h2><img src="../images/oxygen/doc32.png" alt="" /> ZFS Documentation</h2>
16 <div id="toc">
17 <h3>Contents</h3>
18 <ul>
19 <li><a href="#s1b">Introduction</a></li>
20 <li><a href="#s1c">Preparing</a></li>
21 <li><a href="#s1d">Examples</a></li>
22 <li><a href="#s1e">Recovery</a></li>
23 <li><a href="#s1f">Snapshots</a></li>
24 <li><a href="#s1g">Send/Receive</a></li>
25 <li><a href="index.html"><strong>Documentation</strong></a></li>
26 <li><a href="../wiki/"><strong>MidnightBSD Wiki (more)</strong></a></li>
27 </ul>
28 </div>
29 <h3 id="s1a">ZFS</h3>
30 <h4 id="s1b">Introduction</h4>
31 <p>ZFS is a file system developed for Oracle Solaris. It was released as open source under the CDDL
32 with OpenSolaris. FreeBSD created a port of the file system for FreeBSD 7.0-CURRENT. It was imported
33 into MidnightBSD with 0.3-CURRENT.</p>
34
35 <p>ZFS is considered an alternative file system to UFS2 in MidnightBSD. It has independant RAID features
36 that are not tied to GEOM classes. It does not make use of the VFS cache and has some issues with
37 NFS. Advantages include support for very large file systems and large pools of disks. it supports
38 checksum data integrety checking and can repair bad data when raidz is used.</p>
39
40 <p>MidnightBSD includes ZFS file system and storage pool version 6. You may access pools created
41 on other operating systems at or below this version. If you upgrade to version 6, you will no
42 longer be able to read them on older versions.</p>
43
44 <h4 id="s1c">Prepairing</h4>
45 <p>ZFS can be used in two ways. You may either dedicate entire disks to ZFS (recommended) or use
46 GPT partitions (mnbsd-zfs in 0.4-CURRENT) to add to a pool. ZFS shines when used with RAID features.
47 </p>
48
49 <p>If you're going to use RAID, determine how many disks you want to use. It's best to group them
50 in identical sizes. If possible, use the same brand and model of drives when using mirroring.
51 If you have two drives, use mirror. If you have more than two drives, consider using raidz. You
52 may add multiple mirror sets (2 at a time) to the pool.</p>
53
54 <p>ZFS also supports adding spare drives to the pool. They will be used automatically when a drive fails.</p>
55
56 <p>It is strongly recommended to use ZFS only with amd64 MidnightBSD and only on systems with more
57 than 1GB of RAM. It will require tuning sysctl's to get the right balance of memory usage. Particularly,
58 you need to watch the ARC size as it can grow very large</p>
59
60 <p>MidnightBSD does not support booting from ZFS at this time. It may be added in a future release. You need
61 a UFS/UFS2 partition for / including /boot, but /var, /tmp, /usr and /home can be on ZFS.</p>
62
63 <h4 id="s1d">Examples</h4>
64
65 <p>In these examples, mpool and tank are used as pool names. You can pick any name for the pool, but tank is very
66 common. After creating a pool named tank, you'll see /tank</p>
67
68 <p>You will most likely want to add zfs_enable="YES" into /etc/rc.conf so that ZFS is loaded on system startup</p>
69
70 <p>Create a mirror</p>
71 <code>zpool create mpool mirror /dev/ad0 /dev/ad1</code>
72
73 <p>Add a spare drive</p>
74 <code> zpool add mpool spare /dev/ad3</code>
75
76 <p>Check status</p>
77 <code>zpool status</code>
78
79 <p>Listing information about pools</p>
80 <code>zpool list</code>
81 <code>zfs list</code>
82
83 <p>Create file systems</p>
84 <code>zfs create mpool/data</code>
85
86 <p>Use raidz instead (raid 5 like mode)</p>
87 <code>zpool add tank raidz /dev/ad0 /dev/ad1 /dev/ad2</code>
88
89 <p>Scrub data (check for errors)</p>
90 <code>zpool scrub tank</code>
91
92 <h4 id="s1e">Recovery</h4>
93
94 <p>During a hardware upgrade such as moving to a new motherboard or controller,
95 one might find their zpool damaged. Usually the cause is that the device name has
96 changed. For instance, a recent upgrade moved ad6 to ad12.</p>
97 <p>To fix this problem,
98 several steps are required.
99 <ul><li><code>rm /boot/zfs/zpool.cache & shutdown -r now</code></li>
100 <li>
101 <code>zpool list</code>. This should not show the pool.
102 </li>
103 <li><code>zpool import</code>. It should show you possible pools to recover.</li>
104 <li>
105 Finally, try <code>zpool import <em>name of pool</em></code>.
106 </li>
107 </ul>
108
109 <p>To verify it worked, run <code>zpool list</code></p>
110
111 <h4 id="s1f">Snapshots</h4>
112
113 <p>A ZFS snapshot, is a point in time copy or bookmark of your data. You can use
114 it to compare changes made to a file system or to backup a file system. This allows
115 you to get your data back after trying an upgrade, etc. It can be a handy trick
116 to make copies of jails easily.
117 </p>
118
119 <p>You can create a snapshot named 1 using the following:</p>
120 <code>zfs snapshot tank/test@1</code>
121
122 <p>You can also apply a snapshot recursively to all file systems in a pool
123 with the r flag</p>
124
125 <code>zfs snapshot -r tank/home@now</code>
126
127 <p>As more changes occur to a file system, the amount of disk space a snapshot
128 takes increases. You will want to purge old snapshots to free up disk space
129 when they are no longer needed.</p>
130
131 <code>zfs destroy tank/home@now</code>
132
133 <p>You can use the rename command to rename a snapshot, the hold command to
134 prevent removal of a snapshot, and many more options. Consult the
135 relevant man pages for more information.</p>
136
137 <p>Finally, you can list snapshots</p>
138 <code>zfs list -t snapshot</code>
139
140 <p>You can also make zfs list show snapshots by default by changing this setting
141 <code>zpool set listsnapshots=on tank</code></p>
142
143 <h4 id="s1g">Using Send and Receive</h4>
144 <p>You can use zfs to send a snapshot to the same or another pool with the
145 zfs send and receive commands. This can be used to backup ZFS file systems
146 to another location such as an external disk.</p>
147
148 <p>To backup the snapshot named 1 from file system test:
149 <code>
150 zfs send tank/test@1 | zfs receive tank/testback
151 </code>
152 </p>
153
154 <h4 id="s1h">Advanced format hard drives (4k sector)</h4>
155
156 <p>Many 4k sector drives do not report their size properly in a bad attempt
157 at backward compatibility. ZFS works fine with drives that report
158 properly, but for the rest of them the following workaround is
159 recommended.
160 </p>
161 <p>
162 <code>
163 gpart create -s gpt ada0
164
165 # create partitions
166 gpart add -a 1m -t mnbsd-zfs -l drive0 ada0
167 gpart add -a 1m -t mnbsd-zfs -l drive1 ada1
168
169 # use gnop to make 4k friendly devices
170 gnop create -S 4k gpt/drive0
171 gnop create -S 4k gpt/drive1
172
173 # make a mirror
174 zpool create mpool mirror /dev/gpt/drive0.nop /dev/gpt/drive1.nop
175
176 # export pool and remove virtual devices
177 zpool export mpool
178 gnop destroy gpt/drive0.nop
179 gnop destroy gpt/drive1.nop
180
181 # import and keep labels (via -d flag)
182 zpool import -d /dev/gpt mpool
183 </code>
184 </p>
185
186
187 <div id="disqus_thread"></div>
188 <script type="text/javascript">
189 var disqus_shortname = 'midnightbsd';
190
191 (function() {
192 var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
193 dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
194 (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
195 })();
196 </script>
197 <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
198 <a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
199 </div>
200 <!--#include virtual="/footer.html"-->
201 </body>
202 </html>

Properties

Name Value
svn:executable *