Score:1

ZFS: restore pool with detached drive

bd flag

I have a Debian system installed on zfspool of 4 HDDs (like raid10 - raid0 of two raid1). And was displayed like set of 2 mirrors mirror0 and mirror1 each with 2 HDDs.

One of the disks became Faulted. As there was no more free slots in this server, I detached it by command:

zpool detach poolname diskname

And then unplug it physically, and plug in a new one. Now zpool looks like this:

zpool status rpool
  pool: rpool
 state: ONLINE
  scan: scrub repaired 52K in 0 days 08:33:06 with 0 errors on Sun May  9 08:57:09 2021
config:

        NAME                                        STATE     READ WRITE CKSUM
        rpool                                       ONLINE       0     0     0
          mirror-0                                  ONLINE       0     0     0
            ata-TOSHIBA_HDWQ140_104EK2MQFAYG-part3  ONLINE       0     0     0
            ata-TOSHIBA_HDWQ140_1042K0ECFAYG-part3  ONLINE       0     0     0
          ata-TOSHIBA_HDWQ140_104EK2MLFAYG          ONLINE       0     0     0

Looks like it's not a raid10 anymore. And I can not replace faulted disk with new one:

zpool replace rpool 4504484537486819887 /dev/disk/by-id/newdisk_id
cannot replace 4504484537486819887 with /dev/disk/by-id/newdisk_id: no such device in pool

What is the safe way to add a new disk to pool and restore pool configuration?

Score:0
ca flag

As you detach the failed disk, the top level vdev is not a mirror anymore. So you can not replace the old disk. Rather, you need to attach the new one with something similar to:

zpool attach rpool ata-TOSHIBA_HDWQ140_104EK2MLFAYG <newdisk>

As always, before running anything, be sure to have current backups.

ALexJolno avatar
bd flag
answer by shodanshok was absolutely correct - I followed recommendation with exact command and zfs successfully attached disk to pool and started resilvering. Now it looks like it was before detachment (with new disk in mirror 1) Thank you!
shodanshok avatar
ca flag
If so, feel free to upvote and accept my answer
ALexJolno avatar
bd flag
Sorry, have no enough reputation yet. I'll return here when earn some.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.