It is easy to set up a disk raid using ZFS. Many tutorials / documents give the examples using
# zpool create tank /dev/sdb /dev/sdc /dev/sdd.
However, this is not a good practice, descibed in the ZFS on Linux FAQ, the names of the devices are not persistent. Any device change, for example, unplug a removable hard drive, could mess up with the configuration.
It is suggested to use a persistent disk identifier to manage the zpool, for example using disk ID.
To switch an exist zpool from
/dev/disk/by-id, just export then import the pool.
The above command should replace the disk in zpool with something like
But in some rare case, the output of
# zpool stauts tank may seems like this:
One disk often has multiple entries under
/dev/disk/by-id/, there is no garantee which one will be used by zpool.
The solution is to use vdev ID.
Benefits: The main benefit of this approach is that it allows you to choose meaningful human-readable names. Beyond that, the benefits depend on the naming method employed. If the names are derived from the physical path the benefits of /dev/disk/by-path are realized. On the other hand, aliasing the names based on drive identifiers or WWNs has the same benefits as using /dev/disk/by-id.
Create the config file
This will create friendly disk shortcuts in
After reboot, export and import the zpool:
Remeber when miggrate the pool, also copy the
vdedv_id.conf to the new place.