From a0f3dde0c08094b0b6b959f3d2295901abc13a90 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Mon, 12 Feb 2024 08:37:33 -0600 Subject: add more content to the zfs post --- content/blog/2024-02-06-zfs.md | 102 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 101 insertions(+), 1 deletion(-) (limited to 'content/blog/2024-02-06-zfs.md') diff --git a/content/blog/2024-02-06-zfs.md b/content/blog/2024-02-06-zfs.md index a0c5023..9dd3eb5 100644 --- a/content/blog/2024-02-06-zfs.md +++ b/content/blog/2024-02-06-zfs.md @@ -35,7 +35,8 @@ zfs-kmod-2.1.5-1ubuntu6~22.04.1 Now that ZFS is installed, we can create and configure the pool. You have various options for configuring ZFS pools that all come different pros -and cons. +and cons. I suggest visiting the links at the top of this post or searching +online for the best configuration for your use-case. - Striped VDEVs (Raid0) - Mirrored VDEVs (Raid1) @@ -133,6 +134,13 @@ existing `tank` pool. sudo zpool add tank mirror /dev/sdX /dev/sdY ``` +If you're adding disks of different sizes, you'll need to use the `-f` flag. +Keep in mind that the max size will be limited to the smallest disk added. + +```sh +sudo zpool add -f tank mirror /dev/sdX /dev/sdY +``` + I added two 8TB hard drives and this process took around 10 seconds to complete. When 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 tank/media 96K 14.3T 96K /tank/media ``` +#### Converting Disks + +Some disks, such as NTFS-formatted drives, will need to be partitioned and +formatted prior to being added to the pool. + +Start by identifying the disks you want to format and add to the pool. + +```sh +sudo fdisk -l | grep /dev +``` + +I am going to format my `/dev/sdc` and `/dev/sdd` disks with the `fdisk` +command. + +See below for instructions on how to use `fdisk`. Here's what I did to create +basic Linux formatted disks: + +- `g` : Create GPT partition table +- `n` : Create a new partition, hit Enter for all default options +- `t` : Change partition type to `20` for `Linux filesystem` +- `w` : Write the changes to disk and exit + +I repeated this process for both disks. + +```sh +> sudo fdisk /dev/sdc + +Welcome to fdisk (util-linux 2.37.2). +Changes will remain in memory only, until you decide to write them. +Be careful before using the write command. + +This disk is currently in use - repartitioning is probably a bad idea. +It's recommended to umount all file systems, and swapoff all swap +partitions on this disk. + + +Command (m for help): m + +Help: + + GPT + M enter protective/hybrid MBR + + Generic + d delete a partition + F list free unpartitioned space + l list known partition types + n add a new partition + p print the partition table + t change a partition type + v verify the partition table + i print information about a partition + + Misc + m print this menu + x extra functionality (experts only) + + Script + I load disk layout from sfdisk script file + O dump disk layout to sfdisk script file + + Save & Exit + w write table to disk and exit + q quit without saving changes + + Create a new label + g create a new empty GPT partition table + G create a new empty SGI (IRIX) partition table + o create a new empty DOS partition table + s create a new empty Sun partition table +``` + +Once the drives are formatted, we can add these disks to the pool. + +```sh +sudo zpool add tank mirror /dev/sdc /dev/sdd +``` + +When we list the pool again, we can see that our size is now updates to +approximately 22TB. This represents my hard drives totalling 45.6TB when +shown with `fdisk -l`, with a Raid10 configuration using 22TB for mirroring +and 22TB of useable space. + +```sh +> zfs list + +NAME USED AVAIL REFER MOUNTPOINT +tank 145G 21.7T 104K /tank +tank/cloud 145G 21.7T 145G /tank/cloud +tank/media 145GT 21.7T 96K /tank/media +``` + ### Creating Datasets According to [ZFS -- cgit v1.2.3-70-g09d2