Linux – LVM physical volume priority

linuxlvm

Linux LVM can combine several physical volumes in one group and when spread space of this group among logical volumes.

If some slow devices will be added to group it may slow down all logical volumes. Is there a way to add device but allow system to use it only in starvation case?

Best Answer

This depends on what type of striping you want to use. You can control how logical volumes will span physical volumes by an order of LV creation and PV addition. E.g.:

  1. add pv0
  2. create lv0
  3. add pv1
  4. create lv1

So, now if lv0 spans whole pv0, lv1 will span pv1 (in case of linear striping). Filesystem will use blocks first at the beginning of device, so in linear case, if FS spans multiple PV, last PV will only be used if filesystem is full enough.

If you need non-linear striping across fast devices, you may create VG only with these devices. Then create raid LV in it. Then use this LV as PV. I.e. create second level VG from LV. And then add slow device to this second level VG on linear basis.