2

So I'm playing around with ZFS on what will eventually be a file server, and I managed to get myself into this state:

  pool: storage
 state: DEGRADED
status: One or more devices has experienced an unrecoverable error.  An
        attempt was made to correct the error.  Applications are unaffected.
action: Determine if the device needs to be replaced, and clear the errors
        using 'zpool clear' or replace the device with 'zpool replace'.
   see: http://zfsonlinux.org/msg/ZFS-8000-9P
  scan: scrub in progress since Wed Oct 18 17:55:08 2017
    272G scanned out of 665G at 512M/s, 0h13m to go
    8K repaired, 40.92% done
config:

        NAME                                      STATE     READ WRITE CKSUM
        storage                                   DEGRADED     0     0     0
          raidz2-0                                DEGRADED     0     0     0
            ata-Hitachi_HUA723020ALA641_YFH0ZXHA  ONLINE       0     0     0
            ata-Hitachi_HUA723020ALA641_YFH2808B  ONLINE       0     0     0
            ata-Hitachi_HUA723020ALA641_YGGLAUJA  ONLINE       0     0     0
            ata-Hitachi_HUA723020ALA641_YGGN6B7A  ONLINE       0     0     0
            sdf                                   OFFLINE      0     0     2  (repairing)

errors: No known data errors

I did this by building a 5 drive raidz2 pool, then intentionally corrupting one of the disks, then somehow removing/replacing it. But I think at some point I added the disk using the sdX label instead of what I wanted, which is the "by-id" label.

The array works in this state, but if it were production I'd much rather have the naming consistent, and at some level I'm really just trying to understand it better.

What are possible ways to "rename" this last device? (Other than completely destroying the pool!)

4
  • 1
    Did you try exporting and re-importing the pool? – ewwhite Oct 18 '17 at 22:21
  • Corrupt this drive too and readd it with right name – Marco Oct 18 '17 at 22:26
  • Sure seems like you should be able to remove that device from the vdev, then re-add it. – Zoredache Oct 19 '17 at 6:15
  • You might want to take a look here. I suppose you can create a directory, then symlink all drives into it? Afterwards you can just do zpool export pool && zpool import -d /path/to/dir. Not sure if/how it will work across reboots though, so you probably want to test it before putting it in production. – cyqsimon Jun 22 at 2:25
0

So I'm not sure I did it the right or best way, but the only way I could get this to work was to replace the disk with a different disk, and then replace that one with the original one, using the new name/ID that I want. I'm 99% sure that this is because ZFS does not allow you to replace a disk that's marked as in-use, and the UUID of what is "sdf" above was in the ZFS database as an active device. So even zeroing out the label/metadata didn't help, because when you try to add/replace that disk is still present in the database.

If you replace this disk with something that has a different ID, when the replace is finished it clears the ID from the zdb. THEN you can "re-replace" the disk with the original (because there's no longer a conflict).

I'm reasonably sure that IF you can manually edit the ZFS database, you could probably just solve this, but I haven't gotten that far yet...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.