15

In the example below, how can the devices in the second mirror be changed so they they reference the /dev/disk/by-id instead of /dev/sdX?

user@pc:~$ sudo zpool status
  pool: storage
 state: ONLINE
  scan: scrub repaired 0 in 8h30m with 0 errors on Sun May 28 08:54:48 2017
config:

    NAME                                  STATE     READ WRITE CKSUM
    storage                               ONLINE       0     0     0
      mirror-0                            ONLINE       0     0     0
        ata-ST2000AS0002-1NA12Z_Z840MHWP  ONLINE       0     0     0
        ata-ST2000AS0002-1NA12Z_Z840MHTQ  ONLINE       0     0     0
      mirror-1                            ONLINE       0     0     0
        sdd                               ONLINE       0     0     0
        sde                               ONLINE       0     0     0
1
  • Did you manage to change the vdevs in /dev/sdx to /dev/disk/by-id/.. ? Commented Apr 4, 2018 at 4:56

3 Answers 3

10

You simply need to export and re-import your pool with a different default search directory for devices (-d option).

For example:

zpool export storage
zpool import storage -d /dev/disk/by-id
0

I'm not familiar with ZFS on linux (I'm guessing this is a problem peculiar to linux, Solaris and FreeBSD wouldn't have that kind of device name schizophrenia...) but you might try detaching and reattaching the drives as disk-by-id (be sure to give each time to fully resilver)

zpool detach mirror-1 sdd
zpool attach mirror-1 /dev/disk/sdd-by-id
<wait until zpool status shows it's rebuilt...>

and so on...

0

I know this is an old question, but it is the one that still comes up. As an alternative to shodanshok's answer (which works), where you export and re-import the pool, there is a method that does not require taking the pool offline to do. Unlike quadruplebucky's answer this solution does not require the pool to be a mirror, it can be a raidz. I've done it to my raidz2.

This requires the pool to have enough redundancy to take a drive offline. It will also trigger a resilver of the array. Do NOT do more than 1 drive at a time with this method.

zpool offline poolname /dev/sdd
zpool labelclear -f /dev/sdd
zpool replace poolname /dev/sdd /dev/disk/by-id/ata-drivemodel_SN

These three lines will

  1. take drive /dev/sdd offline and stop using it. Note that this will cause it to come out of sync with the rest of the array
  2. Forcing remove the ZFS metadata from drive /dev/sdd despite poolname still being an active pool.
  3. Trigger a resilver of poolname using the /dev/disk/by-id/... reference. You must wait for this to finish before doing another drive.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.