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/sdX
to /dev/disk/by-id
, just export then import the pool.
1 |
|
The above command should replace the disk in zpool with something like ata-WDC_WD40EZRZ-00GXCB0_WD-WCC3Z7KHKLAN
or wwn-0x50014ee215a0e59e
.
But in some rare case, the output of # zpool stauts tank
may seems like this:
1 |
|
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 /etc/zfs/vdev_id.conf
1 |
|
This will create friendly disk shortcuts in /dev/disk/by-vdev/
After reboot, export and import the zpool:
1 |
|
The detailed tutorial of vdev_id.conf
can be found here or here.
Remeber when miggrate the pool, also copy the vdedv_id.conf
to the new place.