-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
122 lines (113 loc) · 4.39 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!DOCTYPE html>
<html lang="en-GB">
<head>
<title>Floating Octothorpe</title>
<meta charset="utf-8" />
<meta name="Author" content="Floating Octothorpe" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/css/main.css">
<link rel="icon" type="image/png" href="/img/favicon.png" />
</head>
<body>
<header>
<a href="/"><img class="logo" src="/img/logo.png" alt="Floating Octothorpe logo"/></a>
<h1 class="site-title">Floating Octothorpe</h1>
<nav>
<ul>
<li><a href="/">Latest</a></li>
<li><a href="/archive.html">Archive</a></li>
<li><a href="/about.html">About</a></li>
</ul>
</nav>
</header>
<article>
<h1>Building a NAS: part 4 - ZFS mirror</h1>
<time datetime="2020-05-25">25 May 2020</time>
<p>At the end of the <a href="/2020/building-a-nas-part-3">previous post</a> I had a ZFS pool backed by a
single vdev. This is all well and good until a disk fails. To improve fault
tolerance ZFS allows you to add a mirror disk. This obviously isn't a backup;
but should make life easier if a disk fails unexpectedly.</p>
<p><img alt="Layout diagram showing an extra vdev being added to a pool" src="/2020/zfs-layout-with-mirror.svg"></p>
<h2>Adding a mirror</h2>
<p>Assuming you are starting from a pool backed by a single vdev, adding an
additional vdev to mirror the content is relatively straightforward.</p>
<ol>
<li>
<p>First make sure the pool is online:</p>
<pre><code>$ zpool status pool: mypool state: ONLINE
scan: none requested
config:
NAME STATE READ WRITE CKSUM
mypool ONLINE 0 0 0
sdc ONLINE 0 0 0
errors: No known data errors
</code></pre>
</li>
<li>
<p>Then identify the device to join to the pool using <code>lsblk</code>:</p>
<pre><code>$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 37.3G 0 disk
├─sda1 8:1 0 731M 0 part /boot
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 36.6G 0 part
└─sdb5_crypt 253:0 0 36.6G 0 crypt
├─vghost-root 253:1 0 35.6G 0 lvm /
└─vghost-swap_1 253:2 0 976M 0 lvm [SWAP]
sdb 8:16 1 492M 0 disk
└─sdb1 8:17 1 491M 0 part
sdc 8:32 0 3.7T 0 disk
├─sdc1 8:33 0 3.7T 0 part
└─sdc9 8:41 0 8M 0 part
sdd 8:48 0 3.7T 0 disk
├─sdd1 8:49 0 3.7T 0 part
└─sdd9 8:57 0 8M 0 part
</code></pre>
<p><strong>Note</strong>: in this case <code>/dev/sdd</code> is the device we want to use.</p>
</li>
<li>
<p>Clear any existing partitions from the disk (make sure you have the correct
disk!):</p>
<pre><code>$ parted /dev/sdd mklabel gpt
Warning: The existing disk label on /dev/sdd will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes
Information: You may need to update /etc/fstab.
</code></pre>
</li>
<li>
<p>Finally attach the blank disk to the pool, ZFS will automatically start
resilvering the new disk to setup a mirror:</p>
<pre><code>$ zpool attach mypool /dev/sdc /dev/sdd
$ zpool status
pool: mypool
state: ONLINE
status: One or more devices is currently being resilvered. The pool will
continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
scan: resilver in progress since Mon Apr 6 22:40:24 2020
38.6G scanned at 963M/s, 432K issued at 10.5K/s, 2.76T total
0B resilvered, 0.00% done, no estimated completion time
config:
NAME STATE READ WRITE CKSUM
mypool ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
sdc ONLINE 0 0 0
sdd ONLINE 0 0 0
errors: No known data errors
</code></pre>
<p>Eventually ZFS will finish resilvering and the mirror setup will be complete.</p>
</li>
</ol>
</article>
<footer class="footer pure-u-1 pure-u-md-3-4">
<hr />
<small>
Copyright © 2021 Floating Octothorpe. Except where
otherwise noted, content on this site is licensed under a
<a rel="license"
href="https://creativecommons.org/licenses/by/4.0/">Creative Commons
Attribution 4.0 License</a>.
</small>
</footer>
</body>
</html>