Add post on zfs single disk to mirror

This commit is contained in:
Ariejan de Vroom 2024-03-07 14:04:41 +01:00
parent 45fb9a5a20
commit 8af820358b
Signed by: ariejan
GPG Key ID: AD739154F713697B

View File

@ -0,0 +1,36 @@
+++
date = 2024-03-07
title = "ZFS: Upgrade single disk to mirror"
tags = ["homelab", "storage", "nas", "zfs"]
+++
For a while now I've had a single 3TB WD Green in my NAS to store local [Borg backups](https://www.borgbackup.org/) before syncing them to ~~Google Drive~~ a [Hetzner Storage Box](https://www.hetzner.com/storage/storage-box/).
Because I recently replaced my 3TB Reds for 10TB HGST's, I have some spare drives left.
My goals are:
- Turn the single disk zpool for backups into a mirrored pair.
- Replace the WD Green with a WD Red, eventually.
So, today is about upgrading a single disk ZFS pool to a mirrored pair.
### Prepare the new disk
The 3TB Red came out of my `tank` pool. This means it has partitions and metedata suggesting it's a disk in use by a ZFS pool. To prepare this disk, I'll need to clean it fully. Note that I'm not going to zero out this disk, since it'll be me who's going to use it.
```bash
wipefs -af /dev/sdq
```
This will _destructively_ clean any and all filesystem / ZFS information on the disk.
### Upgrading the ZFS pool
The next step is to upgrade the pool by adding the new device into a mirrored pair.
```bash
zfs attach <pool> <existing hdd guid> <new hdd guid>
```
By using the `zfs attach` command like this, you're creating a mirrored pair out of the existing and new HDDs. After this you'll need to wait for the new HDD to resilver, but after that you're all set.