Commit 7522b99532

7522b995327bfaf73fef88f0ca0f8422db43c540

parent: 300cdf0772

Unsigned

cmc <hello@cleberg.net> · 2024-02-12 14:37 UTC

add more content to the zfs post

Layout: unified · split

content/blog/2024-02-06-zfs.md +101 −1
@@ -35,7 +35,8 @@ zfs-kmod-2.1.5-1ubuntu6~22.04.1
3535Now that ZFS is installed, we can create and configure the pool.
3636
3737You have various options for configuring ZFS pools that all come different pros
38and cons.
38and cons. I suggest visiting the links at the top of this post or searching
39online for the best configuration for your use-case.
3940
4041- Striped VDEVs (Raid0)
4142- Mirrored VDEVs (Raid1)
@@ -133,6 +134,13 @@ existing `tank` pool.
133134sudo zpool add tank mirror /dev/sdX /dev/sdY
134135```
135136
137If you're adding disks of different sizes, you'll need to use the `-f` flag.
138Keep in mind that the max size will be limited to the smallest disk added.
139
140```sh
141sudo zpool add -f tank mirror /dev/sdX /dev/sdY
142```
143
136144I added two 8TB hard drives and this process took around 10 seconds to complete.
137145
138146When viewing the pool again, you can see that the pool has now doubled in size.
@@ -147,6 +155,98 @@ tank/cloud 145G 14.3T 145G /tank/cloud
147155tank/media 96K 14.3T 96K /tank/media
148156```
149157
158#### Converting Disks
159
160Some disks, such as NTFS-formatted drives, will need to be partitioned and
161formatted prior to being added to the pool.
162
163Start by identifying the disks you want to format and add to the pool.
164
165```sh
166sudo fdisk -l | grep /dev
167```
168
169I am going to format my `/dev/sdc` and `/dev/sdd` disks with the `fdisk`
170command.
171
172See below for instructions on how to use `fdisk`. Here's what I did to create
173basic Linux formatted disks:
174
175- `g` : Create GPT partition table
176- `n` : Create a new partition, hit Enter for all default options
177- `t` : Change partition type to `20` for `Linux filesystem`
178- `w` : Write the changes to disk and exit
179
180I repeated this process for both disks.
181
182```sh
183> sudo fdisk /dev/sdc
184
185Welcome to fdisk (util-linux 2.37.2).
186Changes will remain in memory only, until you decide to write them.
187Be careful before using the write command.
188
189This disk is currently in use - repartitioning is probably a bad idea.
190It's recommended to umount all file systems, and swapoff all swap
191partitions on this disk.
192
193
194Command (m for help): m
195
196Help:
197
198 GPT
199 M enter protective/hybrid MBR
200
201 Generic
202 d delete a partition
203 F list free unpartitioned space
204 l list known partition types
205 n add a new partition
206 p print the partition table
207 t change a partition type
208 v verify the partition table
209 i print information about a partition
210
211 Misc
212 m print this menu
213 x extra functionality (experts only)
214
215 Script
216 I load disk layout from sfdisk script file
217 O dump disk layout to sfdisk script file
218
219 Save & Exit
220 w write table to disk and exit
221 q quit without saving changes
222
223 Create a new label
224 g create a new empty GPT partition table
225 G create a new empty SGI (IRIX) partition table
226 o create a new empty DOS partition table
227 s create a new empty Sun partition table
228```
229
230Once the drives are formatted, we can add these disks to the pool.
231
232```sh
233sudo zpool add tank mirror /dev/sdc /dev/sdd
234```
235
236When we list the pool again, we can see that our size is now updates to
237approximately 22TB. This represents my hard drives totalling 45.6TB when
238shown with `fdisk -l`, with a Raid10 configuration using 22TB for mirroring
239and 22TB of useable space.
240
241```sh
242> zfs list
243
244NAME USED AVAIL REFER MOUNTPOINT
245tank 145G 21.7T 104K /tank
246tank/cloud 145G 21.7T 145G /tank/cloud
247tank/media 145GT 21.7T 96K /tank/media
248```
249
150250### Creating Datasets
151251
152252According to [ZFS