How to repair a pool after failed drive

At first I had a pool with 4 disks in 2 mirrors of two. Then one disk died. I replaced the physical disk with a new one.

After that I don’t remember what I did. Somehow I must have removed the old dead disk from the pool. Now I have
Code:
root@fn2:~ # zpool status
  pool: fn2
 state: ONLINE

       NAME                    STATE     READ WRITE CKSUM
        fn2                       ONLINE       0     0     0
          mirror-0                ONLINE       0     0     0
            gptid0                 ONLINE       0     0     0
            gptid1                 ONLINE       0     0     0
          gptid2                   ONLINE       0     0     0

I want to add a new disk to the pool to get two mirrors.
I don’t want to make any mistakes - I could lose all my data.

How can I add a disk to this pool to get mirrors?

Please help.
Thank you.
 
You have to be very careful now!
The command you need is zpool attach fn2 gptid2 <YOUR_NEW_DEVICE>.
Be careful NOT to use the add command, it would stripe another vdev into your pool and this cannot be undone.

zpool-attach(8)
Attaches new_device to the existing device. The existing device cannot be part of a raidz configuration. If device is not currently part of a mirrored configuration, device automatically transforms into a two-way mirror of device and new_device. If device is part of
a two-way mirror, attaching new_device creates a three-way mirror, and so on.
 
Why did zpool status wrote those names of disks?
How to find out what is the name of NEW_DEVICE? And I think that "real" name of existing disk is not gptid2?
 
Why did zpool status wrote those names of disks?
How to find out what is the name of NEW_DEVICE? And I think that "real" name of existing disk is not gptid2?
If you don't know how your new device is called, you could use the commands mentioned by grahamperrin, that's probably the proper way to do it.
I usually list the contents of /dev/ada* or /dev/da* to see what is my latest attached drive. When you attach it to the machine you usually get a related text in the output of dmesg. In case you needed a shutdown to attach the device, then it might not be the last entry shown in dmesg, it depends.

gpart would show the device only if it has been formatted with a GPT partition table. If not, you need to partition it first like so (carefully select the right device, otherwise you can lose data. I use ada4 as an example.)
Also very important: Make sure you use exactly the same partition size as your other device you want to mirror.
Code:
# Creates a GPT formatted partition table on the device, destroying any previous partitions if existing!!!
gpart create -s GPT /dev/ada4

# In case you need a swap partition:
gpart add -t freebsd-swap -s 32G -a 1M -l swap4 /dev/ada4

# The rest is taken by a ZFS-type partition, aligned at 1M although you could use 4k as a value too. I like to round up. "storage4" is a label you could change.
# You can list your other device's partition table with "gpart show" and then just copy the layout by using -b for "beginning" and -s for "size".
gpart add -t freebsd-zfs -a 1M -l storage4 /dev/ada4

gpart show ada4
# The GPT partitions appears here: /dev/gpt/storage4, /dev/gpt/swap4
 
Back
Top