2

Data is intact in the first drive, second drive is "UNAVAIL". Reason for overwrite is my lack of concentration while applying dd command ...

Command

sudo zpool replace -f hgst 4596995095197485503 /dev/sdd

Gives

invalid vdev specification the following errors must be manually repaired: /dev/sdd1 is part of active pool 'hgst'

I took the disk offline and removed partitions with Gparted. After reboot they reappeared, and zpool replace -command did not work.

Command

dd if=/dev/zero of=/dev/sdd bs=1M count=2 seek=2048

and

dd if=/dev/zero of=/dev/sdd bs=512 seek=$(( $(blockdev --getsz /dev/sdd) - 1 )) count=1

did not help either.

Command sudo zpool labelclear /dev/sdd and then zpool replace -command gave

cannot replace 4596995095197485503 with /dev/sdd: /dev/sdd is busy

Busy also with command

sudo zpool replace -f hgst 4596995095197485503 /dev/disk/by-id/ata-HGST_HDN724030ALE640_PK2238P3G3E0MJ

zpool status

3 Answers3

5

Well, it was a mirror, so it sure seems like you would just need to re-create the partition table and correctly sized partitions on the wiped disk, and the add it, then remove the left over entry.

This command would add a new device to the mirror

zpool add hgst mirror good_device_name new_device

And remove the old device

zpool remove hgst old_device_id

Or in a single step

zpool replace hgst old_device_id new_device

Links

P.S. Make sure that you have a good verified external backup, because you don't want to make things worse.

Zoredache
  • 128,755
  • 40
  • 271
  • 413
2

I would use these commands:

zpool detach hgst <corrupted_device>
zpool attach -f hgst <online_device> <new_device>

(check man pool to be sure)

Use pool add carefully, because you easily end up with striped pool instead of a mirror!

chicks
  • 3,639
  • 10
  • 26
  • 36
Michel
  • 21
  • 1
2

I took the disk offline

zpool offline hgst /dev/disk/by-id/ata-HGST_HDN724030ALE640_PK2238P3G3E0MJ

Detached the drive

zpool detach hgst 4596995095197485503

Cleared label

zpool labelclear -f /dev/disk/by-id/ata-HGST_HDN724030ALE640_PK2238P3G3E0MJ

Attached the disk back

zpool attach hgst ata-HGST_HDN724030ALE640_PK2238P3G3E3UJ /dev/disk/by-id/ata-HGST_HDN724030ALE640_PK2238P3G3E0MJ

And now it is resilvering.

NAME                                         STATE     READ WRITE CKSUM
hgst                                         ONLINE       0     0     0
  mirror-0                                   ONLINE       0     0     0
    ata-HGST_HDN724030ALE640_PK2238P3G3E3UJ  ONLINE       0     0     0
    ata-HGST_HDN724030ALE640_PK2238P3G3E0MJ  ONLINE       0     0     0  (resilvering)