zfs:add_a_mirror_to_an_existing_zfs_drive
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
zfs:add_a_mirror_to_an_existing_zfs_drive [2020/06/15 22:10] – peter | zfs:add_a_mirror_to_an_existing_zfs_drive [2021/10/13 22:27] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== ZFS - Add a Mirror to an Existing ZFS Drive ====== | ||
- | |||
- | Convert the most basic ZFS pool, a system with a single disk, to a Mirror or Stripe. | ||
- | |||
- | Current Setup: | ||
- | |||
- | * We have a single disk attached to our system, **/ | ||
- | * This disk is used as a simple zfs pool, **tank** | ||
- | * You bought another disk and want to mirror the pool to the new disk, **/ | ||
- | |||
- | ---- | ||
- | |||
- | ===== Ensure the disk names are correct ===== | ||
- | |||
- | Make sure you’ve got the disk names correct. | ||
- | |||
- | Use **dmesg** to see the system messages, to determine which disk is which. | ||
- | |||
- | <WRAP alert> | ||
- | **ALERT: | ||
- | </ | ||
- | |||
- | |||
- | ---- | ||
- | |||
- | ===== Prepare Your Drive ===== | ||
- | |||
- | Delete any existing partitions if needed. | ||
- | |||
- | <code bash> | ||
- | sudo gpart destroy -F /dev/da2 | ||
- | </ | ||
- | |||
- | Format the drive as gpt: | ||
- | |||
- | <code bash> | ||
- | sudo gpart create -s gpt /dev/da2 | ||
- | </ | ||
- | |||
- | Create a zfs partition: | ||
- | |||
- | <code bash> | ||
- | sudo gpart add -t freebsd-zfs /dev/da2 | ||
- | </ | ||
- | |||
- | This new partition is **/ | ||
- | |||
- | ---- | ||
- | |||
- | ===== Get the Partition IDs ===== | ||
- | |||
- | Get the information needed to feed to zfs so that it will configure the drives correctly. | ||
- | |||
- | We will need the gpt ID of the existing partition as well as the new one we’re adding. | ||
- | |||
- | The **zpool status** command will show all we need to know about the existing drive, partition, and pool. | ||
- | |||
- | <code bash> | ||
- | zpool status | ||
- | </ | ||
- | |||
- | returns: | ||
- | |||
- | <code bash> | ||
- | pool: Internal | ||
- | | ||
- | scan: none requested | ||
- | config: | ||
- | |||
- | NAME STATE READ WRITE CKSUM | ||
- | Tank ONLINE | ||
- | gptid/ | ||
- | |||
- | errors: No known data errors | ||
- | </ | ||
- | |||
- | <WRAP info> | ||
- | **NOTE: | ||
- | </ | ||
- | |||
- | |||
- | Determine the ID of the new partition we just created. | ||
- | |||
- | Here’s an abbreviated output of **gpart list**: | ||
- | |||
- | <code bash> | ||
- | gpart list | ||
- | </ | ||
- | |||
- | returns: | ||
- | |||
- | <code bash> | ||
- | Geom name: da2 | ||
- | modified: false | ||
- | state: OK | ||
- | fwheads: 255 | ||
- | fwsectors: 63 | ||
- | last: 7814037127 | ||
- | first: 40 | ||
- | entries: 128 | ||
- | scheme: GPT | ||
- | Providers: | ||
- | 1. Name: da2p1 | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | Mode: r0w0e0 | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | type: freebsd-zfs | ||
- | | ||
- | end: 7814037119 | ||
- | | ||
- | Consumers: | ||
- | 1. Name: da2 | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | Mode: r0w0e0 | ||
- | .... | ||
- | </ | ||
- | |||
- | <WRAP info> | ||
- | **NOTE: | ||
- | </ | ||
- | |||
- | |||
- | ---- | ||
- | |||
- | ===== Mirror the disks ===== | ||
- | |||
- | Tell zfs that these two disks need to be joined together as a mirrored set. | ||
- | |||
- | Here are the inputs: | ||
- | |||
- | The pool name: Tank | ||
- | The existing partition uuid: 799a169a-aa2f-11ea-bfaa-00d861fcb7d8 | ||
- | The new partition uuid: 8229a169a-aa2f-11ea-bfaa-00d861fcb7d8 | ||
- | |||
- | Mirror the disks: | ||
- | |||
- | <code bash> | ||
- | sudo zpool attach Tank / | ||
- | </ | ||
- | |||
- | ZFS will attach the new partition to the existing drive set, mirroring all data from the old drive to the new one. | ||
- | |||
- | <WRAP info> | ||
- | **NOTE: | ||
- | |||
- | You can use the “zpool status Tank” command to see the progress, including an estimated time of completion. | ||
- | |||
- | With two 4 TB drives containing a little over 1 TB of data) it took about 3 hours. | ||
- | |||
- | </ | ||
- | |||
- | <WRAP info> | ||
- | **NOTE: | ||
- | |||
- | You can’t mess with RAID-Z sets in this manner, even though that would be much more useful. | ||
- | |||
- | </ | ||
- | |||
- | |||
- | ---- | ||
- | |||
- | |||
zfs/add_a_mirror_to_an_existing_zfs_drive.1592259043.txt.gz · Last modified: 2020/07/15 09:30 (external edit)